fix: disable MCP session idle timeout completely
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 <noreply@anthropic.com>
This commit is contained in:
@@ -40,8 +40,9 @@ else
|
|||||||
.AddMcpServer()
|
.AddMcpServer()
|
||||||
.WithHttpTransport(options =>
|
.WithHttpTransport(options =>
|
||||||
{
|
{
|
||||||
// Increase idle timeout to 24 hours to prevent session drops during long operations
|
// Disable idle timeout completely - sessions should never be killed due to inactivity
|
||||||
options.IdleTimeout = TimeSpan.FromHours(24);
|
// The SDK's IdleTrackingBackgroundService respects InfiniteTimeSpan to skip idle-based pruning
|
||||||
|
options.IdleTimeout = Timeout.InfiniteTimeSpan;
|
||||||
})
|
})
|
||||||
.WithToolsFromAssembly();
|
.WithToolsFromAssembly();
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ else
|
|||||||
|
|
||||||
app.MapMcp("/mcp");
|
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);
|
app.Logger.LogInformation("MCP endpoint available at: http://localhost:{Port}/mcp", port);
|
||||||
|
|
||||||
await app.RunAsync($"http://0.0.0.0:{port}");
|
await app.RunAsync($"http://0.0.0.0:{port}");
|
||||||
|
|||||||
Reference in New Issue
Block a user