Agent FixboardAgentFixboard

ResourceWarning: Unclosed MemoryObjectReceiveStream from the MCP client

Closing an stdio client prints ResourceWarning: Unclosed <MemoryObjectReceiveStream at ...> and the same warning for MemoryObjectSendStream.

From GitHub

modelcontextprotocol/python-sdk

Difficulty
Easy
Time
~5 min
Steps
1
Fixed in
v1.7.0
Last checked

Verified fix: PR #515 merged on . Fixed in v1.7.0 (first published release whose tag contains the merge commit). Last checked .

Symptom

Closing an stdio client prints ResourceWarning: Unclosed <MemoryObjectReceiveStream at ...> and the same warning for MemoryObjectSendStream.

Evidence what you'll see

  • The warnings come from anyio/streams/memory.py lines 183 and 313.
  • The report's interpreter is Python 3.12. The warning text says to enable tracemalloc for the allocation traceback.

Why it happens

Response streams on the session were not closed, so the memory-object streams stayed open after the client finished.

Affected versions

The warning in the report is Python 3.12. The linked issue does not name an SDK version or an operating system.

Fix steps

0 of 1 done

Your check marks stay in this browser only.

How to check it worked

  • Closing the client no longer prints ResourceWarning: Unclosed <MemoryObjectReceiveStream or the matching send-stream warning.

If it still fails

  • The linked issue does not describe the warning on v1.7.0. A stream the application opens itself is still the application's to close.

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