Skip to main content

Module mcp

Module mcp 

Source
Expand description

MCP (Model Context Protocol) server over stdio.

Spec: https://modelcontextprotocol.io/specification/2025-06-18

Wire protocol: JSON-RPC 2.0, one message per line on stdin and stdout. stderr is reserved for logs (clients display them as server-side diagnostics).

Tools exposed:

Identity / messaging (always agent-safe)

  • wire_whoami — read self DID + fingerprint + capabilities
  • wire_peers — list pinned peers + tiers
  • wire_send — sign + queue an event to a peer
  • wire_tail — read recent signed events from inbox
  • wire_verify — verify a signed event JSON

Pairing (agent drives, but the user types the SAS digits back)

  • wire_init — idempotent identity creation; same handle = no-op, different handle = error (cannot re-key silently)
  • wire_pair_initiate — host opens a pair-slot; returns code phrase agent shows to user out-of-band
  • wire_pair_join — guest accepts a code phrase; both sides reach SAS-ready
  • wire_pair_check — poll a pending session_id (used when initiate returned before peer was on the line)
  • wire_pair_confirm — user types the 6 SAS digits back; mismatch aborts

§Why pairing is now agent-callable (T10 update)

v0.1 originally refused wire_init / wire_pair_* over MCP entirely on the theory that a fully-autonomous agent would skip the SAS confirmation. The new design preserves the human gate by requiring the user to type the 6-digit SAS back into chat — wire_pair_confirm(session_id, typed_digits) compares against the cached SAS server-side, mismatch aborts the session.

Defense-in-depth:

  1. SAS digits are returned as tool output the agent renders to the user. A malicious agent that fabricates digits in chat fails because the user’s peer reads their independently-derived SAS over a side channel (voice / unrelated text channel). Mismatch on type-back aborts.
  2. The host runtime (Claude Desktop, etc.) is responsible for surfacing the type-back step to the actual user, not auto-filling. Wire cannot enforce this — see THREAT_MODEL.md T14.

Concurrent multi-peer: each pair flow has its own session_id (the relay pair_id) and its own Mutex<PairSessionState> in the in-memory store. Pairing with N peers in parallel is fully supported.

Structs§

McpState
Shared MCP-session state. Today: subscribed resource URIs + a writer channel for unsolicited notifications (push). Future per-session cursors, etc. go here.

Functions§

run
Run the MCP server until stdin closes.