Expand description
Bounded session management for MCP servers.
This crate provides BoundedSessionManager, a wrapper around rmcp’s
LocalSessionManager that enforces:
- Maximum concurrent sessions with FIFO eviction of the oldest session when the limit is reached.
- Optional rate limiting on session creation via a sliding-window counter.
- Idle timeout via rmcp’s
keep_aliveconfiguration (passed through).
§Quick start
ⓘ
use std::sync::Arc;
use mcp_session::BoundedSessionManager;
use mcp_session::SessionConfig;
let manager = Arc::new(
BoundedSessionManager::new(
SessionConfig {
keep_alive: Some(std::time::Duration::from_secs(4 * 60 * 60)),
..Default::default()
},
100, // max concurrent sessions
)
.with_rate_limit(10, std::time::Duration::from_secs(60)),
);
// Pass `manager` to `StreamableHttpService::new(factory, manager, config)`Structs§
- Bounded
Session Manager - Wraps
LocalSessionManagerand limits the number of concurrent sessions. - Session
Config
Enums§
- Bounded
Session Error - Errors returned by
BoundedSessionManager.