Connect Claude Code (MCP)
AgentOps exposes its guard as an MCP server. Point Claude Code — or any MCP-capable agent framework — at it, and the agent calls AgentOps tools on its own. Every spend decision is enforced against your policy in real time and anchored on-chain.
Before you start
- A funded Casper float and an org guard policy.
- An active agent with a policy configured, and its agent key (
ag_...). - Node.js installed, so
npxis available.
NOTE
Connect Claude Code screen generates this configuration for your actual agents, with the correct endpoint filled in. Copy it from there rather than typing the URL by hand.Add the MCP server
AgentOps speaks MCP over HTTP at /v1/casper-guard/mcp. Clients that expect a local stdio server reach it through mcp-remote, which bridges the two and attaches your agent key as a bearer token.
{
"mcpServers": {
"agentops-<your-agent-id>": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://<your-agentops-host>/v1/casper-guard/mcp",
"--header",
"Authorization: Bearer ag_live_..."
]
}
}
}One server entry per agent. If you run three agents with three different policies, add three entries — each carrying its own key. That is what keeps their limits separate.
The tools your agent gets
casper_guard_policy_check— ask whether an action would be allowed, without committing to it.casper_guard_authorize_payment— authorize an x402 payment; returns the payment header on ALLOW.casper_guard_authorize_action— authorize a non-payment action such as a swap or a deploy.casper_guard_decision_status— look up a decision by id.casper_guard_audit_export— pull the audit record.
Telling the agent how to use them
Give the agent a short standing instruction: never pay a 402 directly; always call casper_guard_authorize_payment first, and if the outcome is DENY, stop and report the reason. Models follow a rule like that reliably — and if one ever doesn’t, it still has no signing key, so the policy holds anyway.
Verify the connection
- Restart your MCP client and confirm the AgentOps tools appear in its tool list.
- Ask the agent to run a
casper_guard_policy_checkon a small payment. - Open
Decision Streamin the console — the call should appear within seconds. - Ask for an amount above the per-action max and confirm you get a DENY with a readable reason.
Troubleshooting
- Tools do not appear — the client did not start the server. Check the JSON is valid and restart the client fully.
- 401 / auth errors — the header must be exactly
Authorization: Bearer ag_..., and the key must belong to an active agent. - Every call denies — the agent has no policy or no budget. Fix that in the console first.
- Nothing in the decision stream — you are pointed at a different host or network than the console is showing.
Prefer typed function calls in your own backend? Use the SDK instead — it reaches the same guard. The SDK also ships an MCP client if you want to drive these tools from your own code.
