Skip to main content

mcp_methods/server/
mod.rs

1//! Reusable building blocks for Rust-native MCP servers.
2//!
3//! The `mcp-server` binary (in the sibling `crates/mcp-server` crate)
4//! is a complete generic MCP server: source navigation, GitHub access
5//! (issues + REST API with drill-down), workspace mode (github
6//! clone-and-track or local directory bind), watch mode, and
7//! manifest-driven Cypher / tool registration. Downstream crates that
8//! want the same framework with domain-specific tools layered on top
9//! depend on `mcp-methods` and call into the public modules below.
10//!
11//! Typical layering pattern:
12//! 1. Construct [`server::ServerOptions`] from a manifest, optionally
13//!    binding source roots, a default repo, or a workspace handle.
14//! 2. `let mut server = server::McpServer::new(options);`
15//! 3. Register your domain-specific tools with
16//!    [`server::McpServer::register_typed_tool`] — typed arg struct
17//!    plus a `Fn(T) -> String` handler. (For lower-level control, use
18//!    [`server::McpServer::tool_router_mut`] and rmcp's `ToolRoute`
19//!    directly.)
20//! 4. `server.serve(rmcp::transport::stdio()).await`.
21//!
22//! See `kglite-mcp-server` for a real example: it adds `cypher_query`,
23//! `graph_overview`, and `save_graph` tools that close over an active
24//! graph handle. Python authors running a FastMCP server can compose
25//! tools via the `mcp_methods.fastmcp` helper submodule (Python-side).
26//!
27//! **Note:** the legacy `embedder:` / `tools[].python:` extension hooks
28//! that lived here in 0.3.25 have been removed. They required PyO3 in
29//! the framework's source, which violated the pure-Rust constraint of
30//! this crate. Downstream Python-aware servers (kglite, etc.) implement
31//! their equivalent via a thin pyo3 wrapper in their own cdylib.
32
33pub mod env;
34pub mod manifest;
35pub mod runtime;
36// `server` inside the `server` feature module — the inner module is
37// the rmcp `ServerHandler` impl. Rename would churn every downstream
38// import; allow the inception.
39#[allow(clippy::module_inception)]
40pub mod server;
41pub mod source;
42pub mod watch;
43pub mod workspace;
44
45// Re-export the most commonly used types so downstream crates can
46// `use mcp_methods::server::{Manifest, ServerOptions, McpServer};`
47// without chasing the module hierarchy.
48pub use manifest::{
49    find_sibling_manifest, find_workspace_manifest, load as load_manifest, BuiltinsConfig,
50    EmbedderConfig, Manifest, ManifestError, PythonTool, TempCleanup, ToolSpec, TrustConfig,
51    WorkspaceConfig, WorkspaceKind,
52};
53pub use runtime::{init_tracing, load_env_for_mode, maybe_watch, resolve_source_roots};
54pub use server::{McpServer, RepoProvider, ServerOptions};
55pub use source::SourceRootsProvider;
56pub use watch::{watch as watch_dir, ChangeHandler, WatchHandle};
57pub use workspace::{PostActivateHook, Workspace};