From b74a73f793dd239ae9a95a55373139d6360b1803 Mon Sep 17 00:00:00 2001 From: Barry Walker Date: Sat, 24 Jan 2026 13:15:50 -0500 Subject: [PATCH] fix: disable MCP session idle timeout completely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 24-hour timeout was still not being respected - sessions were being killed after ~14 minutes. Using Timeout.InfiniteTimeSpan completely disables idle-based session pruning in the SDK's IdleTrackingBackgroundService. This makes the MCP server bulletproof against session drops during long periods of inactivity (e.g., when users are discussing/planning before making tool calls). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- PaperlessMCP/Program.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PaperlessMCP/Program.cs b/PaperlessMCP/Program.cs index a4cabc2..b8ea14f 100644 --- a/PaperlessMCP/Program.cs +++ b/PaperlessMCP/Program.cs @@ -40,8 +40,9 @@ else .AddMcpServer() .WithHttpTransport(options => { - // Increase idle timeout to 24 hours to prevent session drops during long operations - options.IdleTimeout = TimeSpan.FromHours(24); + // Disable idle timeout completely - sessions should never be killed due to inactivity + // The SDK's IdleTrackingBackgroundService respects InfiniteTimeSpan to skip idle-based pruning + options.IdleTimeout = Timeout.InfiniteTimeSpan; }) .WithToolsFromAssembly(); @@ -52,7 +53,7 @@ else app.MapMcp("/mcp"); - app.Logger.LogInformation("PaperlessMCP server starting on port {Port}", port); + app.Logger.LogInformation("PaperlessMCP server starting on port {Port} with infinite session timeout", port); app.Logger.LogInformation("MCP endpoint available at: http://localhost:{Port}/mcp", port); await app.RunAsync($"http://0.0.0.0:{port}");