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 bundled_skills_index;
34pub mod cli;
35pub mod env;
36pub mod manifest;
37pub mod runtime;
38// `server` inside the `server` feature module — the inner module is
39// the rmcp `ServerHandler` impl. Rename would churn every downstream
40// import; allow the inception.
41#[allow(clippy::module_inception)]
42pub mod server;
43pub mod skills;
44pub mod source;
45pub mod watch;
46pub mod workspace;
47
48// Re-export the most commonly used types so downstream crates can
49// `use mcp_methods::server::{Manifest, ServerOptions, McpServer};`
50// without chasing the module hierarchy.
51pub use manifest::{
52 find_sibling_manifest, find_workspace_manifest, load as load_manifest, BuiltinsConfig,
53 EmbedderConfig, Manifest, ManifestError, PythonTool, SkillSource, SkillsSource, TempCleanup,
54 ToolSpec, TrustConfig, WorkspaceConfig, WorkspaceKind,
55};
56pub use runtime::{init_tracing, load_env_for_mode, maybe_watch, resolve_source_roots};
57pub use server::{serve_prompts, McpServer, RepoProvider, ServerOptions};
58pub use skills::{
59 library_bundled_skills, render_skill_template, write_skill_template, AppliesWhen, BundledSkill,
60 GraphPropertyCheck, PredicateClause, PredicateOutcome, Registry as SkillRegistry,
61 ResolvedRegistry, Skill, SkillActivation, SkillError, SkillFrontmatter,
62 SkillPredicateEvaluator, SkillProvenance,
63};
64pub use source::SourceRootsProvider;
65pub use watch::{watch as watch_dir, ChangeHandler, WatchHandle};
66pub use workspace::{PostActivateHook, Workspace};