construct/mcp_server/mod.rs
1//! Construct MCP server — exposes Construct's built-in tools over the MCP
2//! Streamable HTTP transport (JSON-RPC 2.0 + SSE) so external CLIs
3//! (Claude Code, Codex, OpenCode, Gemini CLI) can share one local backend.
4//!
5//! The MCP server runs as an **in-process tokio task inside the main construct
6//! daemon** (see `src/gateway/mod.rs::run_gateway`). External clients discover
7//! it through `~/.construct/mcp.json`, written by the gateway as soon as the
8//! MCP task finishes binding to its ephemeral port.
9//!
10//! This module contains the router, session store, tool registry, and
11//! `ProgressSink` that publishes `notifications/progress` events onto the
12//! originating SSE stream.
13//!
14//! Design notes:
15//! - One daemon, many sessions; sessions are in-memory only.
16//! - Auth is a `session_id` + `bearer token` pair; no persistence.
17//! - MCP keeps its own ephemeral port and its own auth pair — it does NOT
18//! share the gateway's listener or pairing model.
19//! - Tools are enumerated once at startup via [`registry::build_tools_with_runtime`]
20//! (config-aware + wired to live runtime handles) so every tool the gateway
21//! can run is also exposed to MCP clients. [`registry::build_default_tools`]
22//! and [`registry::build_tools_with_config`] are retained as the degraded
23//! fallback and the test entry point.
24
25pub mod progress;
26pub mod progress_wrap;
27pub mod registry;
28pub mod runtime;
29pub mod server;
30pub mod session;
31pub mod skills_tools;
32
33pub use runtime::RuntimeHandles;
34pub use server::{McpServerHandle, run_daemon, serve_on};
35pub use session::ProgressEvent;