pub struct McpServer<Counterpart: Role, Run = NullRun> { /* private fields */ }Expand description
A runtime-agnostic MCP server.
McpServer wraps an McpServerConnect
implementation. A server whose counterpart is role::mcp::Client can be
connected directly as a standalone MCP component. With the
unstable_mcp_over_acp feature, servers can instead be attached to ACP
session setup through Builder::with_mcp_server or
SessionBuilder::with_mcp_server. When unstable_protocol_v2 is also
enabled, Proxy.v2().with_mcp_server attaches a server globally to draft
v2 setup requests. V2SessionBuilder::with_mcp_server attaches one to a
single new v2 session, while V2ResumeSessionBuilder::with_mcp_server
attaches one to a single resumed session. With unstable_session_fork,
V2ForkSessionBuilder::with_mcp_server attaches one to a single forked
session.
§Creating an MCP Server
The agent-client-protocol-rmcp crate provides builder APIs for MCP tools
backed by the rmcp crate.
Or implement McpServerConnect for custom server behavior:
let server = McpServer::new(MyCustomServerConnect, NullRun);Implementations§
Source§impl<Counterpart: Role, Run> McpServer<Counterpart, Run>where
Run: RunWithConnectionTo<Counterpart>,
impl<Counterpart: Role, Run> McpServer<Counterpart, Run>where
Run: RunWithConnectionTo<Counterpart>,
Sourcepub fn new(c: impl McpServerConnect<Counterpart>, runner: Run) -> Self
pub fn new(c: impl McpServerConnect<Counterpart>, runner: Run) -> Self
Create an MCP server from something that implements the McpServerConnect trait.
§See also
See agent-client-protocol-rmcp to construct MCP servers from Rust code
with rmcp.