Repository navigation
Closed
SharkyND/mcp-atlassian
#11Description
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
Reacted by Luc Cary, NAVNAV221, Orie Steele, Jarred Nicholls and Michal Augustýn
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]RuntimeError: Task group is not initialized in the simplest possible MCP server with default config[/-][+]`RuntimeError: Task group is not initialized` in the simplest possible MCP server with default config[/+]Nayjest commentedon May 29, 2025
IMHO,
soby commentedon May 29, 2025
The behavior where every following request dies after incorrect client behavior is what this PR addresses #841
The server-side session manager is being killed during unhandled exceptions, leaving the whole server unusable.
Nayjest commentedon May 30, 2025
@Sorby @ihrpr
I confirm, for code attached in the description, PR #841 fixes the issue
bhosmer-ant commentedon Jul 9, 2025
#841 just merged, thank you @soby!
feat: resolve Task group is not initialized error and update FastMCP …
feat: resolve Task group is not initialized error and update FastMCP …
feat: resolve Task group is not initialized error and update FastMCP …
feat: resolve Task group is not initialized error and update FastMCP …