Drop uvicorn from test suite
We should be using httpx.AsyncClient with httpx.ASGITransport.
could you pls give more insights on this , happy to work on this
The idea is to not have Uvicorn running on the test suite, it's to use the ASGITransport to "run as the server".
Ok got it thanks , it needs to be updated for all the applicable tests under folder named -> 'tests'. Could you please assign this task
@jeevakumar-m Any success with this issue?
I'm running into ResourceWarning: Unclosed <MemoryObjectReceiveStream at xxxxxx> when testing test_streamablehttp_client-like functions in test_streamable_http.py with ASGITransport.
For the tests, I passed a client factory which returns httpx.AsyncClient wired with httpx.ASGITransport to streamablehttp_client (referenced below).
https://github.com/modelcontextprotocol/python-sdk/blob/679b22970e12b8eec3897108ac7d6b0624809b9e/src/mcp/client/streamable_http.py#L441-L449
Hello. I am a new contributor and picked up this issue as my first task.
I started implementing it and wanted to check if I have the right understanding. ASGITransport works well for normal request/response tests, but it does not support streaming. It buffers until the application completes, so SSE, WebSockets, and other long-lived streams do not behave correctly. MCP relies on SSE and web socket functionality for testing, so those tests still appear to require a real server such as uvicorn.
I also tried StreamingASGITransport in src/mcp/server/streaming_asgi_transport.py here for SSE tests, but I encountered resource and event loop cleanup issues (for example, resource busy and event loop closed errors). It does not currently seem like a drop-in replacement for uvicorn for streaming tests.
Before I continue, can you confirm whether the intended approach for this issue is:
- Use ASGITransport for standard HTTP tests
- Keep uvicorn for SSE and streaming tests
- Document why both are required and reference the upstream issues
I wanted to check that I am aligned with the intended direction before submitting a PR. Thank you.
We should implement the transport on our side, if it can't handle stream. Uvicorn should be dropped from the test suite. Maybe a good first step is to actually implement that transport.
@Kludex Ok noted on this, thanks. I'll look into how to improve StreamingASGITransport so that it can be used as a drop in replacement for uvicorn in streaming tests.