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:
@@ -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)
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user