# OPA MCP

> OPA MCP is an open-source MCP server for developer tools. Write, test, lint and explain OPA Rego policies from any MCP client. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted, macOS, Windows, Linux
- **Website:** https://orygn.tech
- **Repository:** https://github.com/orygnscode/opa-mcp-server
- **MCP Registry name:** io.github.OrygnsCode/opa-mcp
- **Categories:** developer tools, security
- **Listing updated:** 2026-11-15

## About

The README counts 52 tools, split into two groups. The rego_* language tools work on policy text with the opa binary and need no running server. The opa_* runtime tools talk to a live OPA server through OPA_URL, which defaults to http://localhost:8181.

Optional helpers widen the toolset: Regal powers rego_lint, rego_security_audit and rego_fix, Conftest powers the conftest_* tools, and rego_playground_share publishes a policy as a GitHub gist when a token with the gist scope is set. Other named tools include rego_explain_decision, rego_bench, rego_migrate_v1 for moving Rego v0 policies to v1, and rego_generate_test_skeleton, which writes todo_test_ stubs that opa test skips until you fill them in.

File access is off until you list allowed root directories in OPA_MCP_ALLOWED_PATHS. Subprocesses no longer inherit the server's environment, so a policy cannot read host variables unless you name them in OPA_MCP_PASSTHROUGH_ENV. It runs over stdio from npm or Docker and needs Node.js 22 or later.

## Features

- **Rego authoring tools:** The rego_* tools validate, lint, fix, benchmark and explain policies using the local opa binary.
- **Live OPA server tools:** The opa_* tools query a running OPA instance, with an optional bearer token for token authentication.
- **Regal and Conftest support:** Linting, security audits and Conftest checks run when those binaries are installed.
- **Rego v0 to v1 migration:** rego_migrate_v1 converts older policies, since the bundled OPA 1.x no longer parses v0 syntax.
- **Path allow-list:** File-based tools refuse disk access until OPA_MCP_ALLOWED_PATHS names permitted root directories.
- **Scrubbed subprocess environment:** Child processes do not inherit the server's environment unless variables are passed through explicitly.

## Good for

- Check that a Rego policy compiles before committing it
- Ask an assistant why a policy denied a given input
- Benchmark a slow rule and compare runs
- Convert a Rego v0 policy set to v1
- Generate test stubs for an existing policy
- Lint policies for security issues with Regal

## Install

### Claude Code (Terminal)

```sh
claude mcp add opa-mcp --env OPA_TOKEN='<OPA_TOKEN>' --env GITHUB_TOKEN='<GITHUB_TOKEN>' -- npx -y @orygn/opa-mcp
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "opa-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@orygn/opa-mcp"
      ],
      "env": {
        "OPA_TOKEN": "<OPA_TOKEN>",
        "GITHUB_TOKEN": "<GITHUB_TOKEN>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "opa-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@orygn/opa-mcp"
      ],
      "env": {
        "OPA_TOKEN": "<OPA_TOKEN>",
        "GITHUB_TOKEN": "<GITHUB_TOKEN>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "opa-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@orygn/opa-mcp"
      ],
      "env": {
        "OPA_TOKEN": "<OPA_TOKEN>",
        "GITHUB_TOKEN": "<GITHUB_TOKEN>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "opa-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@orygn/opa-mcp"
      ],
      "env": {
        "OPA_TOKEN": "<OPA_TOKEN>",
        "GITHUB_TOKEN": "<GITHUB_TOKEN>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "opa-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@orygn/opa-mcp"
      ],
      "env": {
        "OPA_TOKEN": "<OPA_TOKEN>",
        "GITHUB_TOKEN": "<GITHUB_TOKEN>"
      }
    }
  }
}
```

## Tools

- `rego_lint`: Lints Rego policies using Regal.
- `rego_security_audit`: Audits policies for security issues using Regal.
- `rego_fix`: Applies Regal fixes to a policy.
- `rego_playground_share`: Shares a policy as a GitHub gist.
- `rego_explain_decision`: Returns the evaluation trace of a decision as readable lines.
- `rego_bench`: Benchmarks a policy and reports iterations and time, allocations and bytes per operation.
- `rego_migrate_v1`: Converts Rego v0 policies to v1.
- `rego_generate_test_skeleton`: Writes todo_test_ stubs for a policy.
- `opa_exec`: Evaluates against policies and data with opa.
- `conftest_test`: Runs Conftest checks and reports whether any rule was evaluated.

## FAQ

### Do I need a running OPA server?

Only for the opa_* runtime tools. The rego_* language tools run the local opa binary and do not need a server.

### Which Node.js version is required?

Version 0.7.0 raised the requirement to Node.js 22 or later.

### How do I let the tools read my policy files?

Set OPA_MCP_ALLOWED_PATHS to a comma-separated list of root directories. Until then file-based tools refuse to touch the disk.

### Which clients does it work with?

The README names Claude Desktop, Claude Code, Cursor, VS Code, Windsurf and Zed, and says any MCP-compatible client works.

### Is OPA MCP free?

Yes. OPA MCP is open source, so you can use and self-host it for free.

### How do I add OPA MCP to Claude Code?

Run this command in your terminal: claude mcp add opa-mcp --env OPA_TOKEN='<OPA_TOKEN>' --env GITHUB_TOKEN='<GITHUB_TOKEN>' -- npx -y @orygn/opa-mcp

### What are the best alternatives to OPA MCP?

The closest alternatives to OPA MCP are REA, Codebase Memory, GitHub, Serena MCP: the IDE for your agent and XERJ.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [Ouroboros](https://ai-powered.com/mcp/ouroboros): Ouroboros is an open-source MCP server for developer tools.
- [Claude Code Ultimate Guide](https://ai-powered.com/mcp/claude-code-ultimate-guide): Claude Code Ultimate Guide is an open-source MCP server for ai models and llm tooling.
- [Concord MCP](https://ai-powered.com/mcp/concord-mcp): Concord MCP is a freemium MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/opa-mcp
