Skip to content

mcp-http-drain-rejected-request-body - #805

Merged
jeffreyaven merged 1 commit into
mainfrom
fix/mcp-reject-drains-body
Oct 4, 2026
Merged

jeffreyaven merged 1 commit into
mainfrom
fix/mcp-reject-drains-body

Conversation

@jeffreyaven

Copy link
Copy Markdown
Member

Summary

Post-merge Windows Build on main (ed962c9) failed in MCP HTTP Bearer Token Authentication with ConnectionResetError: [WinError 10054]. Reproduced locally on Windows: 6 of 30 anonymous (401) and 11 of 30 cross-origin (403) round trips reset; authenticated (200) never did.

Cause: both refusals were written without reading the request body. The client sends Connection: close, so Go closes the socket after the response while the body bytes are still unread when they arrived in a separate segment; that close is a TCP reset, and Windows discards the buffered response on reset. Linux clients read the buffered bytes first, which is why only Windows saw it.

Fix: rejectRequest drains up to 64 KiB of the body before writing the 401 / 403 (bearer check and the CrossOriginProtection deny handler). One file, plus a unit test asserting the body is consumed on both refusals. Against the patched binary the same loop is 180 of 180 clean.

Test plan

  • go test ./pkg/mcp_server/, golangci-lint v2.5.0: pass.
  • Robot Mcp suite in WSL: 79 / 79.
  • The existing MCP HTTP Bearer Token Authentication scenario is the regression test; CI Windows Build is the proof.

🤖 Generated with Claude Code

Early refusals (401 from the bearer check, 403 from cross-origin
protection) answered without reading the request body; with a client
sending Connection: close, Go then closed the socket with unread bytes,
which resets the connection and a Windows client loses the response.
The body is now drained (bounded) before the refusal is written.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jeffreyaven
jeffreyaven merged commit 50d6746 into main Oct 4, 2026
30 checks passed
@jeffreyaven
jeffreyaven deleted the fix/mcp-reject-drains-body branch October 4, 2026 17:01
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.

2 participants