Add governance to Claude Code (Anthropic's CLI coding agent) so that every tool call is validated against your policy and logged to a tamper-evident evidence ledger.
Claude Code
|
| MCP tool call (e.g. read_text_file)
v
+----------------------------------+
| Deterministic Agent Control Protocol MCP Proxy |
| |
| 1. Receives MCP tool call |
| 2. Evaluates against policy |
| 3. ALLOW -> forwards to backend |
| DENY -> returns error |
| 4. Records to evidence ledger |
+----------------------------------+
|
| (forwarded only if allowed)
v
+----------------------------------+
| Backend MCP Server |
| (e.g. filesystem, database) |
| |
| Executes the actual operation |
+----------------------------------+
Claude Code has native MCP client support via .mcp.json (project scope) or ~/.claude.json (user scope). The governed proxy registers as an MCP server, and all tool calls from the MCP server are validated against your policy.
Claude Code provides the strongest built-in governance among the supported agents thanks to three layers:
-
MCP proxy (soft) -- The proxy validates all MCP tool calls against the policy, enforces session budgets and rate limits, and logs everything to the evidence ledger.
-
CLAUDE.md (soft) -- A
CLAUDE.mdfile instructs Claude Code to prefer governed MCP tools over its built-in tools. This is equivalent to Cursor's governance rule. -
settings.json permissions (semi-hard) -- Claude Code's built-in permission system can deny specific built-in tools, making it harder to bypass governance. For example, you can deny
Read,Write, andEdittools so Claude Code is forced to use the governed MCP alternatives.
The settings.json permission layer makes this integration stronger than Cursor's pure soft governance, since Claude Code will refuse to use denied tools even if instructed to.
cd deterministic-agent-control-protocol
npm install
npm run buildFrom your target project directory, run:
npx det-acp init claude-codeThis generates all required files with sensible defaults:
| File | Purpose |
|---|---|
policy.yaml |
Governance policy (edit to customize) |
.mcp.json |
Registers the governed MCP proxy in Claude Code |
CLAUDE.md |
Instructs the agent to use governed tools |
.claude/settings.json |
Denies built-in file tools (semi-hard enforcement) |
To use your own policy instead of the default:
npx det-acp init claude-code --policy ./my-policy.yamlAfter running init, restart Claude Code to pick up the MCP server. That's it.
Note: The generated
.claude/settings.jsondenies built-inRead,Write, andEdittools, forcing Claude Code to use the governed MCP alternatives. If this causes issues, you can safely delete.claude/settings.json-- the soft governance viaCLAUDE.mdwill still work.
Click to expand manual setup instructions
# From the deterministic-agent-control-protocol root:
cp integrations/claude-code/policy.yaml ./claude-code.policy.yamlClaude Code uses .mcp.json at the project root for project-scoped MCP servers. Copy the template:
cp integrations/claude-code/mcp.json ./.mcp.jsonEdit .mcp.json and replace the absolute paths:
{
"mcpServers": {
"governed-filesystem": {
"command": "node",
"args": [
"/absolute/path/to/deterministic-agent-control-protocol/dist/cli/index.js",
"proxy",
"/absolute/path/to/claude-code.policy.yaml"
]
}
}
}Note: Claude Code's
.mcp.jsonformat usescommandandargsfor stdio servers, similar to Cursor. The file can be committed to git for team-wide governance.
Copy the CLAUDE.md file into your project root:
cp integrations/claude-code/CLAUDE.md ./CLAUDE.mdThis file instructs Claude Code to:
- Prefer
governed-filesystemMCP tools over built-inRead,Write,Edittools - Respect policy denials and not fall back to direct tool use
- Report denials to the user
Claude Code automatically loads CLAUDE.md from the project root at session start.
For stronger governance, copy the settings template that denies direct file access:
mkdir -p .claude
cp integrations/claude-code/settings.json .claude/settings.jsonThis settings file:
- Denies built-in
Read,Write, andEdittools for all paths - Allows the
governed-filesystemMCP tools - Allows Bash commands (since the proxy does not govern shell access -- use the Shell Proxy separately if needed)
With these permissions, Claude Code physically cannot use its built-in file tools, even if it wanted to -- providing semi-hard governance.
Warning: Denying built-in tools may impact Claude Code's ability to perform some operations if the governed MCP server does not expose equivalent functionality. Test thoroughly.
cp -r integrations/claude-code/test-sandbox ./test-sandbox# Start Claude Code in the project directory
claude
# Try these prompts:Test 1 -- Allowed read (should succeed):
Read the file test-sandbox/hello.txt
Claude Code should use the governed MCP read_text_file tool and return the file contents.
Test 2 -- Forbidden path (should be denied):
Read the file test-sandbox/.env
The proxy should deny this with: Action denied by policy: Path "..." matches forbidden pattern "**/.env"
Test 3 -- Unconfigured tool (should be denied):
Create a directory called test-sandbox/new-folder
The proxy should deny this: No capability defined for tool "create_directory"
Test 4 -- Built-in tool denied (if settings.json is installed):
Use the built-in Read tool to read test-sandbox/hello.txt
If settings.json denies the Read tool, Claude Code will refuse to use it and should fall back to the governed MCP tool (or report that the built-in tool is denied).
| Action | Tool | Expected |
|---|---|---|
| Read a normal file | read_text_file (MCP) |
ALLOWED |
| Write a normal file | write_file (MCP) |
ALLOWED |
| List a directory | list_directory (MCP) |
ALLOWED |
Read .env |
read_text_file (MCP) |
DENIED (forbidden pattern) |
| Create a directory | create_directory (MCP) |
DENIED (not in capabilities) |
| Built-in Read | Read (built-in) |
DENIED (settings.json) |
ls .det-acp/ledgers/
npx det-acp report .det-acp/ledgers/<session-file>.jsonl| File | Purpose |
|---|---|
policy.yaml |
Policy allowing filesystem MCP tools, blocking sensitive files |
mcp.json |
Template for .mcp.json to register the governed proxy in Claude Code |
CLAUDE.md |
Instructions for Claude Code to prefer governed MCP tools |
settings.json |
Template for .claude/settings.json that denies built-in file tools |
test-sandbox/hello.txt |
Test file for allowed reads |
test-sandbox/.env |
Test file for forbidden path denials |