Skip to content

Limit MCP response serialization - #2970

Merged
Widthdom merged 1 commit into
mainfrom
fix-issue2860
Jun 2, 2026
Merged

Limit MCP response serialization#2970
Widthdom merged 1 commit into
mainfrom
fix-issue2860

Conversation

@Widthdom

@Widthdom Widthdom commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace MCP response-size checks that called ToJsonString with a bounded UTF-8 JSON writer that stops when the configured byte cap is crossed.
  • Apply the same bounded measurement to batch_query response estimates and mark whether response_too_large.error.data.actual_bytes is exact.
  • Add MCP tests for early bounded serialization and the additive exactness flag.

Validation

  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj --filter FullyQualifiedName~McpServerTests -p:UseSharedCompilation=false -m:1 -nr:false
  • dotnet run --project tools/CodeIndex.Changelog -- check
  • dotnet format CodeIndex.sln --verify-no-changes --no-restore
  • dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll status --check --json

Attempted dotnet test CodeIndex.sln -p:UseSharedCompilation=false; sandboxed MSBuild first failed with named-pipe bind permission errors, then the escalated full run surfaced an unrelated transient SQL extractor test failure that passed when rerun directly and was stopped after becoming long-running. Targeted MCP coverage passed on net8.0 and net9.0 after the final rebase-equivalent cleanup.

Documentation and Changelog

  • Added changelog.d/unreleased/2860.security.md.
  • No docs update was needed because the configured MCP response limit remains the same; this changes enforcement timing and adds response error metadata.

Review

  • Codex adversarial review via .codex/workflows/adversarial-review.md: no blocking/actionable issues found.

Follow-up Candidates

  • None.

Fixes #2860

@Widthdom
Widthdom merged commit d4aaf42 into main Jun 2, 2026
10 checks passed
@Widthdom
Widthdom deleted the fix-issue2860 branch June 3, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP response size limit should be enforced before full response materialization

1 participant