Skip to content

Quick start

Markdown · llms.txt

Install mcp-opa-authz, connect it to an MCP client, then drive it by hand over stdio with no model in the loop: ask evaluate_policy whether bob may delete a document under the RBAC policy in examples/, get a deny, change the policy, and get an allow. The policy runs in-process, so this needs no PDP and no network. The stdio commands need jq.

Homebrew

macOS and Linux.

Terminal window
brew install kanywst/tap/mcp-opa-authz

Go

Needs Go 1.26.6 or later (the go line in go.mod). Installs to $(go env GOPATH)/bin.

Terminal window
go install github.com/dyokto/mcp-opa-authz@latest

Linux and macOS binary

Pick the archive for your platform from the releases page: darwin-arm64, darwin-amd64, linux-amd64 or linux-arm64.

Terminal window
gh release download -R dyokto/mcp-opa-authz -p 'mcp-opa-authz-*-linux-amd64.tar.gz'
tar xzf mcp-opa-authz-*-linux-amd64.tar.gz mcp-opa-authz
sudo install mcp-opa-authz /usr/local/bin/

Container

linux/amd64 and linux/arm64, on ghcr.io. This is also the package the MCP registry lists as io.github.dyokto/mcp-opa-authz.

Terminal window
docker pull ghcr.io/dyokto/mcp-opa-authz:0.8.0@sha256:88e0bfd39bc27b28dae795ae541a598dac557b3cd1a14d8559642551a4010a9d

Check it is on your PATH. A release binary, the Homebrew formula and the image print the release version; a go install build prints the module version (v0.8.0).

Terminal window
$ mcp-opa-authz --version
mcp-opa-authz 0.8.0

evaluate_policy and coaz_map without evaluate work with no configuration. The other tools need AUTHZEN_PDP_URL; Configuration lists every variable.

Claude Code

Terminal window
claude mcp add opa-authz -- mcp-opa-authz

With a PDP:

Terminal window
claude mcp add opa-authz \
--env AUTHZEN_PDP_URL=http://localhost:8181/access/v1/evaluation \
-- mcp-opa-authz

Claude Desktop

Add the server to ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop. If it cannot find the command, give the absolute path that command -v mcp-opa-authz prints.

{
"mcpServers": {
"opa-authz": {
"command": "mcp-opa-authz",
"env": { "AUTHZEN_PDP_URL": "http://localhost:8181/access/v1/evaluation" }
}
}
}

Leave out env if you have no PDP.

Cursor

Add the same block to ~/.cursor/mcp.json, or to .cursor/mcp.json in a project to scope it there.

{
"mcpServers": {
"opa-authz": {
"command": "mcp-opa-authz",
"env": { "AUTHZEN_PDP_URL": "http://localhost:8181/access/v1/evaluation" }
}
}
}

Container

Any client that takes a command and arguments. -i keeps stdin open, which the stdio transport needs.

{
"mcpServers": {
"opa-authz": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "AUTHZEN_PDP_URL",
"ghcr.io/dyokto/mcp-opa-authz:0.8.0@sha256:88e0bfd39bc27b28dae795ae541a598dac557b3cd1a14d8559642551a4010a9d"
],
"env": { "AUTHZEN_PDP_URL": "https://pdp.example.com/access/v1/evaluation" }
}
}
}

The policies below are in examples/. rbac.rego gives alice the editor role and bob only viewer, and only editor may delete.

Terminal window
git clone --depth 1 https://github.com/dyokto/mcp-opa-authz
cd mcp-opa-authz

MCP is JSON-RPC over stdin and stdout, so the tools can be called without a client. The server needs the initialize handshake before any tools/call, and it cancels calls still running when stdin closes, so the sleep keeps stdin open until the answer is back. The last jq keeps the two members that carry the decision.

Terminal window
$ { printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"cli","version":"0"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
"$(jq -nc --rawfile rego examples/rbac.rego \
--arg input '{"user":"bob","action":"delete","resource":"doc-1"}' \
'{jsonrpc:"2.0",id:2,method:"tools/call",params:{name:"evaluate_policy",arguments:{rego:$rego,query:"data.rbac.allow",input_json:$input}}}')"; \
sleep 2; } \
| mcp-opa-authz | jq 'select(.id==2) | .result.structuredContent | {defined, value}'
{
"defined": true,
"value": false
}

"defined": true, "value": false is a deny: a rule answered, and it said no. bob's only role is viewer, which has read and nothing else, so the default allow := false answered.

Give bob the editor role:

roles := {
"alice": {"editor"},
"bob": {"viewer"},
"bob": {"viewer", "editor"},
"carol": {"viewer", "auditor"},
}

The command below makes that edit with sed on the way in, so the file in the repository stays as it is:

Terminal window
$ { printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"cli","version":"0"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
"$(jq -nc --rawfile rego <(sed 's/"bob": {"viewer"}/"bob": {"viewer", "editor"}/' examples/rbac.rego) \
--arg input '{"user":"bob","action":"delete","resource":"doc-1"}' \
'{jsonrpc:"2.0",id:2,method:"tools/call",params:{name:"evaluate_policy",arguments:{rego:$rego,query:"data.rbac.allow",input_json:$input}}}')"; \
sleep 2; } \
| mcp-opa-authz | jq 'select(.id==2) | .result.structuredContent | {defined, value}'
{
"defined": true,
"value": true
}

Ask for a rule the policy does not have, here data.authz.allow instead of data.rbac.allow:

Terminal window
$ { printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"cli","version":"0"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
"$(jq -nc --rawfile rego examples/rbac.rego \
--arg input '{"user":"bob","action":"delete","resource":"doc-1"}' \
'{jsonrpc:"2.0",id:2,method:"tools/call",params:{name:"evaluate_policy",arguments:{rego:$rego,query:"data.authz.allow",input_json:$input}}}')"; \
sleep 2; } \
| mcp-opa-authz | jq 'select(.id==2) | .result.structuredContent | {defined, value}'
{
"defined": false,
"value": null
}

opa eval returns an empty result here, which reads like a deny. "defined": false says the policy has no answer for this query, which is a different bug from a deny.

In a client, the model sends the same tools/call: ask it "evaluate examples/rbac.rego for bob deleting doc-1, and why", and it picks the query, builds the input, and can pass trace: true to see which rule body failed.

Each release has a checksum file signed keylessly with cosign (one Sigstore bundle holds the signature and certificate) and a CycloneDX SBOM per archive. The container image is not signed.

Terminal window
$ gh release download v0.8.0 -R dyokto/mcp-opa-authz -p '*-checksums.txt*' -p '*-linux-amd64.tar.gz'
$ cosign verify-blob \
--bundle mcp-opa-authz-0.8.0-checksums.txt.sigstore.json \
--certificate-identity https://github.com/dyokto/mcp-opa-authz/.github/workflows/release.yml@refs/tags/v0.8.0 \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
mcp-opa-authz-0.8.0-checksums.txt
Verified OK
$ sha256sum --ignore-missing -c mcp-opa-authz-0.8.0-checksums.txt
mcp-opa-authz-0.8.0-linux-amd64.tar.gz: OK

Releases up to v0.7.0 were signed from kanywst/mcp-opa-authz, the repository's earlier name; use that in --certificate-identity for them.

  • Tools: every tool's parameters and results, including the AuthZEN tools that ask a PDP
  • Running it: the container, other MCP clients, and PDPs it works with
  • Sandbox and PDP client: what the Rego sandbox removes and how the PDP client is constrained
  • Examples: the other example policies and how to call them