rmcp-actix-web
actix-web transport implementations for RMCP (Rust Model Context Protocol)
This crate provides actix-web-based transport implementations for the Model Context Protocol, offering a complete alternative to the default Axum-based transports in the main RMCP crate.
Overview
rmcp-actix-web
provides:
- SSE (Server-Sent Events) transport: Real-time, unidirectional communication
- Streamable HTTP transport: Bidirectional communication with session management
- Framework-level composition: Mount MCP services at custom paths using actix-web Scope
- Full MCP compatibility: Implements the complete MCP protocol specification
- RMCP ecosystem alignment: APIs that follow RMCP patterns for maximum consistency
Installation
Add this to your Cargo.toml
:
[]
= "0.2"
= "0.3"
= "4"
Feature Flags
Control which transports are compiled:
# Default: both transports enabled
= "0.2"
# Only SSE transport
= { = "0.2", = false, = ["transport-sse-server"] }
# Only StreamableHttp transport
= { = "0.2", = false, = ["transport-streamable-http-server"] }
Compatibility Matrix
rmcp-actix-web | rmcp |
---|---|
0.2.2 | 0.3.0 |
0.2.x | 0.2.x |
0.1.x | 0.2.x |
Quick Start
Simple SSE Server
use SseServer;
async
Framework-Level Composition
Mount MCP services at custom paths within existing actix-web applications:
use ;
use LocalSessionManager;
use ;
use Arc;
async
Examples
See the examples/
directory for complete working examples:
Basic Examples
counter_sse.rs
- SSE server with a simple counter servicecounter_streamable_http.rs
- Streamable HTTP server example
Composition Examples
composition_sse_example.rs
- SSE server with framework-level compositioncomposition_streamable_http_example.rs
- StreamableHttp with custom mountingmulti_service_example.rs
- Multiple MCP services with different transports
Running Examples
# Basic SSE server
# Framework composition with SSE
# Multi-service example with both transports
Each example includes detailed documentation and curl commands for testing.
Key Features
Framework-Level Composition
- SSE Server:
SseServer::new()
returns(SseServer, Scope)
for mounting at custom paths - StreamableHttp:
StreamableHttpService::scope()
returns configuredScope
for composition - Multi-Service: Compose multiple MCP services with different transports in one app
- RMCP Alignment: APIs follow RMCP ecosystem patterns for consistency
Protocol Support
- Full MCP Compatibility: Implements complete MCP protocol specification
- Bidirectional Communication: Both request/response and streaming patterns
- Session Management: Stateful and stateless modes for StreamableHttp
- Keep-Alive: Configurable keep-alive intervals for connection health
Integration
- Drop-in Replacement: Same service implementations work with Axum or actix-web
- Middleware Support: Full integration with actix-web middleware stack
- Custom Paths: Mount services at any path using actix-web's Scope system
- Built on actix-web: Leverages the mature actix-web framework
License
MIT License - see LICENSE file for details.
Contributing
This project is part of the Model Context Protocol ecosystem. Contributions are welcome!