Open
Description
The bug
RuntimeError: Task group is not initialized. Make sure to use run().
Response code: 500 (Internal Server Error); Time: 9ms (9 ms); Content length: 1677 bytes (1.68 kB)
Reproduces in each subsequent HTTP request (the first one works fine).
It's very counterintuitive if the default configuration doesn't work out of the box.
To Reproduce
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(port=8010, debug=True, host='0.0.0.0')
@mcp.tool()
def ping(): return "pong"
mcp.run(transport="streamable-http")
###
POST http://localhost:8010/mcp/session
Content-Type: application/json
Accept: application/json, text/event-stream
{
"method": "initialize",
"jsonrpc": "2.0",
"id": 1
}
Stack trace
HTTP/1.1 500 Internal Server Error
date: Thu, 29 May 2025 14:19:00 GMT
server: uvicorn
content-length: 1677
content-type: text/plain; charset=utf-8
Traceback (most recent call last):
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\middleware\errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\middleware\exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
raise exc
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\routing.py", line 758, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\routing.py", line 778, in app
await route.handle(scope, receive, send)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\starlette\routing.py", line 487, in handle
await self.app(scope, receive, send)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\mcp\server\fastmcp\server.py", line 786, in handle_streamable_http
await self.session_manager.handle_request(scope, receive, send)
File "C:\Users\********\AppData\Roaming\Python\Python313\site-packages\mcp\server\streamable_http_manager.py", line 137, in handle_request
raise RuntimeError("Task group is not initialized. Make sure to use run().")
RuntimeError: Task group is not initialized. Make sure to use run().
Related issues
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
To triage