Repository navigation
fix(server): return HTTP 200 for handler-origin INVALID_PARAMS in modern streamable HTTP - #3864
Cemilcanoz wants to merge 1 commit into
Conversation
…ern streamable HTTP
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3855. If a maintainer assigns you to #3855, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Summary
On the 2026-07-28 modern Streamable HTTP path (
src/mcp/server/_streamable_http_modern.py),_writepreviously mapped everyJSONRPCErrorthroughERROR_CODE_HTTP_STATUSregardless of error origin. BecauseERROR_CODE_HTTP_STATUSmapsINVALID_PARAMS(-32602) to HTTP400for inbound envelope rejections, handler-origin-32602errors (such as reading an unknown resource URI viaMCPServer) were incorrectly returned with HTTP400instead of in-band HTTP200.This PR separates pre-dispatch boundary rejections from post-ladder dispatched responses:
_HANDLER_ERROR_HTTP_STATUSinsrc/mcp/server/_streamable_http_modern.pycontaining only the four spec-assigned non-200 status codes for dispatched responses (HEADER_MISMATCH->400,MISSING_REQUIRED_CLIENT_CAPABILITY->400,UNSUPPORTED_PROTOCOL_VERSION->400,METHOD_NOT_FOUND->404), leaving handler/dispatchINVALID_PARAMS(-32602) andINTERNAL_ERROR(-32603) at HTTP200._write(..., *, error_statuses=ERROR_CODE_HTTP_STATUS)so_write_rejectionand malformed-body/parse rejections retainERROR_CODE_HTTP_STATUS, while both post-dispatch JSON write paths (directjson_response=Trueand the SSE deferral fallbackif done:) passerror_statuses=_HANDLER_ERROR_HTTP_STATUS.ERROR_CODE_HTTP_STATUSdocstring insrc/mcp/shared/inbound.pyto reflect inbound/boundary rejections vs. dispatched handler errors.test_modern_tools_call_mis_shaped_envelope_skips_validation_without_an_error_logto expect HTTP200and add wire-level regression tests covering JSON mode, SSE deferral fallback, SSE streaming afterreport_progress, and pre-dispatch ladder HTTP400preservation.Fixes #3855
Testing
uv run pytest tests/server/test_streamable_http_modern.py tests/shared/test_inbound.py tests/interaction/transports/test_hosting_http_modern.py -q(269 passed)uv run ruff check src/mcp/server/_streamable_http_modern.py src/mcp/shared/inbound.py tests/server/test_streamable_http_modern.pyuv run pyright src/mcp/server/_streamable_http_modern.py src/mcp/shared/inbound.py tests/server/test_streamable_http_modern.py