Title: ClosedResourceError when using FastMCP(..., stateless_http=True, json_response=True) with MCP Inspector · Issue #1658 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: ClosedResourceError when using FastMCP(..., stateless_http=True, json_response=True) with MCP Inspector · Issue #1658 · modelcontextprotocol/python-sdk
X Title: ClosedResourceError when using FastMCP(..., stateless_http=True, json_response=True) with MCP Inspector · Issue #1658 · modelcontextprotocol/python-sdk
Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description Summary Running the ex...
Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/1658
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ClosedResourceError when using FastMCP(..., stateless_http=True, json_response=True) with MCP Inspector","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\n# Summary\n\nRunning the example MCP server fastmcp_quickstart.py with:\n`FastMCP(\"Demo\", stateless_http=True, json_response=True)\n`\nand connecting to it using MCP Inspector triggers an exception inside the server’s message router:\n`ClosedResourceError`\n\nThis occurs immediately after the Inspector connects.\n\n# Steps to Reproduce\n1. Use the example server from the Python MCP SDK:\n`uv run --with mcp examples/snippets/servers/fastmcp_quickstart.py\n`\n2. Ensure the server instance is initialized as:\n`FastMCP(\"Demo\", stateless_http=True, json_response=True)\n`\n3. Open MCP Inspector and connect to this server.\n4. Observe the server error.\n\n# Environment\n- MCP Python SDK version: latest\n- Python version: 3.13\n- OS: macOS (Apple Silicon)\n- MCP Inspector version: latest\n\n### Example Code\n\n```Python\n\"\"\"\nFastMCP quickstart example.\n\nRun from the repository root:\n uv run examples/snippets/servers/fastmcp_quickstart.py\n\"\"\"\n\nfrom mcp.server.fastmcp import FastMCP\n\n# Create an MCP server\nmcp = FastMCP(\"Demo\", stateless_http=True, json_response=True)\n\n\n# Add an addition tool\n@mcp.tool()\ndef add(a: int, b: int) -\u003e int:\n \"\"\"Add two numbers\"\"\"\n return a + b\n\n\n# Add a dynamic greeting resource\n@mcp.resource(\"greeting://{name}\")\ndef get_greeting(name: str) -\u003e str:\n \"\"\"Get a personalized greeting\"\"\"\n return f\"Hello, {name}!\"\n\n\n# Add a prompt\n@mcp.prompt()\ndef greet_user(name: str, style: str = \"friendly\") -\u003e str:\n \"\"\"Generate a greeting prompt\"\"\"\n styles = {\n \"friendly\": \"Please write a warm, friendly greeting\",\n \"formal\": \"Please write a formal, professional greeting\",\n \"casual\": \"Please write a casual, relaxed greeting\",\n }\n\n return f\"{styles.get(style, styles['friendly'])} for someone named {name}.\"\n\n\n# Run with streamable HTTP transport\nif __name__ == \"__main__\":\n mcp.run(transport=\"streamable-http\")\n```\n\n### Python \u0026 MCP Python SDK\n\n```Text\nPython: 3.13\nMCP Python SDK: 1.22.1.dev4+b19fa6f\n```","author":{"url":"https://github.com/yabramow","@type":"Person","name":"yabramow"},"datePublished":"2025-11-24T14:14:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1658/python-sdk/issues/1658"}
| 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:3b47a53d-5cbe-a15e-3901-8d5c33236287 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB36:1A7259:C95F9B:10CB608:6A5B5B05 |
| html-safe-nonce | ce40b2c726855cf937ed646dc5df3c541136384fdac15767370e7175c7335b4b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjM2OjFBNzI1OTpDOTVGOUI6MTBDQjYwODo2QTVCNUIwNSIsInZpc2l0b3JfaWQiOiI4NTk2OTc1MTg3NjQzODE2NzA5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d54424a151c9c0a65e3e9f93df577bea8b3cb8880bf98bbe5ac56c4f3ac829e5 |
| hovercard-subject-tag | issue:3659105276 |
| 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/1658/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7853347a0aad7b4f1e9ec786d3d3637693907626c42775530d6f9414c1897125/modelcontextprotocol/python-sdk/issues/1658 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7853347a0aad7b4f1e9ec786d3d3637693907626c42775530d6f9414c1897125/modelcontextprotocol/python-sdk/issues/1658 |
| og:image:alt | Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yabramow |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width