Description
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.