pub struct McpServer {
name: String,
version: String,
instructions: Option<String>,
tools: BTreeMap<String, Arc<dyn Tool>>,
}Expand description
A fully-constructed MCP server. Clone is cheap (just bumps Arcs).
Fields§
§name: String§version: String§instructions: Option<String>§tools: BTreeMap<String, Arc<dyn Tool>>Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn has_tool_prefix(&self, prefix: &str) -> bool
pub fn has_tool_prefix(&self, prefix: &str) -> bool
Whether any registered tool’s name starts with prefix, so a
host can introspect which tool group it registered.
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
The names this server carries, in the order tools/list answers
them, so a host can record the surface it hands a child.
Sourcepub fn tool_schemas(&self) -> Vec<(String, Value)>
pub fn tool_schemas(&self) -> Vec<(String, Value)>
Every registered tool’s name and input schema, so a test can pin the surface a family advertises. Test-only.
Sourcepub async fn dispatch(&self, req: &JsonRpcRequest) -> Option<JsonRpcResponse>
pub async fn dispatch(&self, req: &JsonRpcRequest) -> Option<JsonRpcResponse>
Dispatch one JSON-RPC request to the appropriate handler.
Returns None for JSON-RPC notifications (no id) - notifications
must not elicit a response per the spec. Returns Some(response) for
every id-bearing request, success or error.
This method is pure (modulo tool side-effects): no I/O, no
timeouts, no mutation of self. Thread-safe; cheap to call
concurrently.