1 unstable release

Uses new Rust 2024

0.5.0 Dec 26, 2025

#2594 in HTTP server

MIT/Apache

1MB
22K SLoC

Rocket integration for the Rust MCP SDK.

This crate provides integration between the MCP SDK and the Rocket 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 via Rocket fairings

HTTP Protocol Requirements

Clients must include the Mcp-Protocol-Version header in all requests:

POST /mcp HTTP/1.1
Content-Type: application/json
Mcp-Protocol-Version: 2025-11-25

{"jsonrpc":"2.0","id":1,"method":"initialize","params":{...}}

Supported protocol versions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25

Quick Start

use mcpkit::prelude::*;
use mcpkit_rocket::McpRouter;

// Your MCP server handler (use #[mcp_server] macro)
#[mcp_server(name = "my-server", version = "1.0.0")]
impl MyServer {
    #[tool(description = "Say hello")]
    async fn hello(&self, name: String) -> ToolOutput {
        ToolOutput::text(format!("Hello, {name}!"))
    }
}

#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
    McpRouter::new(MyServer::new())
        .launch()
        .await?;
    Ok(())
}

Advanced Usage

For more control, use into_rocket() to integrate with an existing app:

use mcpkit_rocket::McpRouter;
use rocket::{Build, Rocket};

fn build_app() -> Rocket<Build> {
    let mcp = McpRouter::new(MyServer::new())
        .with_cors();

    rocket::build()
        .attach(mcp.into_fairing())
        .mount("/health", routes![health_check])
}

#[rocket::get("/")]
fn health_check() -> &'static str {
    "OK"
}

Client Example (curl)

# Initialize the connection
curl -X POST http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -H "Mcp-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","clientInfo":{"name":"test","version":"1.0"},"capabilities":{}}}'

# List available tools
curl -X POST http://localhost:8000/mcp \
  -H "Content-Type: application/json" \
  -H "Mcp-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

mcpkit-rocket

Rocket framework integration for mcpkit MCP servers.

Features

  • Full MCP protocol support over HTTP
  • CORS fairing for cross-origin requests
  • Session management with SSE streaming
  • Macro-based route generation for type safety

Usage

use mcpkit_rocket::{McpRouter, create_mcp_routes};
use rocket::launch;

#[launch]
fn rocket() -> _ {
    let handler = MyHandler::new();

    rocket::build()
        .manage(McpRouter::new(handler).with_cors())
        .mount("/", create_mcp_routes!())
}

Requirements

  • Rust 1.85+
  • Rocket 0.5+

License

MIT OR Apache-2.0

Dependencies

~32–71MB
~1M SLoC