-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.
Description
Description
We are using FastMCP v2.8.1 and seeing the same as modelcontextprotocol/python-sdk#883
Here is my error:
ERROR: Exception in ASGI application
+ Exception Group Traceback (most recent call last):
| File "/app/.venv/lib/python3.13/site-packages/starlette/_utils.py", line 77, in collapse_excgroups
| yield
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 183, in __call__
| async with anyio.create_task_group() as task_group:
| ~~~~~~~~~~~~~~~~~~~~~~~^^
| File "/app/.venv/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
| raise BaseExceptionGroup(
| "unhandled errors in a TaskGroup", self._exceptions
| ) from None
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/app/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
| result = await app( # type: ignore[func-returns-value]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| self.scope, self.receive, self.send
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| )
| ^
| File "/app/.venv/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
| return await self.app(scope, receive, send)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/app/.venv/lib/python3.13/site-packages/starlette/applications.py", line 113, in __call__
| await self.middleware_stack(scope, receive, send)
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 187, in __call__
| raise exc
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 165, in __call__
| await self.app(scope, receive, _send)
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 182, in __call__
| with recv_stream, send_stream, collapse_excgroups():
| ~~~~~~~~~~~~~~~~~~^^
| File "/usr/local/lib/python3.13/contextlib.py", line 162, in __exit__
| self.gen.throw(value)
| ~~~~~~~~~~~~~~^^^^^^^
| File "/app/.venv/lib/python3.13/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
| raise exc
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 185, in __call__
| await response(scope, wrapped_receive, send)
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 223, in __call__
| async for chunk in self.body_iterator:
| ...<5 lines>...
| await send({"type": "http.response.body", "body": chunk, "more_body": True})
| File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 169, in body_stream
| assert message["type"] == "http.response.body", f"Unexpected message: {message}"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| AssertionError: Unexpected message: {'type': 'http.response.start', 'status': 200, 'headers': [(b'content-length', b'0')]}
+------------------------------------
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.scope, self.receive, self.send
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/app/.venv/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.13/site-packages/starlette/applications.py", line 113, in __call__
await self.middleware_stack(scope, receive, send)
File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 182, in __call__
with recv_stream, send_stream, collapse_excgroups():
~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/contextlib.py", line 162, in __exit__
self.gen.throw(value)
~~~~~~~~~~~~~~^^^^^^^
File "/app/.venv/lib/python3.13/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
raise exc
File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 185, in __call__
await response(scope, wrapped_receive, send)
File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 223, in __call__
async for chunk in self.body_iterator:
...<5 lines>...
await send({"type": "http.response.body", "body": chunk, "more_body": True})
File "/app/.venv/lib/python3.13/site-packages/starlette/middleware/base.py", line 169, in body_stream
assert message["type"] == "http.response.body", f"Unexpected message: {message}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Unexpected message: {'type': 'http.response.start', 'status': 200, 'headers': [(b'content-length', b'0')]}I just wanted to port the issue over here since it appears to have the same root cause. Note, I did not test the example code, it came from the upstream issue; if it's not enough I'm already working on a separate MRE
Example Code
class CustomHeaderMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
return await call_next(request)
middleware = [
Middleware(CustomHeaderMiddleware)
]
app = Starlette(middleware=middleware)
app.mount("/", mcp_server.sse_app())
def main():
uvicorn.run(
app="atlantis_mcp_server:app",
host="0.0.0.0",
port=8000,
workers=1,
log_level="info"
)
__all__ = ["main"]Version Information
FastMCP version: 2.8.1
MCP version: 1.9.4
Python version: 3.13.5
Platform: macOS-15.5-arm64-arm-64bit-Mach-O
FastMCP root path: /Users/jonzeolla/.venv/lib/python3.13…
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.Something isn't working. Reports of errors, unexpected behavior, or broken functionality.