Model Context Protocol server for Open Policy Agent (OPA).
5.5K
Model Context Protocol (MCP) server for Open Policy Agent (OPA) and the Rego policy language.
Wraps the OPA CLI, the OPA REST API, and the Regal linter behind 52 schema-validated tools so any MCP-compatible client (Claude Desktop, Claude Code, Cursor, VS Code, Zed, Windsurf) can author, evaluate, and debug Rego policies through a structured tool surface instead of free-form CLI text.
This image is multi-arch (linux/amd64, linux/arm64), runs as a non-root user, and bundles
pinned versions of opa and regal inside the container. No host install of OPA or Regal is
required.
That is the main reason to use this image over npm install -g @orygn/opa-mcp -- you get a
self-contained runtime with pinned, digest-checked binaries and no
version-skew risk.
Note on conftest: The
conftest_*tools (policy testing for Kubernetes, Terraform, Helm, Dockerfile, and other configuration formats) require theconftestbinary. It is not bundled in this image. To use those tools, either mount aconftestbinary into the container or extend this image and install it.
docker pull orygn/opa-mcp:latest
docker run --rm -i \
-v /path/to/your/policies:/policies:ro \
-e OPA_MCP_ALLOWED_PATHS=/policies \
orygn/opa-mcp
The container speaks MCP over stdio. Wire it into your client by pointing it at
docker run --rm -i ... orygn/opa-mcp as the launch command.
| Tag | Meaning |
|---|---|
latest | Latest stable release. |
0.6.0 | An exact, immutable release. |
0.6, 0 | Track the newest patch and minor. |
Versioned tags follow Semantic Versioning. The public surface for SemVer purposes is the set of registered tools, prompts, and resources, their input/output schemas, and the recognized environment variables.
All configuration is via environment variables. Every variable is optional.
| Variable | Default | Purpose |
|---|---|---|
OPA_URL | http://localhost:8181 | Base URL of an OPA REST endpoint, used by opa_* tools. Inside a container localhost is the container itself, so to reach an OPA on the host set this explicitly (http://host.docker.internal:8181 on Docker Desktop; on Linux add --add-host=host.docker.internal:host-gateway). |
OPA_TOKEN | (unset) | Bearer token for OPA, if required. Treated as a secret. |
OPA_MCP_ALLOWED_PATHS | (unset) | Comma-separated list of directories the server is allowed to read policies from. When unset, file-based tools refuse to read from disk. |
OPA_MCP_LOG_LEVEL | info | One of debug, info, warn, error. |
OPA_MCP_MAX_RESPONSE_BYTES | 100000 | Cap on a single tool response. |
OPA_MCP_TIMEOUT_MS | 30000 | Hard timeout for any spawned subprocess. |
CONFTEST_BINARY | conftest | Path to the conftest binary. Only relevant if you extend this image to include conftest. |
OPA_MCP_HTTP_TIMEOUT_MS | 15000 | Timeout for HTTP requests to the OPA REST API. |
OPA_MCP_LOG_FILE | <tmpdir>/orygn-opa-mcp.log | Path the server appends logs to. The server never writes to stdout; that channel is reserved for the MCP protocol. |
OPA_MCP_NO_TELEMETRY | (unset) | Set to 1 to disable the anonymous startup ping. The ping sends the server version, OS platform, and a random install ID. No policy content or file paths are ever sent. |
OPA_MCP_MAX_SUBPROCESS_BYTES | 33554432 | Cap on bytes captured from a subprocess's stdout and stderr. On overflow the child is stopped and the tool returns OUTPUT_TOO_LARGE. |
OPA_MCP_PASSTHROUGH_ENV | (unset) | Comma-separated variable names to pass through to the OPA binary. Everything else is withheld. Anything named here is readable by evaluated policy. |
OPA_MCP_BLOCK_ENV | (unset) | Comma-separated variable names withheld from opa, regal and conftest even when the built-in allow-list would pass them. Applied last, so it also overrides OPA_MCP_PASSTHROUGH_ENV; use it to drop the proxy variables, at the cost of proxy support. |
GITHUB_TOKEN | (unset) | Personal access token with the gist scope. Only rego_playground_share reads it. |
OPA_BINARY and REGAL_BINARY are not used in this image -- both binaries ship at known paths
inside the container.
52 tools across seven categories:
rego_format, rego_lint, rego_check, rego_check_schema, rego_parse_ast,
rego_deps, rego_inspect, rego_capabilities, rego_migrate_v1rego_eval, rego_test, rego_test_multiroot, rego_bench,
rego_eval_with_profile, rego_eval_with_explain, rego_eval_with_coverage,
rego_compile_query, opa_execopa_bundle_build, opa_bundle_sign, opa_bundle_verifyopa_list_policies, opa_get_policy, opa_put_policy, opa_delete_policy,
opa_get_data, opa_put_data, opa_patch_data, opa_delete_data, opa_query_decision,
opa_compile_query, opa_health, opa_status, opa_configrego_explain_decision, rego_explain_undefined, rego_describe_policy,
rego_generate_test_skeleton, rego_suggest_fix, rego_fix, rego_format_write,
rego_security_audit, rego_coverage_gaps, rego_infer_input_schema, rego_policy_diff,
rego_verify, rego_playground_sharemcp_server_infoconftest_test, conftest_verify, conftest_pull, conftest_push
(requires conftest binary -- not bundled; see note above)Three MCP prompts and three resources (built-in function catalog, Rego style guide, curated pattern library).
Stable error codes (INVALID_REGO, OPA_UNREACHABLE, PATH_NOT_ALLOWED, TIMEOUT,
CANCELLED, etc.) and a structured { ok, data | error } envelope on every response.
shell: false and a hard timeout.OPA_MCP_ALLOWED_PATHS.OPA_TOKEN is never echoed in tool responses or log output.opa and regal are pinned
and checked against their published digests.MIT © Orygn LLC
@orygn/opa-mcp is an independent project. It is not affiliated with, endorsed by, or sponsored
by the Open Policy Agent project, the Cloud Native Computing Foundation, Styra, or Anthropic.
"Open Policy Agent" and "Rego" are trademarks of their respective owners.
"Model Context Protocol" is a trademark of Anthropic, PBC.
Content type
Image
Digest
sha256:5bdf9a678…
Size
134.5 MB
Last updated
9 days ago
docker pull orygn/opa-mcp