OPA MCP
Write, test, lint and explain OPA Rego policies from any MCP client
- Pricing
- Open source
- Platforms
- CLI, self-hosted, macOS
- Runs
- Locally
- Version
- 0.10.0
- Listing updated
- 2 days ago
About OPA MCP
OPA MCP is an open-source MCP server for developer tools. It runs locally on your machine and is started by your AI client.
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.
Install
Run in a terminal
claude mcp add opa-mcp --env OPA_TOKEN='<OPA_TOKEN>' --env GITHUB_TOKEN='<GITHUB_TOKEN>' -- npx -y @orygn/opa-mcpAdd to claude_desktop_config.json
{
"mcpServers": {
"opa-mcp": {
"command": "npx",
"args": [
"-y",
"@orygn/opa-mcp"
],
"env": {
"OPA_TOKEN": "<OPA_TOKEN>",
"GITHUB_TOKEN": "<GITHUB_TOKEN>"
}
}
}
}Add to ~/.cursor/mcp.json
{
"mcpServers": {
"opa-mcp": {
"command": "npx",
"args": [
"-y",
"@orygn/opa-mcp"
],
"env": {
"OPA_TOKEN": "<OPA_TOKEN>",
"GITHUB_TOKEN": "<GITHUB_TOKEN>"
}
}
}
}Add to .vscode/mcp.json
{
"servers": {
"opa-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@orygn/opa-mcp"
],
"env": {
"OPA_TOKEN": "<OPA_TOKEN>",
"GITHUB_TOKEN": "<GITHUB_TOKEN>"
}
}
}
}Add to ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"opa-mcp": {
"command": "npx",
"args": [
"-y",
"@orygn/opa-mcp"
],
"env": {
"OPA_TOKEN": "<OPA_TOKEN>",
"GITHUB_TOKEN": "<GITHUB_TOKEN>"
}
}
}
}Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"opa-mcp": {
"command": "npx",
"args": [
"-y",
"@orygn/opa-mcp"
],
"env": {
"OPA_TOKEN": "<OPA_TOKEN>",
"GITHUB_TOKEN": "<GITHUB_TOKEN>"
}
}
}
}Configuration
OPA_URLBase URL of a running OPA server. Required only for opa_* runtime tools, not for rego_* language tools.OPA_TOKENBearer token for OPA running with --authentication=token.OPA_BINARYPath to the opa binary. Defaults to 'opa' on PATH.REGAL_BINARYPath to the regal binary (optional; used by rego_lint, rego_security_audit and rego_fix). Defaults to 'regal' on PATH.CONFTEST_BINARYPath to the conftest binary (optional, used by conftest_* tools). Defaults to 'conftest' on PATH.OPA_MCP_ALLOWED_PATHSComma-separated list of root directories tools may read/write. When unset, file-based tools refuse to access the disk.GITHUB_TOKENGitHub personal access token with the "gist" scope. Required only for rego_playground_share.OPA_URLBase URL of a running OPA server.OPA_TOKENBearer token for OPA authentication.GITHUB_TOKENGitHub personal access token with the "gist" scope. Required only for rego_playground_share.
Tools this server provides (10)
Taken from the project documentation; the running server may differ.
- 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.
What it does
- 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
Pricing
Open source
Free; published on npm and Docker Hub
Prices change. Check orygn.tech before you buy.
OPA MCP 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 to OPA MCP

REA
MCP serverCLI and MCP server that lets coding agents reverse engineer apps and binaries
Runs locally- Open source
- 464K GitHub stars
- Developer tools

Codebase Memory
MCP serverLocal MCP server that builds a code knowledge graph for AI coding agents
Runs locally- Open source
- 48.7K GitHub stars
- Knowledge and memory

GitHub
MCP serverOfficial MCP server connecting AI assistants to GitHub repos, issues and workflows
Not checked yet- Remote
- Open source
- 34.5K GitHub stars
- Developer tools

Serena MCP: the IDE for your agent
MCP serverMCP toolkit giving coding agents symbol-level code retrieval and editing
Runs locally- Open source
- 31.5K GitHub stars
- Developer tools

XERJ
MCP serverLocal search engine for AI agents with cited answers over your code and docs
Runs locally- Open source
- 19.2K GitHub stars
- Knowledge and memory

Ouroboros
MCP serverSpec-first layer that pins requirements and verifies results of AI coding agent work
Runs locally- Open source
- 6.4K GitHub stars
- Developer tools