Skip to main content

Module mcp

Module mcp 

Source
Expand description

safe-chains mcp: the CLI’s checks and config changes as MCP tools, for an agent that calls tools rather than running commands. Hand-rolled newline-delimited JSON-RPC 2.0 over stdio, one request at a time.

Every tool runs the safe-chains binary itself (Runner). That keeps the two surfaces equal by construction, and it is also necessary: the classifier loads the user’s rules once per process, so a long-lived server answering in-process would go on using rules it had just changed.

The editing tools never approve themselves. They are annotated destructive, so a client that reads annotations asks before each call, and the server refuses them outright when it can see that the client is set to run them without asking (client_approval).

Modules§

client_approval
Whether the client running this server approves its editing tools without asking anyone.

Structs§

Spawn
The real runner: this executable, with SAFE_CHAINS_SURFACE=mcp so its messages name tools.

Constants§

INSTRUCTIONS
What the client is told about the server, once, at initialize. Under 2,000 characters, with what it is and where to start in the first 500 (tests/mcp_rules.rs holds both).
PROTOCOL_VERSION
The newest protocol revision this server has been checked against. A client that asks for another gets its own echoed back, as the house servers do.

Traits§

Runner
How a tool reaches the safe-chains binary. Tests and the fuzz target substitute a stand-in.

Functions§

handle_line
One message in, at most one reply out. A notification (no id) gets none.
manifest
tests/mcp_tools.toml: each tool and what it can do, for review and the allowlist check.
serve
Serve until stdin closes.