Expand description
MCP JSON-RPC 2.0 ↔ ATD translation.
SP-streamable-http §4.2: ATD-native Request::Hello / Request::ToolList
/ Request::RunTool (atd-protocol::messages.rs:34-52) does not
appear on the HTTP wire. Instead the listener translates the four MCP
methods (initialize, notifications/initialized, tools/list,
tools/call) into ATD operations, then dispatches via
atd_runtime::dispatch::run_tool for tool calls. Bytes returned from
Tool::call are byte-identical to the UDS path — the parity test in
tests/e2e_parity.rs is the regression guard.
Structs§
- Json
RpcError - Json
RpcRequest - Incoming JSON-RPC envelope (MCP
POST /mcpbody).jsonrpcis retained for downstream introspection but the listener does not branch on it — MCP rev2025-06-18pins it to"2.0". - Json
RpcResponse - Outgoing JSON-RPC envelope.
resultanderrorare mutually exclusive — exactly one isSomeper MCP2025-06-18.
Functions§
- error_
response - Convenience builder for a JSON-RPC error response paired with an HTTP status. SP-streamable-http §5.6 codifies the (status, code) pairs: origin → 403/-32001; missing bearer → 401/-32002; unknown method → 200/-32601; capability denied / broker error / internal → 200/-32603.
- error_
response_ with_ headers error_responsewith optional response headers (e.g.WWW-Authenticate,Retry-After). SP-token-broker-phase2 §4.4 requires distinct headers for each bearer-auth error class so adopter-side UIs can distinguish “expired” / “revoked” / “unknown” without re-parsing the message body.- handle_
initialize - Build the
initializereply. EchoesserverInfo(name + version), an emptycapabilities.toolsmap, and — when aTokenBrokeris wired — the broker’saccepted_token_formats()as anexperimentalhint (SP-token-broker-phase2 §8.2 last entry). - handle_
initialized_ notification notifications/initializedis one-way per MCP; we return an empty JSON-RPC result so the client’s request future resolves cleanly.- handle_
tools_ call tools/call— the load-bearing path.- handle_
tools_ list tools/list— wrapsRegistry::summariesfiltered by visibility into the MCP{ tools: [...] }shape. Each entry exposes{name, description, inputSchema, ...atd_fields...}so MCP clients see the standard fields and ATD-aware clients still see the full definition. Mirrorscelia-cli/src/http_server.rs:437-455with the ATDToolSummarypayload preserved.- ok_
response - JSON-RPC success envelope.
- wrap_
tool_ response - Translate an ATD
Response(fromrun_tool) into the MCP wire shape the HTTP listener returns. Mirrorscelia-cli/src/http_server.rs:497-525for the success / execution_failed branches; non-resultResponsevariants (capability denied, broker error, internal) map to the JSON-RPCerrorenvelope per SP-streamable-http §5.6.