MCP
The MCP (Model Context Protocol) adapter intercepts tool calls on an MCP server, records each invocation through an Arclasp chain, and only forwards the call to the underlying handler when the policy engine allows it. If you’re building MCP servers exposing tools to Claude Desktop, Cursor, or any other MCP client, this is how you add governance without changing your tool code.Install
mcp Python SDK if not already present.
Supported MCP Python SDK versions: 1.0.x. The protocol is still evolving — pin the specific version range you’ve tested against.
Quick start
Themcp SDK (>= 1.0) no longer exposes a patchable call-handler attribute, so there’s no server-patching shortcut. Wire governance directly inside your @server.call_tool() handler by calling handle_tool_call():
handle_tool_call() goes through Arclasp’s policy engine before dispatch runs. Denied calls raise ActionDeniedError in your handler — catch it and return an MCP-compatible error to the client.
MCP integration records the governed invocation and policy decision before tool execution. Tool return values and execution exceptions are not persisted as MCP action evidence in this release.
Two usage patterns
The MCP adapter supports two integration styles depending on how much control you want over dispatching.Pattern 1: handle_tool_call() — wrap your existing dispatch
Route calls through the adapter from inside your @server.call_tool() handler, as shown above. This gives you full control over the dispatching logic while recording every call. This is the recommended approach for most cases.
ArclaspMcpAdapter.install() exists on the class but raises RuntimeError — it is not supported with mcp >= 1.0, which removed the patchable _call_tool_handler attribute the old implementation relied on. Do not call it; use handle_tool_call() inside your own handler instead.Pattern 2: @adapter.tool() decorator — per-tool wrapping
For more granular control, decorate individual tool implementations:
What gets recorded
For each tool invocation:- A
tool_callevent with the tool name asaction_nameand the arguments as the payload agent_nameis the value you passed toArclaspMcpAdapterparent_agent_nameif you supplied one (useful for tracking MCP client identity)
Policy enforcement
When a policy denies a tool call:ActionDeniedError inside your @server.call_tool() handler (as shown above) and convert it to whatever error shape your MCP transport expects — the adapter itself does not do this conversion for you.
For approval-required decisions, handle_tool_call blocks until the approver responds. The MCP client sees a delayed response (until approval times out, your client may consider the call hung — set reasonable client timeouts).
Identifying the MCP client
If your MCP server knows which client is connected, pass that identity asparent_agent_name:
Session lifetime
An Arclasp chain corresponds to an MCP session. The natural pattern:arclasp/mcp/adapter.py for the underlying primitives.
Edge cases
Callinginstall(). It exists on ArclaspMcpAdapter for backward compatibility but always raises RuntimeError — it is not supported with mcp >= 1.0. Use handle_tool_call() inside your own @server.call_tool() handler instead.
Multiple tools registered. Since dispatching happens in your own handler, every tool your handler routes through handle_tool_call() is covered — there’s no separate registration step with the adapter.
Tool with no arguments. Works fine — arguments={} is a valid payload.
Streaming tool responses. MCP tools that stream responses are tracked at the request level only. The response stream is forwarded to the client unchanged; Arclasp doesn’t intercept individual stream chunks.
Tool errors. If the underlying handler raises, the exception propagates after the governance event is recorded. The event records the governed invocation — the error itself is part of the MCP response.
Where to go next
LangGraph adapter
For LangGraph-orchestrated agent workflows.
LangChain adapter
For LangChain agent executors and chains.
Policies
What decisions get applied to your tool calls.
SDK reference
The complete
ArclaspMcpAdapter API.