Repository navigation
mcp-http-drain-rejected-request-body - #805
Merged
Merged
Conversation
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>
general-kroll-4-life
approved these changes
Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Post-merge
Windows Buildonmain(ed962c9) failed inMCP HTTP Bearer Token AuthenticationwithConnectionResetError: [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:
rejectRequestdrains up to 64 KiB of the body before writing the 401 / 403 (bearer check and theCrossOriginProtectiondeny 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-lintv2.5.0: pass.Mcpsuite in WSL: 79 / 79.MCP HTTP Bearer Token Authenticationscenario is the regression test; CIWindows Buildis the proof.🤖 Generated with Claude Code