Connect OpenCode to Open Policy Agent
Set up in minutes
Choose where it runs
On your computer through your own OpenCode, or hosted in the cloud. The rest of setup adapts to your choice:
Pick what it can do in Open Policy Agent
A preset of real Open Policy Agent operations. Each one becomes a tool the agent can call, and it can't touch anything outside the list.
Connect Open Policy Agent
One sign-in. The agent acts through your account, scoped to the operations you picked.
Add your personal MCP link
The last step mints a private MCP URL for this agent and walks you through exactly this, with your real link filled in. The page flips to Connected the moment your OpenCode first calls in. opencode mcp add only saves the config. OpenCode connects when it starts — run opencode, or restart a running one.
1. Run this in your terminal
2. Choose Remote and paste your server URL
3. Choose No when asked about OAuth authentication — the link itself is the key
<your-link> is your personal server URL — setup mints it for you.
Tools OpenCode gets
Open Policy Agent
16 toolsList all loaded policy modules (also the connection proof).
Read a policy module and its AST.
Create or replace a Rego policy module.
Delete a loaded policy module.
Read a base or virtual document without input.
Evaluate a decision with input wrapped in the v1 input envelope.
Evaluate the v0 decision endpoint with an unwrapped input document.
Create or replace base data at a document path.
Apply an atomic JSON Patch to base data.
Delete base data at a document path.
Evaluate the instance's default decision using a raw input object.
Execute an ad hoc Rego query using GET.
Execute a complex ad hoc Rego query using POST.
Partially evaluate a query with specified unknowns.
Read OPA health, optionally checking bundles and plugins.
Read the active instance configuration (OPA masks private keys).
About OpenCode
Frequently asked questions
More ways to connect
More tools for OpenCode
Use Open Policy Agent with other agents
Open your OpenCode agent in one click.
NoClick runs OpenCode for you with Open Policy Agent wired in as tools. Connect your account and run.