Skip to main content

Module mcp_server

Module mcp_server 

Source
Expand description

MCP server support for providing MCP tools over ACP MCP server support for providing MCP tools over ACP.

This module provides the infrastructure for building MCP servers that integrate with ACP connections.

§Quick Start

use agent_client_protocol::mcp_server::{McpServer, McpTool};

// Create an MCP server with tools
let server = McpServer::builder("my-server".to_string())
    .instructions("A helpful assistant")
    .tool(MyTool)
    .build();

// Use the server as a handler on your connection
Proxy.builder()
    .with_handler(server)
    .serve(client)
    .await?;

§Custom MCP Server Implementations

You can implement McpServerConnect to create custom MCP servers:

use agent_client_protocol::mcp_server::{McpServer, McpServerConnect, McpContext};
use agent_client_protocol::{DynComponent, JrLink};

struct MyCustomServer;

impl<R: Role> McpServerConnect<Link> for MyCustomServer {
    fn name(&self) -> String {
        "my-custom-server".to_string()
    }

    fn connect(&self, cx: McpContext<Link>) -> DynComponent {
        // Return a component that serves MCP requests
        DynComponent::new(my_mcp_component)
    }
}

let server = McpServer::new(MyCustomServer);

Structs§

McpConnectionTo
Context about the ACP and MCP connection available to an MCP server.
McpServer
An MCP server that can be attached to ACP connections.
McpServerBuilder
Builder for creating MCP servers with tools.

Enums§

EnabledTools
Tracks which tools are enabled.

Traits§

McpServerConnect
Trait for types that can create MCP server connections.
McpTool
Trait for defining MCP tools.