mcpguard-sdk wraps any tool handler with a deterministic policy check before it runs. CEL-based rules. Observe-first ramp. Framework-agnostic — OpenAI, Anthropic, LangChain, MCP, your own loop.
import { MCPGuard } from'mcpguard-sdk'const guard = newMCPGuard({ apiKey: process.env.MCPGUARD_API_KEY! })
// Drop-in gate. Throws MCPGuardDeniedError on policy deny.await guard.enforce({
action_id: 'billing.refund',
params: { invoice_id, amount_cents },
user_context: { user_id, plan },
})
// → allow: continue. → review: human in the loop.// → deny: thrown, the tool call is skipped.await stripe.refunds.create({ charge, amount: amount_cents })
packages/sdk/src/index.ts — real signature, not pseudocode.
The three-line install
Wrap your tool handlers. Keep your loop.
One MCPGuard instance, one adapter import, one handler-map transform. Your dispatch code doesn't change — every tool call now flows through policy before it runs.
Works with LangChain, LangGraph, OpenAI Assistants, Anthropic tool use, MCP servers, Vercel AI SDK — anything that hands you a tool name and a params object. The SDK has no framework dependency; the adapters are structural duck-types.
Local MCP tools
Try it in Cursor. No signup. No network.
The free-tier MCP server ships four tools that run fully local — no API key, no telemetry, no round-trip. Drop the snippet into your MCP client and your editor can author, validate, and test policy without leaving the buffer.
Action / policy / review schema documentation, bundled. No round-trip to a docs site.
cursor — agent chatprompt
> validate ./policy.yaml and tell me which rules would block billing.refund > $500mcp-guard → calling mcpguard.policy_validate ✓ policy parses (3 rules) → calling mcpguard.cel_test matched_rule: refund.large_amount → review
Observe → enforce
Roll out without breaking prod.
The SDK ships with two policy modes and a clean transition between them. Same code, same call site — the only thing that changes is whether enforce() throws.
Day 1mode: observe
Drop in. Nothing breaks.
Install the SDK in observe mode. Every tool call is logged with the decision the policy would have made — allow, deny, review — but the call still runs.
→
Week 1mode: review
Watch what would have blocked.
The dashboard shows "if enforcing now, X% of refund.create calls would route to review." You tune rules against real traffic, not synthetic test cases.
→
When you’re readymode: enforce
Flip per-action.
Move `billing.refund` to enforce. Leave `db.query` in observe another week. Mode is per-action and per-environment — no big-bang rollout.
The SDK is free up to 10,000 evaluations / month on self-hosted or via the hosted free tier. Team plan is when you bring on the first reviewer — the dashboard, the review queue, the Slack approval bot.
Free
$0forever
For the dev evaluating, prototyping, or shipping a side project.