JamJet Policy is a portable policy layer for AI agent actions, and its packages/mcp-shim subpackage provides @jamjet/mcp-shim, which runs as an MCP stdio interceptor. It sits between any MCP client (such as Claude Desktop, Cursor, the OpenAI Agents SDK's MCP client, or a custom client) and any MCP server, governing each tools/call according to the same policy file.
Main capabilities:
- Policy interception: Before a request reaches the real MCP server, it matches policy rules by tool name to block or require approval. For example, a call matching delete directly returns a JSON-RPC policy error, and the server never receives the request.
- Approval workflow: High-risk tools can be manually approved via jamjet approve <run-id> (the approval workflow is provided with @jamjet/cli v0.2).
- Audit logging: Writes in JSONL format to ~/.jamjet/audit/<YYYY-MM-DD>/mcp-shim.jsonl.
- Tool definition pinning: Computes a canonical hash over the tool's name, title, description, inputSchema, outputSchema, and annotations and compares it with the pin, preventing the server from changing definitions after pinning (rug pull). Supports three modes: tofu (default, pin on first sight), allowlist (only provide already-pinned tools), and off. The pin file is located at ~/.jamjet/mcp-tool-pins.json, distinguished by --server name.
- Invisible character detection: Scans tool definitions for zero-width characters, bidirectional control characters, Unicode TAG blocks, variation selectors, and control characters; blocks by default, and can be changed to warn and forward via mcp.invisible_unicode: warn.
- Protocol version governance: Only governs known MCP protocol versions; unknown versions return UnsupportedProtocolVersionError (-32022) by default, and can be changed via mcp.protocol.unknown_versions: pass Forward and output warnings. The 2026-07-28 version also has additional behaviors, such as rejecting server-initiated requests and validating the consistency of Mcp-Method / Mcp-Name with the request body for HTTP transport.
- Message security validation: rejects JSON-RPC batch requests, tools/call with a non-string name, missing or abnormally typed id, duplicate keys differing only in case, messages nested more than 256 levels deep, etc., to prevent ungoverned forwarding.
- Standalone policy server: using --serve-self runs the policy primitives as a standalone MCP server without a downstream server, providing three read-only policy tools for agents to query policies.
Usage: Configure this shim as a stdio-launched MCP server in claude_desktop_config.json (or ~/.config/claude-code/...); it also applies to Cursor, OpenAI Agents SDK, etc. After restarting Claude Desktop, tools/call matching delete will receive a JSON-RPC policy error. If --policy is omitted and no policy.yaml is found (in the current directory, ~/.jamjet/, or the JAMJET_POLICY_FILE environment variable), the built-in demo policy is used (delete blocked, drop blocked, destructive / payments.* require approval), a warning is output to stderr, and policy_load_info reports policy_source: "demo".
The same policy.yaml can also be used by the Claude Code PreToolUse hook (@jamjet/claude-code-hook), the OpenAI Agents SDK guardrail (@jamjet/openai-guardrail, coming soon), the JamJet Python SDK (jamjet on PyPI), and the JamJet TS SDK (@jamjet/cloud on npm).
Use cases: AI agent deployments that require unified policy control, auditing, and approval for MCP tool calls.
Limitations: pinning only covers the tool's declared definition, not the code running behind it; unknown protocol versions are not silently forwarded by default; some features (such as approval workflows) depend on later versions.