mcpkit-axum 0.2.0

Axum integration for mcpkit
Documentation

Axum integration for the Rust MCP SDK.

This crate provides integration between the MCP SDK and the Axum web framework, making it easy to expose MCP servers over HTTP.

Features

  • HTTP POST endpoint for JSON-RPC messages
  • Server-Sent Events (SSE) streaming for notifications
  • Session management with automatic cleanup
  • Protocol version validation
  • CORS support

Example

use mcpkit_axum::{McpRouter, McpState};
use mcpkit_server::ServerHandler;
use axum::Router;

// Your MCP server handler (must implement ServerHandler)
struct MyServer;

#[tokio::main]
async fn main() {
    // Create MCP router with your handler
    let mcp_router = McpRouter::new(MyServer);

    // Build the full application
    let app = Router::new()
        .nest("/mcp", mcp_router.into_router());

    // Run the server
    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}