pub struct McpServer { /* private fields */ }Expand description
MCP server backed by the rmcp framework.
The struct is cloned per request by rmcp’s handler dispatch; the expensive bits (provider closure) are behind an Arc so cloning is cheap.
Implementations§
Source§impl McpServer
impl McpServer
pub fn new(options: ServerOptions) -> Self
Sourcepub fn builtins(&self) -> &BuiltinsConfig
pub fn builtins(&self) -> &BuiltinsConfig
Read the manifest-declared builtins: config. Downstream
consumers (e.g. a graph_overview tool that wipes a temp/
directory when temp_cleanup: on_overview is set) call this
to discover what flags the operator asked for. The framework
itself does not act on this — that would force it to interpret
graph-specific semantics it shouldn’t know about.
Sourcepub fn tool_router_mut(&mut self) -> &mut ToolRouter<McpServer>
pub fn tool_router_mut(&mut self) -> &mut ToolRouter<McpServer>
Mutable access to the tool router for dynamic tool registration.
Use only at server-construction time (before serve).
Once dispatching starts, the router is cloned per request and
mutation would race.
Sourcepub fn prompt_router_mut(&mut self) -> &mut PromptRouter<McpServer>
pub fn prompt_router_mut(&mut self) -> &mut PromptRouter<McpServer>
Mutable access to the prompt router for dynamic skill / prompt
registration. Same lifecycle contract as [tool_router_mut]:
boot-time only. Most operators reach prompts via
serve_prompts rather than touching the router directly.
Sourcepub fn register_typed_tool<T, F>(
&mut self,
name: &'static str,
description: &'static str,
handler: F,
)where
T: for<'de> Deserialize<'de> + JsonSchema + Default + Send + Sync + 'static,
F: Fn(T) -> String + Send + Sync + 'static,
pub fn register_typed_tool<T, F>(
&mut self,
name: &'static str,
description: &'static str,
handler: F,
)where
T: for<'de> Deserialize<'de> + JsonSchema + Default + Send + Sync + 'static,
F: Fn(T) -> String + Send + Sync + 'static,
Register a typed dynamic tool. Compresses the boilerplate of:
- Generating a JSON Schema for the args type via
schemars. - Building a
rmcp::model::Toolattr from the schema + name + description. - Deserialising the per-call JSON arguments via serde.
- Wrapping the handler in a
rmcp::handler::server::router::tool::ToolRoute::new_dynclosure suitable fortool_router_mut.
The handler is Fn(T) -> String; it owns whatever state it
needs through the closure environment (typically an Arc-clone
of a domain-specific state handle). Returning a string means
the tool reports a clean text body to the agent rather than
exposing a tool-error envelope — matches the framework’s
“errors as values” convention for source / GitHub tools.
Sourcepub fn ping_tool_attr() -> Tool
pub fn ping_tool_attr() -> Tool
Generated tool metadata function for ping
Sourcepub fn read_source_tool_attr() -> Tool
pub fn read_source_tool_attr() -> Tool
Generated tool metadata function for read_source
Sourcepub fn grep_tool_attr() -> Tool
pub fn grep_tool_attr() -> Tool
Generated tool metadata function for grep
Sourcepub fn list_source_tool_attr() -> Tool
pub fn list_source_tool_attr() -> Tool
Generated tool metadata function for list_source
Sourcepub fn repo_management_tool_attr() -> Tool
pub fn repo_management_tool_attr() -> Tool
Generated tool metadata function for repo_management