Available on crate feature
mcp only.Expand description
MCP (Model Context Protocol) server surface for faucet (issue #420).
A transport-agnostic JSON-RPC 2.0 dispatcher (handle_message) plus the
tool implementations (tools). Two front-ends drive it:
- stdio — the
faucet mcpsubcommand (crate::commands::mcp), for local agents (Claude Desktop / Code). - Streamable HTTP — the
/mcproute mounted byfaucet serve --mcp, which inherits serve’s bearer-auth + RBAC + audit.
The dispatcher re-exposes existing faucet capabilities (list / schema /
scaffold / validate / preview, and a gated run_pipeline) in the shape an
LLM agent speaks; it re-implements no pipeline logic. Read-only tools are
always available; the mutating run_pipeline tool appears only when the
context is constructed with allow_mutations = true (the --allow-mutations
flag, ANDed with the caller’s RBAC scope on the HTTP transport).
Modules§
- protocol
- JSON-RPC 2.0 + MCP protocol types (issue #420).
- tools
- MCP tool definitions + in-process dispatch (issue #420).
Structs§
- McpContext
- Everything a tool handler needs, independent of transport.
Functions§
- handle_
message - Handle one JSON-RPC message. Returns
Some(response_json)for a request, orNonefor a notification (which gets no response). A malformed message yields a JSON-RPC parse/invalid-request error envelope. - install_
stderr_ tracing - Install a tracing subscriber that writes to stderr — stdout is reserved
for the JSON-RPC message stream in
faucet mcp(stdio) mode. - serve_
stdio - Drive an MCP session over any byte streams: read newline-delimited JSON-RPC
from
reader, write each response (one JSON object per line) towriter. Blank lines are skipped; notifications produce no output. Returns when the reader hits EOF. Thefaucet mcpstdio command wraps stdin/stdout with this; tests drive it with in-memory buffers.