AgentFixboard

ClosedResourceError in server logs when a request fails validation early

An MCP server running Streamable HTTP logs ClosedResourceError when a request is rejected quickly, for example because of a wrong Accept header.

From GitHub

modelcontextprotocol/python-sdk

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
v1.23.2
Last checked

Verified fix: PR #1384 merged on . Fixed in v1.23.2 (first release published after the merge). Last checked .

Symptom

An MCP server running Streamable HTTP logs ClosedResourceError when a request is rejected quickly, for example because of a wrong Accept header.

Evidence what you'll see

  • Started from v1.12.0
  • Reproducible by POSTing without application/json or text/event-stream in the Accept header
  • Error raised from receive_nowait() in the message router

Cause

The transport is terminated right after an early-return request while the message router task is still yielding; when it resumes it reads a closed stream.

Fix steps

0 of 2 done

Your check marks stay in this browser only.

Verify the fix worked

  • Send a POST with a bad Accept header and confirm the server returns the error response without logging ClosedResourceError.

Sources and credit

Summarized in our own words from these public reports. Credit goes to their authors.

Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change

Hit an error we don't cover? Submit it