raise mcp streamable-http session keepalive from 5m to 24h

This commit is contained in:
damocles 2026-08-31 11:33:36 +02:00 committed by mara
commit 6ccd634afb
3 changed files with 29 additions and 3 deletions

View file

@ -272,7 +272,15 @@ pub async fn serve_http(addr: std::net::SocketAddr) -> anyhow::Result<()> {
use rmcp::transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService, session::local::LocalSessionManager,
};
let session_manager = std::sync::Arc::new(LocalSessionManager::default());
let mut session_manager = LocalSessionManager::default();
// rmcp's default session idle timeout is 5 minutes, meant to reap zombie
// connections lost to an HTTP/2 RST_STREAM — far too short for a claude
// turn that goes several minutes between bash-MCP calls (a long Read/Edit
// stretch, a background-task wait). That trips a client-visible "MCP
// server ... session expired" mid-turn; self-recovering on the next call,
// but confusing. Give it real headroom instead of turning it off outright.
session_manager.session_config.keep_alive = Some(std::time::Duration::from_hours(24));
let session_manager = std::sync::Arc::new(session_manager);
let service = StreamableHttpService::new(
|| Ok(BashMcp),
session_manager,