agent_client_protocol/mcp_server/mod.rs
1//! Runtime-agnostic MCP server support for providing MCP tools over ACP.
2//!
3//! This module provides the infrastructure for attaching MCP servers to ACP
4//! connections without tying the core SDK to a particular MCP implementation or
5//! async runtime.
6//!
7//! ## Building MCP servers with tools
8//!
9//! The `agent-client-protocol-rmcp` crate provides the builder APIs for MCP
10//! tools backed by the `rmcp` crate.
11//!
12//! ## Custom MCP Server Implementations
13//!
14//! You can implement [`McpServerConnect`](`crate::mcp_server::McpServerConnect`) to create custom MCP servers:
15//!
16//! ```rust,ignore
17//! use agent_client_protocol::mcp_server::{McpConnectionTo, McpServer, McpServerConnect};
18//! use agent_client_protocol::{DynConnectTo, NullRun, Role, role};
19//!
20//! struct MyCustomServer;
21//!
22//! impl<R: Role> McpServerConnect<R> for MyCustomServer {
23//! fn name(&self) -> String {
24//! "my-custom-server".to_string()
25//! }
26//!
27//! fn connect(&self, cx: McpConnectionTo<R>) -> DynConnectTo<role::mcp::Client> {
28//! // Return a component that serves MCP requests
29//! DynConnectTo::new(my_mcp_component(cx))
30//! }
31//! }
32//!
33//! let server = McpServer::new(MyCustomServer, NullRun);
34//! ```
35
36mod active_session;
37mod connect;
38mod context;
39mod registry;
40mod server;
41mod tool;
42mod tool_fn;
43
44pub use connect::McpServerConnect;
45pub use context::McpConnectionTo;
46pub use registry::{
47 EnabledTools, McpToolMetadata, McpToolRegistry, McpToolSchema, RegisteredMcpTool,
48};
49pub use server::McpServer;
50pub use tool::McpTool;
51pub use tool_fn::{tool_fn, tool_fn_mut};