Expand description
MCP method dispatch: decode an incoming JSON-RPC frame, route it to its handler, and produce the outgoing frame(s).
Pure + panic-free: every path returns a value; malformed input yields a
JSON-RPC parse-error response. This is the unit the connection loop
(server::serve_connection) drives; keeping it pure makes the protocol
contract testable without a socket.
I1 handles initialize / tools/list / prompts/list and emits
notifications/tools/list_changed after the client’s initialized
notification. tools/call is stubbed (reads I2, writes I3, diff I4).
Structs§
- Dispatch
Context - The state the dispatcher needs to answer
tools/call: the read tools’ReadContext+ the write bus. Built once at server spawn and shared (behind anArc) across connections. The I1 methods (initialize/tools/list/prompts/list) ignore it.
Enums§
- Outgoing
- A frame the server should send back to the agent in response to an incoming frame.
Functions§
- dispatch_
frame - Decode + route one incoming frame, returning the frames to send back.
- handle_
request - Route one request to its MCP response.
- is_
blocking_ tool_ call - True if
frameis atools/callrequest for the blockingopenDifftool — the only tool whose handler (crate::mcp::diff::open_diff) awaits an unbounded, user-paced verdict with no timeout. The connection dispatches these on their OWN task so the per-connection read loop is never blocked by a pending review: it keeps polling the socket + shutdown signal (so a dropped connection or:claude-code-stopis observed promptly and the pending review can be rejected), and other tool calls still flow. Every non-blocking tool stays inline + ordered. Malformed / non-matching frames returnfalse(dispatched inline, where the parse error is reported).