10000 Leaking STDIO client: Unclosed <MemoryObjectReceiveStream> · Issue #169 · modelcontextprotocol/python-sdk · GitHub
[go: up one dir, main page]

Skip to content
Leaking STDIO client: Unclosed <MemoryObjectReceiveStream> #169
Closed
@EItanya

Description

@EItanya

Describe the bug
A clear and concise description of what the bug is.

While running the MCP stdio client I noticed that my application was logging a warning from the anyio library, specifically related to unclosed streams.

When I dug in further I noticed that the stdio client does not close any of the streams after completing, see the following link.

This is as opposed to the sse_client which does close the streams.

Here is a slightly scrubbed more detailed error:

/home/user/src/microsoft/autogen/python/.venv/lib/python3.12/site-packages/anyio/streams/memory.py:183: ResourceWarning: Unclosed <MemoryObjectReceiveStream at 7f5394255fa0>
  warnings.warn(
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/user/src/microsoft/autogen/python/.venv/lib/python3.12/site-packages/anyio/streams/memory.py:313: ResourceWarning: Unclosed <MemoryObjectSendStream at 7f5394256270>
  warnings.warn(
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/user/src/microsoft/autogen/python/.venv/lib/python3.12/site-packages/anyio/streams/memory.py:183: ResourceWarning: Unclosed <MemoryObjectReceiveStream at 7f5394256de0>
  warnings.warn(
ResourceWarning: Enable tracemalloc to get the object allocation traceback

The context here is that I am trying to add support for MCP to microsoft/autogen but this is most likely a blocker.

To Reproduce

As mentioned, I am running this code from another project, but this should be easily reproducible with a small example, I will try to do that and update if I find anything.

Expected behavior

No warnings should be logged as these streams should be properly closed

Screenshots
If applicable, add screenshots to help explain your problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0