Lutra/crates/mcp/src/lib.rs
danny 0e56c22b66 M3.8: MCP server lutra mcp
- crates/mcp (L5): JSON-RPC 2.0 over stdio, dual era: MCP 2026-07-28
  (per-request _meta, server/discover, -32022) and legacy initialize
  (2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05). Tools list_commands,
  execute_command (app.quit only with confirm: true), screenshot (image
  content), read_buffer, get_events (ring of 1000 events via
  events.subscribe); resources lutra://buffer/<path> for open buffers.
  Engine errors become tool errors with the engine code. Lines capped at
  16 MiB, guard around every request, parser and tool args fuzzed.
- lutra mcp [--port PORT] [--no-start] in apps/lutra-cli: connects through
  the rendezvous file and token, or starts Lutra.
- Engine: read-only buffer.list command.
- Tests: protocol units + proptest fuzz, integration over the token
  listener, stdio end to end. Docs: architecture (MCP), G7, ROADMAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 20:43:12 +02:00

25 lines
954 B
Rust

//! MCP server of Lutra (layer L5).
//!
//! `lutra mcp` speaks the Model Context Protocol over stdio so that
//! agents can drive Lutra: JSON-RPC 2.0, one message per line
//! ([`jsonrpc`]), served by [`server::Server`] in both the modern
//! (2026-07-28, per-request metadata) and the legacy (`initialize`) era.
//! The tools are generic over the command registry (D16): see [`tools`].
//! Resources are the open buffers. Recent engine events are kept by
//! [`events`].
//!
//! The crate does not open sockets or start processes itself: the `lutra`
//! CLI implements [`remote::Connector`] with the control channel client
//! and the single-instance rendezvous (`lutra_control::client`).
//! Everything read from stdin or from Lutra is untrusted, capped and
//! never panics.
pub mod encoding;
pub mod events;
pub mod jsonrpc;
pub mod remote;
pub mod server;
pub mod tools;
pub use remote::{CallError, Connection, Connector};
pub use server::Server;