fix: prevent MCP session timeouts and fix JSON serialization

- Add JsonIgnoreCondition.WhenWritingNull to prevent sending null values
- Increase idle session timeout to 24 hours to prevent premature session closure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Barry Walker
2026-01-13 22:44:22 -05:00
parent 020c0a318a
commit be44ea12f9
2 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ public class PaperlessClient
private static readonly JsonSerializerOptions JsonOptions = new() private static readonly JsonSerializerOptions JsonOptions = new()
{ {
PropertyNameCaseInsensitive = true, PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
}; };
public PaperlessClient(HttpClient httpClient, IOptions<PaperlessOptions> options, ILogger<PaperlessClient> logger) public PaperlessClient(HttpClient httpClient, IOptions<PaperlessOptions> options, ILogger<PaperlessClient> logger)
+5 -1
View File
@@ -38,7 +38,11 @@ else
builder.Services builder.Services
.AddMcpServer() .AddMcpServer()
.WithHttpTransport() .WithHttpTransport(options =>
{
// Increase idle timeout to 24 hours to prevent session drops during long operations
options.IdleTimeout = TimeSpan.FromHours(24);
})
.WithToolsFromAssembly(); .WithToolsFromAssembly();
var app = builder.Build(); var app = builder.Build();