mcp-opa-authz
Provides tools for querying authorization decisions from an OpenID AuthZEN-compliant Policy Decision Point (PDP). Supports single access evaluations (subject/action/resource) over POST /access/v1/evaluation, batched evaluations with execute_all / deny_on_first_deny / permit_on_first_permit semantics, and PDP metadata discovery via /.well-known/authzen-configuration. Correlates decisions with PDP logs through X-Request-ID, validating AuthZEN's subject/action/resource information model before sending, and treating missing decisions or authentication failures as errors rather than denials.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-opa-authz
Stop letting your agent guess at authorization. This is an MCP server that answers "is this allowed?" from real policy code — either Rego you hand it, or the OpenID AuthZEN 1.0 PDP that actually governs your system.
Ask a model whether Alice may delete that document and it will produce a confident, plausible, unfalsifiable answer. Give it these tools and the answer comes from the policy.
brew install kanywst/tap/mcp-opa-authz
# or, without Homebrew:
go install github.com/dyokto/mcp-opa-authz@latest
claude mcp add opa-authz -- mcp-opa-authzThat is enough for evaluate_policy. Point it at a PDP to get the rest:
claude mcp add opa-authz \
--env AUTHZEN_PDP_URL=http://localhost:8181/access/v1/evaluation \
-- mcp-opa-authzThe quick start installs it, connects an MCP client, and asks evaluate_policy for one denied and one allowed answer without a model. Docs site: https://dyokto.github.io/mcp-opa-authz/.
Two layers, same question
Tool | Answers | Needs |
| "What does this Rego say?" Evaluated in-process by OPA. | Nothing external |
| "What does the PDP that governs this system say?" | A reachable PDP |
| The same, over a list — which of these may the subject touch? | A reachable PDP |
| "Who may…", "which resources may…", "what may…" — the PDP lists what is permitted. | A PDP with the Search APIs |
| "Which endpoints does this PDP offer?" | A reachable PDP |
| "What request does a COAZ-MCP enforcement point send for this MCP call?" | Nothing external; a PDP with |
Use evaluate_policy while authoring or debugging a policy you have the source of. Use authzen_evaluate when the decision has to come from production, not from a policy pasted into the chat. The server's MCP instructions tell the model the same thing, so it usually picks correctly on its own.
Related MCP server: enterprise-auth-mcp-server
What makes this different from opa eval in a shell tool
An agent given shell access can already run opa eval. What it cannot do is get an answer it is allowed to trust:
Undefined is not false. A Rego query with no matching rule and no default returns
[]. Every model reads that as a deny.evaluate_policyreturnsdefinedalongsidevalue, so "the policy denied" and "the policy has no opinion" stop being the same answer.A PDP that did not answer is not a deny. AuthZEN makes
decisiona required member. A response missing it decodes into a Goboolasfalse— a broken PDP would look like a strict one. This server treats a missingdecisionas a failure, never as a deny. Same for a 401: that means this server failed to authenticate, not that the subject was denied, and the error says so.The policy runs in a sandbox. Rego handed to an MCP server was written by a model, from text that may have come from a web page. OPA's
http.sendwould let that policy make arbitrary HTTP requests from your laptop, andopa.runtime()would hand it your environment. Both are compiled out. See Security.Batch decisions carry their index.
permit_on_first_permitlegitimately returns fewer decisions than you sent. Zipping the arrays would attach a decision to the wrong resource.An empty search is not a failed search.
results: []means nothing is permitted; a response with noresultsmember, or a result of the wrong entity type, is an error.
Demo
Debugging a policy that is denying when it should not:
> Why is bob getting denied on doc-1? Here's the policy and the input.
evaluate_policy(rego=…, query="data.rbac.allow", input_json=…, trace=true)
{
"defined": true,
"value": false,
"printed": ["checking roles for bob"],
"trace": [
"policy.rego:16 | Enter data.rbac.allow",
…
"policy.rego:17 | | Eval internal.print([__local8__, __local9__])",
"policy.rego:18 | | Eval __local10__ = input.user",
"policy.rego:18 | | Unify __local10__ = input.user",
"policy.rego:18 | | Unify \"bob\" = __local10__",
"policy.rego:18 | | Eval role = data.rbac.roles[__local10__][__local0__]",
…
"policy.rego:18 | | Fail role = data.rbac.roles[__local10__][__local0__]",
…
"policy.rego:3 | Enter data.rbac.allow",
"policy.rego:3 | | Eval true",
"policy.rego:3 | | Unify true = _",
"policy.rego:3 | | Exit data.rbac.allow early",
…
]
}
Line 18 fails on `roles["bob"]`: bob has no entry in `roles` at all, so the
rule body never reaches the permission check and the `default` on line 3
answers. Adding "bob": {"viewer"} fixes it.Then confirming against the PDP that actually runs:
> Does production agree?
authzen_evaluate(subject={"type":"user","id":"bob"}, …)
{ "decision": false, "context": { "reason": "no role binding" },
"request_id": "3f9c…", "pdp_url": "https://pdp.internal/access/v1/evaluation" }Documentation
docs/quickstart.md: install, connect a client, then one denied and one allowed decision over stdio
docs/tools.md: every tool's parameters and results
docs/configuration.md: environment variables and their defaults
docs/running.md: from source, in a container, and in Cursor and other MCP clients; PDPs it works with
docs/standards.md: which parts of AuthZEN 1.0 and COAZ-MCP are implemented
docs/sandbox.md: the Rego sandbox and the limits on the PDP client
Security
evaluate_policy runs model-written Rego with http.send, net.lookup_ip_addr and opa.runtime removed, and the PDP client refuses redirects and caps what it reads. docs/sandbox.md has the details.
Reporting a vulnerability: see SECURITY.md.
Examples
examples/ has reference Rego policies for evaluate_policy:
rbac.rego— role to permission mappingabac.rego— clearance level comparisonk8s_admission.rego— admission control: required labels
Verifying a release
Releases ship a cosign-signed checksum file (Sigstore keyless via GitHub OIDC) and a CycloneDX SBOM per archive. The signature and its certificate travel together in one Sigstore bundle, *-checksums.txt.sigstore.json.
TAG=v0.8.0
gh release download "$TAG" -R dyokto/mcp-opa-authz -p '*-checksums.txt*'
# The workflow that signed the release: dyokto/mcp-opa-authz for releases after
# v0.7.0, kanywst/mcp-opa-authz (the repository's earlier name) up to v0.7.0.
SIGNER=dyokto/mcp-opa-authz
cosign verify-blob \
--bundle "mcp-opa-authz-${TAG#v}-checksums.txt.sigstore.json" \
--certificate-identity "https://github.com/${SIGNER}/.github/workflows/release.yml@refs/tags/${TAG}" \
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
"mcp-opa-authz-${TAG#v}-checksums.txt"Then check the archive you downloaded against that file:
sha256sum -c "mcp-opa-authz-${TAG#v}-checksums.txt" --ignore-missingContributing
Issues and pull requests are welcome — see CONTRIBUTING.md. Good first contributions: another example policy, a PDP this has not been tried against, or a gap against the AuthZEN text.
This repo is the merge of the former 0-draft/mcp-opa and 0-draft/mcp-authzen. Both histories are preserved here.
License
Apache-2.0. See LICENSE and NOTICE. Releases up to v0.7.0 were published under MIT.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
The Stytch MCP server is a reference implementation that demonstrates remote MCP server authentication and authorization using Stytch Connected Apps. It provides OAuth 2.1-compliant authorization (including PKCE), Dynamic Client Registration, and validates Stytch-issued access tokens to enable AI agents to securely interact with external services through permissioned access, supporting scopes like openid, email, profile, and manage:project_data.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP Server for AI agent identity and authorization. Create, verify, and manage agent identities with trust scores and scoped authorization tokens.77 PyPIMIT
- AlicenseAqualityDmaintenanceMCP server for enterprise authentication and authorization — JWT validation, OIDC token inspection, OAuth 2.0 introspection, and role-based access control for AI agents.8MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to discover and execute tools via a secure MCP server with JWT authentication, RBAC, rate limiting, and audit logging.1MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enforces runtime governance on AI agent actions — file access, command execution, delegation chains, and permission escalation.MIT