mcpkit-actix
Actix-web integration for the Model Context Protocol (MCP).
This crate provides integration between the MCP SDK and the Actix-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
Usage
use McpRouter;
use ServerHandler;
// Your MCP server handler (must implement ServerHandler, ToolHandler, etc.)
// Note: Clone is NOT required - the handler is wrapped in Arc internally.
;
async
Default Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/mcp |
POST | JSON-RPC messages |
/mcp/sse |
GET | Server-Sent Events stream |
Customizing Paths
new
.post_path
.sse_path
.serve
.await
Integration with Existing App
For more control, integrate MCP routes into an existing Actix-web application:
use McpRouter;
use ServerHandler;
use ;
;
async
Exports
| Export | Purpose |
|---|---|
McpRouter |
Router builder for MCP endpoints |
McpState |
Shared state for MCP handlers |
handle_mcp_post |
Handler for POST requests |
handle_sse |
Handler for SSE streaming |
Session |
Individual client session |
SessionManager |
Manages SSE broadcast channels |
SessionStore |
Storage for HTTP session data |
Part of mcpkit
This crate is part of the mcpkit SDK. For most use cases, depend on mcpkit directly rather than this crate.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.