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
⚠️ Security Notice
This transport forwards Authorization headers to MCP services. If your MCP service passes these tokens to upstream APIs (proxy pattern), be aware this violates MCP specifications. See SECURITY.md for details.
Contributing
We welcome contributions to rmcp-actix-web! Please follow these guidelines:
How to Contribute
- Fork the repository on GitLab
- Create a feature branch from
main:git checkout -b feature/my-new-feature - Make your changes and ensure they follow the project's coding standards
- Add tests for your changes if applicable and run examples to verify functionality
- Run the test suite to ensure nothing is broken:
cargo test - Commit your changes with clear, descriptive commit messages
- Push to your fork and create a merge request
Development Setup
# Clone your fork
# Build the project
# Run tests
# Run examples
Code Standards
- Follow Rust conventions and use
cargo fmtto format code - Run
cargo clippy --all-targetsto catch common mistakes - Add documentation for public APIs
- Include tests for new functionality
Reporting Issues
Found a bug or have a feature request? Please report it on our GitLab issue tracker.
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.4.2 | 0.6.1 |
| 0.2.2 | 0.3.0 |
| 0.2.x | 0.2.x |
| 0.1.x | 0.2.x |
Quick Start
Simple SSE Server
use SseService;
use ;
use Arc;
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
Proxy Examples
authorization_proxy_example.rs- MCP service acting as a proxy using Authorization headers
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 Service:
SseService::builder().build()with.scope()method for mounting at custom paths - StreamableHttp:
StreamableHttpService::builder().build()with.scope()for composition - Multi-Service: Compose multiple MCP services with different transports in one app
- Unified Builder API: Consistent builder pattern across all transport services
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
Proxy Support
- Authorization Forwarding: Bearer tokens from Authorization headers can be forwarded to MCP services (requires
authorization-token-passthroughfeature) - MCP Proxy Pattern: Enable MCP services to act as proxies to backend APIs
- Selective Header Forwarding: Only forwards Authorization header when feature is enabled
- Type-Safe Access: Access forwarded headers via
RequestContextextensions - Security Notice: Token passthrough violates MCP specifications - see SECURITY.md for important details
License
MIT License - see LICENSE file for details.