Skip to main content

Module mcp

Module mcp 

Source
Expand description

mcp — lattice as the IDE side of the Claude Code agent protocol.

The MCP adapter half of lattice-ai (AG‑4): an external claude CLI connects over a loopback WebSocket and drives the editor (reading selection / open buffers / diagnostics, opening files, proposing edits as interactive diffs). This is the lattice analog of claude-code-ide.el and the VS Code / JetBrains integrations — it speaks the same WebSocket + MCP contract. Gated behind feature = "mcp".

Architecturally this is a network peer, like lattice-lsp (an LSP client): a loopback JSON-RPC connection to an external process. It runs no agent in-process and adds no scripting surface, so it does not touch the “WASM is the only extension substrate” rule. It shares the protocol-neutral editor-capability port (lattice-agent) with the ACP adapter in super::acp.

See docs/dev/architecture/ide-protocol.md (design) + docs/dev/architecture/agent-integration.md (the AG‑4 fold).

Re-exports§

pub use commands::register_claude_code_ex_commands;
pub use error::ClaudeCodeError;
pub use error::Result;
pub use install::install;
pub use modes::ClaudeCodeMode;
pub use modes::register_claude_code_modes;
pub use server::ClaudeCodeServerHandle;
pub use server::ServerConfig;
pub use server::ServerState;
pub use server::spawn;

Modules§

auth
Connection authorization: the per-session token + a constant-time header check.
commands
Ex-commands owned by the Claude Code IDE peer.
diff
IDE-protocol I4: the openDiff tool — open an interactive diff and BLOCK until the user Keeps or Rejects it.
dispatch
MCP method dispatch: decode an incoming JSON-RPC frame, route it to its handler, and produce the outgoing frame(s).
error
Error type for the Claude Code IDE peer.
install
BC.3b: the crate-owned install(boot) entry point.
lockfile
Discovery lockfile: ~/.claude/ide/<port>.lock.
modes
claude-code-mode — the minor mode layered on the IDE terminal buffer.
notifications
IDE-protocol I6: server-initiated notifications (server → agent).
protocol
MCP envelope payloads carried inside the JSON-RPC frames (the lattice_protocol::jsonrpc types are the envelope; these are the method-specific bodies).
reads
IDE-protocol I2.2: the five read tools.
server
The IDE server supervisor: an idle tokio task that starts/stops the loopback WebSocket listener on command.
status
IDE-protocol I7: the claude-code modeline status segment.
transport
WebSocket accept + authorization handshake.
writes
IDE-protocol I3: the three write tools.