Skip to main content

Module server

Module server 

Source
Expand description

MCP Server configuration and runtime.

This module provides a clean API for creating and running MCP servers:

use mcp::macros::mcp_tool;
use mcp::{McpServerConfig, McpServer};

#[mcp_tool(description = "Add two numbers")]
fn add(a: f64, b: f64) -> f64 { a + b }

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = McpServerConfig::builder()
        .name("calculator")
        .version("1.0.0")
        .with_stdio_transport()
        .with_tools(tools![AddTool])
        .build();

    McpServer::run(config).await?;
    Ok(())
}

Structs§

McpServer
MCP Server runtime.
McpServerConfig
Configuration for an MCP server.
McpServerConfigBuilder
Builder for creating MCP server configurations.

Enums§

ServerError
Errors that can occur when running an MCP server.
ServerTransport
Server transport configuration.