1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! MCP dispatch as a JSON-RPC method on the daemon socket (#6288 step 2a).
//!
//! Why: `tm serve --stdio` and `tm sessions disk` reach the daemon's MCP tool
//! surface through `POST /rpc`, and nothing else serves it. Step 2c removes the
//! TCP bind, so the socket needs this method before either client moves; the
//! 2c install risk depends on it.
//!
//! What: `mpm.mcp.dispatch` takes the whole MCP JSON-RPC envelope `/rpc` takes
//! (`{jsonrpc, id, method, params}`) as its params, and answers with the whole
//! MCP response envelope `/rpc` returns, as its result. Both transports call
//! [`dispatch_op`](crate::daemon::rpc::mcp::dispatch_op), so the two cannot drift. A notification answers the same
//! `{"jsonrpc":"2.0"}` body HTTP returns for a suppressed response.
//!
//! Auth: HTTP gates `/rpc` on a loopback peer address. The socket admits only
//! a peer whose uid is this process's, checked by `serve_until` before a byte
//! is read — a strict subset of loopback callers (see
//! `rpc::managed::control::CallerTrust`). A params object that is not an MCP
//! envelope is refused with `CODE_INVALID_PARAMS` and no tool runs, as HTTP
//! refuses an undecodable body before the handler.
//!
//! Test: `mcp_tests.rs`.
use Arc;
use ;
use ;
use crateStateBackend;
use crateDaemonState;
/// The one method this module registers.
pub const METHOD: &str = "mpm.mcp.dispatch";
/// Route one MCP request through the daemon's tool surface.
///
/// Why: the one body `POST /rpc` and [`METHOD`] share.
/// What: wraps `state` in a [`StateBackend`] and calls [`crate::mcp::dispatch`].
/// Test: `parity_mcp_dispatch_agrees_across_transports`.
pub async
/// Mount [`METHOD`] on `router`.
///
/// Test: `mcp_dispatch_is_registered_on_the_daemon_socket`.