Crates.io | rmcp-actix-web |
lib.rs | rmcp-actix-web |
version | 0.8.4 |
created_at | 2025-07-05 19:48:54.184408+00 |
updated_at | 2025-09-25 11:57:45.284196+00 |
description | actix-web transport implementations for RMCP (Rust Model Context Protocol) |
homepage | https://gitlab.com/lx-industries/rmcp-actix-web |
repository | https://gitlab.com/lx-industries/rmcp-actix-web |
max_upload_size | |
id | 1739432 |
size | 361,103 |
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.
rmcp-actix-web
provides:
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.
We welcome contributions to rmcp-actix-web
! Please follow these guidelines:
main
: git checkout -b feature/my-new-feature
cargo test
# Clone your fork
git clone https://gitlab.com/your-username/rmcp-actix-web.git
cd rmcp-actix-web
# Build the project
cargo build --workspace
# Run tests
cargo test
# Run examples
cargo run --example counter_streamable_http
cargo fmt
to format codecargo clippy --all-targets
to catch common mistakesFound a bug or have a feature request? Please report it on our GitLab issue tracker.
Add this to your Cargo.toml
:
[dependencies]
rmcp-actix-web = "0.2"
rmcp = "0.3"
actix-web = "4"
Control which transports are compiled:
# Default: StreamableHttp transport enabled
rmcp-actix-web = "0.2"
# Only StreamableHttp transport (explicit)
rmcp-actix-web = { version = "0.2", default-features = false, features = ["transport-streamable-http-server"] }
rmcp-actix-web | rmcp |
---|---|
0.6.1 | 0.6.3 |
0.4.2 | 0.6.1 |
0.2.2 | 0.3.0 |
0.2.x | 0.2.x |
0.1.x | 0.2.x |
Mount MCP services at custom paths within existing actix-web applications:
use rmcp_actix_web::StreamableHttpService;
use rmcp::transport::streamable_http_server::session::local::LocalSessionManager;
use actix_web::{App, HttpServer, web};
use std::sync::Arc;
#[actix_web::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// StreamableHttp service with builder pattern (shared across workers)
let http_service = StreamableHttpService::builder()
.service_factory(Arc::new(|| Ok(MyMcpService::new())))
.session_manager(Arc::new(LocalSessionManager::default()))
.stateful_mode(true)
.build();
HttpServer::new(move || {
App::new()
// Your existing routes
.route("/health", web::get().to(|| async { "OK" }))
// Mount MCP service at custom path
.service(web::scope("/api/v1/mcp").service(http_service.clone().scope()))
})
.bind("127.0.0.1:8080")?
.run()
.await?;
Ok(())
}
See the examples/
directory for complete working examples:
counter_streamable_http.rs
- Streamable HTTP server examplecomposition_streamable_http_example.rs
- StreamableHttp with custom mountingauthorization_proxy_example.rs
- MCP service acting as a proxy using Authorization headers# Basic StreamableHttp server
cargo run --example counter_streamable_http
# Framework composition with StreamableHttp
cargo run --example composition_streamable_http_example
# Authorization proxy example
cargo run --example authorization_proxy_example
Each example includes detailed documentation and curl commands for testing.
StreamableHttpService::builder().build()
with .scope()
for compositionauthorization-token-passthrough
feature)RequestContext
extensionsMIT License - see LICENSE file for details.