Title: `RuntimeError: Task group is not initialized` in the simplest possible MCP server with default config · Issue #838 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: `RuntimeError: Task group is not initialized` in the simplest possible MCP server with default config · Issue #838 · modelcontextprotocol/python-sdk
X Title: `RuntimeError: Task group is not initialized` in the simplest possible MCP server with default config · Issue #838 · modelcontextprotocol/python-sdk
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 wor...
Open Graph 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 su...
X 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 su...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/838
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`RuntimeError: Task group is not initialized` in the simplest possible MCP server with default config","articleBody":"## The bug\n```\nRuntimeError: Task group is not initialized. Make sure to use run().\nResponse code: 500 (Internal Server Error); Time: 9ms (9 ms); Content length: 1677 bytes (1.68 kB)\n```\nReproduces in each subsequent HTTP request (the first one works fine).\n\n**It's very counterintuitive if the default configuration doesn't work out of the box.**\n\n## To Reproduce\n\n```python\nfrom mcp.server.fastmcp import FastMCP\nmcp = FastMCP(port=8010, debug=True, host='0.0.0.0')\n@mcp.tool()\ndef ping(): return \"pong\"\nmcp.run(transport=\"streamable-http\")\n```\n\n```http\n###\nPOST http://localhost:8010/mcp/session\nContent-Type: application/json\nAccept: application/json, text/event-stream\n\n{\n \"method\": \"initialize\",\n \"jsonrpc\": \"2.0\",\n \"id\": 1\n}\n```\n\n## Stack trace\n\n```\nHTTP/1.1 500 Internal Server Error\ndate: Thu, 29 May 2025 14:19:00 GMT\nserver: uvicorn\ncontent-length: 1677\ncontent-type: text/plain; charset=utf-8\n\nTraceback (most recent call last):\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\middleware\\errors.py\", line 164, in __call__\n await self.app(scope, receive, _send)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\middleware\\exceptions.py\", line 62, in __call__\n await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\_exception_handler.py\", line 64, in wrapped_app\n raise exc\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\_exception_handler.py\", line 53, in wrapped_app\n await app(scope, receive, sender)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\routing.py\", line 758, in __call__\n await self.middleware_stack(scope, receive, send)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\routing.py\", line 778, in app\n await route.handle(scope, receive, send)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\starlette\\routing.py\", line 487, in handle\n await self.app(scope, receive, send)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\mcp\\server\\fastmcp\\server.py\", line 786, in handle_streamable_http\n await self.session_manager.handle_request(scope, receive, send)\n File \"C:\\Users\\********\\AppData\\Roaming\\Python\\Python313\\site-packages\\mcp\\server\\streamable_http_manager.py\", line 137, in handle_request\n raise RuntimeError(\"Task group is not initialized. Make sure to use run().\")\nRuntimeError: Task group is not initialized. Make sure to use run().\n```\n\n## Related issues\n\nhttps://github.com/modelcontextprotocol/python-sdk/issues/713","author":{"url":"https://github.com/Nayjest","@type":"Person","name":"Nayjest"},"datePublished":"2025-05-29T14:26:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/838/python-sdk/issues/838"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c43566a4-8ac2-458b-345b-39d9d843e575 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7DA:1E5C2:1D2114:28E553:6A60515E |
| html-safe-nonce | 499160e5c035b5efcba53ec0d640bedf46738555c4a69fc8f5cecb02e62d827b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0RBOjFFNUMyOjFEMjExNDoyOEU1NTM6NkE2MDUxNUUiLCJ2aXNpdG9yX2lkIjoiNjIzOTQwNzI5NDU3OTIzMzExOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ffc9f077d4750b764d0e510a4736b06d9ea47b1a6cb37534685435a8e8081e8 |
| hovercard-subject-tag | issue:3100524786 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/838/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b6fcef788a70b3929b28cc32682d414259f93e58366ff9f3d59023e8f7d3180/modelcontextprotocol/python-sdk/issues/838 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b6fcef788a70b3929b28cc32682d414259f93e58366ff9f3d59023e8f7d3180/modelcontextprotocol/python-sdk/issues/838 |
| og:image:alt | 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 su... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Nayjest |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60da8c2a42fa2bbf5f7567474990ec467836a84444262a58e200fa91b7f3d2d0 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9824515e740d83d5eb82168a089b806ab0fe04a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width