<!-- Generated by website/scripts/sync-docs.mjs from docs/quickstart.md. Edit that file, not this one. -->

# Quick start

> Every page of this site: https://dyokto.github.io/mcp-opa-authz/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/](https://dyokto.github.io/mcp-opa-authz/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`.

## Install



**Homebrew**

macOS and Linux.

```sh
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`.

```sh
go install github.com/dyokto/mcp-opa-authz@latest
```

**Linux and macOS binary**

Pick the archive for your platform from the [releases page](https://github.com/dyokto/mcp-opa-authz/releases): `darwin-arm64`, `darwin-amd64`, `linux-amd64` or `linux-arm64`.

```sh
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](https://registry.modelcontextprotocol.io/) lists as `io.github.dyokto/mcp-opa-authz`.

```sh
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`).

```console
$ mcp-opa-authz --version
mcp-opa-authz 0.8.0
```

## Connect an MCP client

`evaluate_policy` and `coaz_map` without `evaluate` work with no configuration. The other tools need `AUTHZEN_PDP_URL`; [Configuration](https://dyokto.github.io/mcp-opa-authz/configuration/) lists every variable.



**Claude Code**

```sh
claude mcp add opa-authz -- mcp-opa-authz
```

With a PDP:

```sh
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.

```json
{
  "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.

```json
{
  "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.

```json
{
  "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" }
    }
  }
}
```



## Get the example policy

The policies below are in [examples/](https://dyokto.github.io/mcp-opa-authz/examples/). [`rbac.rego`](https://github.com/dyokto/mcp-opa-authz/blob/main/examples/rbac.rego) gives alice the `editor` role and bob only `viewer`, and only `editor` may `delete`.

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

## A request the policy denies

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.

```console
$ { 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.

## The same request, fixed policy

Give bob the `editor` role:

```diff
 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:

```console
$ { 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
}
```

## Undefined is not a deny

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

```console
$ { 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.

## Verify a release

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.

```console
$ 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.

## Next

- [Tools](https://dyokto.github.io/mcp-opa-authz/tools/): every tool's parameters and results, including the AuthZEN tools that ask a PDP
- [Running it](https://dyokto.github.io/mcp-opa-authz/running/): the container, other MCP clients, and PDPs it works with
- [Sandbox and PDP client](https://dyokto.github.io/mcp-opa-authz/sandbox/): what the Rego sandbox removes and how the PDP client is constrained
- [Examples](https://dyokto.github.io/mcp-opa-authz/examples/): the other example policies and how to call them
