Skip to content

Harden MCP suggestion sampling - #2922

Merged
Widthdom merged 2 commits into
mainfrom
fix-issue2897-2898
Jun 2, 2026
Merged

Harden MCP suggestion sampling#2922
Widthdom merged 2 commits into
mainfrom
fix-issue2897-2898

Conversation

@Widthdom

@Widthdom Widthdom commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bound suggest_improvement sampling responses before parsing and parse sampled metadata JSON with an explicit depth limit.
  • Bound outbound sampling prompts, clamp long prompt fields, and summarize toolInvocationContext without sending its raw content to the sampling client.
  • Added focused MCP regression coverage for oversized responses, deep JSON responses, and prompt bounding/redaction.

Documentation and changelog

  • Updated USER_GUIDE.md for bounded MCP sampling prompts.
  • Added changelog fragments:
    • changelog.d/unreleased/2897.security.md
    • changelog.d/unreleased/2898.security.md

Validation

  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj --filter "FullyQualifiedName~SuggestImprovement_WhenSamplingResponse" -p:UseSharedCompilation=false
  • dotnet test tests/CodeIndex.Tests/CodeIndex.Tests.csproj --filter "FullyQualifiedName~SuggestImprovement_WhenSampling" -p:UseSharedCompilation=false
  • dotnet run --project tools/CodeIndex.Changelog -- check
  • dotnet build CodeIndex.sln -p:UseSharedCompilation=false
  • dotnet test CodeIndex.sln -p:UseSharedCompilation=false
  • dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll status --check --json

Review

Adversarial review (origin/main..HEAD): No blocking/actionable issues found.

Follow-up candidates

None.

Fixes #2897
Fixes #2898

@Widthdom
Widthdom marked this pull request as ready for review June 2, 2026 06:14
@Widthdom
Widthdom merged commit dc39c90 into main Jun 2, 2026
10 checks passed
@Widthdom
Widthdom deleted the fix-issue2897-2898 branch June 2, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant