Skip to content

MCP Streamable-HTTP client errors #21

@jeffbrl

Description

@jeffbrl

Thank you for the great video and code. This is the best resource I've found on the interwebs.

I noticed this behavior on WSL2 and Windows 11. Client gets an answer along with many traceback messages.

client

python .\client-streamable-http.py
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x000001DB103C8A40>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 404, in __aiter__
    yield part
RuntimeError: async generator ignored GeneratorExit
Exception ignored in: <coroutine object HTTP11ConnectionByteStream.aclose at 0x000001DB103BACE0>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 348, in aclose
    await self._connection._response_closed()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 239, in _response_closed
    async with self._state_lock:
               ^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_synchronization.py", line 77, in __aenter__
    await self._anyio_lock.acquire()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 1808, in acquire
    await AsyncIOBackend.cancel_shielded_checkpoint()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2364, in cancel_shielded_checkpoint
    with CancelScope(shield=True):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 459, in __exit__
    raise RuntimeError(
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x000001DB103CA140>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 404, in __aiter__
    yield part
RuntimeError: async generator ignored GeneratorExit
Available tools:
  - add: Add two numbers together
Exception ignored in: <coroutine object HTTP11ConnectionByteStream.aclose at 0x000001DB11794580>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 348, in aclose
    await self._connection._response_closed()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 239, in _response_closed
    async with self._state_lock:
               ^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_synchronization.py", line 77, in __aenter__
    await self._anyio_lock.acquire()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 1808, in acquire
    await AsyncIOBackend.cancel_shielded_checkpoint()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2364, in cancel_shielded_checkpoint
    with CancelScope(shield=True):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 459, in __exit__
    raise RuntimeError(
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x000001DB1038A340>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 404, in __aiter__
    yield part
RuntimeError: async generator ignored GeneratorExit
2 + 3 = 5
Exception ignored in: <coroutine object HTTP11ConnectionByteStream.aclose at 0x000001DB103B9EE0>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 348, in aclose
    await self._connection._response_closed()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 239, in _response_closed
    async with self._state_lock:
               ^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_synchronization.py", line 77, in __aenter__
    await self._anyio_lock.acquire()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 1808, in acquire
    await AsyncIOBackend.cancel_shielded_checkpoint()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2364, in cancel_shielded_checkpoint
    with CancelScope(shield=True):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 458, in __exit__
    if current_task() is not self._host_task:
       ^^^^^^^^^^^^^^
RuntimeError: no running event loop

server

python .\server.py
Running server with Streamable HTTP transport
INFO:     Started server process [10104]
INFO:     Waiting for application startup.
[11/19/25 16:06:27] INFO     StreamableHTTP session manager started                       streamable_http_manager.py:112
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8057 (Press CTRL+C to quit)
INFO:     127.0.0.1:61023 - "POST /mcp HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:61023 - "POST /mcp/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:61026 - "POST /mcp HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:61026 - "POST /mcp/ HTTP/1.1" 202 Accepted
INFO:     127.0.0.1:61028 - "POST /mcp HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:61028 - "POST /mcp/ HTTP/1.1" 200 OK
[11/19/25 16:06:33] INFO     Processing request of type ListToolsRequest                                   server.py:619
INFO:     127.0.0.1:61030 - "POST /mcp HTTP/1.1" 307 Temporary Redirect
INFO:     127.0.0.1:61030 - "POST /mcp/ HTTP/1.1" 200 OK
                    INFO     Processing request of type CallToolRequest 

I found the redirects odd. I changed the URL in the client to include a trailing / but that introduced other traceback errors.

client

python .\client-streamable-http.py
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x000001B6E300BB40>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 404, in __aiter__
    yield part
RuntimeError: async generator ignored GeneratorExit
Exception ignored in: <coroutine object HTTP11ConnectionByteStream.aclose at 0x000001B6E303AC00>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 348, in aclose
    await self._connection._response_closed()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 239, in _response_closed
    async with self._state_lock:
               ^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_synchronization.py", line 77, in __aenter__
    await self._anyio_lock.acquire()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 1808, in acquire
    await AsyncIOBackend.cancel_shielded_checkpoint()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2364, in cancel_shielded_checkpoint
    with CancelScope(shield=True):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 459, in __exit__
    raise RuntimeError(
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x000001B6E3052A40>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 404, in __aiter__
    yield part
RuntimeError: async generator ignored GeneratorExit
Available tools:
  - add: Add two numbers together
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x000001B6E3053240>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 404, in __aiter__
    yield part
RuntimeError: async generator ignored GeneratorExit
2 + 3 = 5
Exception ignored in: <coroutine object HTTP11ConnectionByteStream.aclose at 0x000001B6E303BAE0>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 348, in aclose
    await self._connection._response_closed()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 239, in _response_closed
    async with self._state_lock:
               ^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_synchronization.py", line 77, in __aenter__
    await self._anyio_lock.acquire()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 1808, in acquire
    await AsyncIOBackend.cancel_shielded_checkpoint()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2364, in cancel_shielded_checkpoint
    with CancelScope(shield=True):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 458, in __exit__
    if current_task() is not self._host_task:
       ^^^^^^^^^^^^^^
RuntimeError: no running event loop
Exception ignored in: <coroutine object HTTP11ConnectionByteStream.aclose at 0x000001B6E305D700>
Traceback (most recent call last):
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 348, in aclose
    await self._connection._response_closed()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_async\http11.py", line 239, in _response_closed
    async with self._state_lock:
               ^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\httpcore\_synchronization.py", line 77, in __aenter__
    await self._anyio_lock.acquire()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 1808, in acquire
    await AsyncIOBackend.cancel_shielded_checkpoint()
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2364, in cancel_shielded_checkpoint
    with CancelScope(shield=True):
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documents\development\ai-cookbook\mcp\crash-course\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 458, in __exit__
    if current_task() is not self._host_task:
       ^^^^^^^^^^^^^^
RuntimeError: no running event loop

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions