Expand description
Runtime-agnostic MCP server support, including optional attachment to ACP sessions. Runtime-agnostic MCP server support.
This module provides infrastructure for serving MCP directly without tying
the core SDK to a particular MCP implementation or async runtime. With the
unstable_mcp_over_acp feature, the same servers can be attached to ACP
session setup requests through the with_mcp_server builder methods.
§Building MCP servers with tools
The agent-client-protocol-rmcp crate provides the builder APIs for MCP
tools backed by the rmcp crate.
§Custom MCP Server Implementations
You can implement McpServerConnect to create custom MCP servers:
ⓘ
use agent_client_protocol::mcp_server::{McpConnectionTo, McpServer, McpServerConnect};
use agent_client_protocol::{DynConnectTo, NullRun, Role, role};
struct MyCustomServer;
impl<R: Role> McpServerConnect<R> for MyCustomServer {
fn name(&self) -> String {
"my-custom-server".to_string()
}
fn connect(&self, cx: McpConnectionTo<R>) -> DynConnectTo<role::mcp::Client> {
// Return a component that serves MCP requests
DynConnectTo::new(my_mcp_component(cx))
}
}
let server = McpServer::new(MyCustomServer, NullRun);Structs§
- McpConnection
To - Connection information available to an MCP server.
- McpServer
- A runtime-agnostic MCP server.
- McpTool
Metadata - Runtime-neutral metadata for an MCP tool.
- McpTool
Registry - Runtime-neutral registry for MCP tools.
- Registered
McpTool - A registered MCP tool that can be dispatched with erased JSON values.
Enums§
- Enabled
Tools - Tracks which tools are enabled.
- McpConnection
Context - Describes how an MCP server connection was established.
Traits§
- McpServer
Connect - Trait for types that can create MCP server connections.
- McpTool
- Trait for defining MCP tools.
Functions§
- tool_fn
- Create a stateless function-backed MCP tool and its concurrent runner.
- tool_
fn_ mut - Create a “single-threaded” function-backed MCP tool and its runner.
Type Aliases§
- McpTool
Schema - JSON Schema object used to describe MCP tool inputs and outputs.