agent_client_protocol/mcp_server/mod.rs
1//! MCP server support for providing MCP tools over ACP.
2//!
3//! This module provides the infrastructure for building MCP servers that
4//! integrate with ACP connections.
5//!
6//! ## Quick Start
7//!
8//! ```rust,ignore
9//! use agent_client_protocol::mcp_server::{McpServer, McpTool};
10//!
11//! // Create an MCP server with tools
12//! let server = McpServer::builder("my-server".to_string())
13//! .instructions("A helpful assistant")
14//! .tool(MyTool)
15//! .build();
16//!
17//! // Use the server as a handler on your connection
18//! Proxy.builder()
19//! .with_handler(server)
20//! .serve(client)
21//! .await?;
22//! ```
23//!
24//! ## Custom MCP Server Implementations
25//!
26//! You can implement [`McpServerConnect`](`crate::mcp_server::McpServerConnect`) to create custom MCP servers:
27//!
28//! ```rust,ignore
29//! use agent_client_protocol::mcp_server::{McpServer, McpServerConnect, McpContext};
30//! use agent_client_protocol::{DynComponent, JrLink};
31//!
32//! struct MyCustomServer;
33//!
34//! impl<R: Role> McpServerConnect<Link> for MyCustomServer {
35//! fn name(&self) -> String {
36//! "my-custom-server".to_string()
37//! }
38//!
39//! fn connect(&self, cx: McpContext<Link>) -> DynComponent {
40//! // Return a component that serves MCP requests
41//! DynComponent::new(my_mcp_component)
42//! }
43//! }
44//!
45//! let server = McpServer::new(MyCustomServer);
46//! ```
47
48mod active_session;
49mod builder;
50mod connect;
51mod context;
52mod responder;
53mod server;
54mod tool;
55
56pub use builder::{EnabledTools, McpServerBuilder};
57pub use connect::McpServerConnect;
58pub use context::McpConnectionTo;
59pub use server::McpServer;
60pub use tool::McpTool;