Initial Checks
Description
Summary
Running the example MCP server fastmcp_quickstart.py with:
FastMCP("Demo", stateless_http=True, json_response=True)
and connecting to it using MCP Inspector triggers an exception inside the server’s message router:
ClosedResourceError
This occurs immediately after the Inspector connects.
Steps to Reproduce
- Use the example server from the Python MCP SDK:
uv run --with mcp examples/snippets/servers/fastmcp_quickstart.py - Ensure the server instance is initialized as:
FastMCP("Demo", stateless_http=True, json_response=True) - Open MCP Inspector and connect to this server.
- Observe the server error.
Environment
- MCP Python SDK version: latest
- Python version: 3.13
- OS: macOS (Apple Silicon)
- MCP Inspector version: latest
Example Code
"""FastMCP quickstart example.Run from the repository root: uv run examples/snippets/servers/fastmcp_quickstart.py"""frommcp.server.fastmcpimportFastMCP# Create an MCP servermcp=FastMCP("Demo", stateless_http=True, json_response=True)
# Add an addition tool@mcp.tool()defadd(a: int, b: int) ->int:
"""Add two numbers"""returna+b# Add a dynamic greeting resource@mcp.resource("greeting://{name}")defget_greeting(name: str) ->str:
"""Get a personalized greeting"""returnf"Hello, {name}!"# Add a prompt@mcp.prompt()defgreet_user(name: str, style: str="friendly") ->str:
"""Generate a greeting prompt"""styles= {
"friendly": "Please write a warm, friendly greeting",
"formal": "Please write a formal, professional greeting",
"casual": "Please write a casual, relaxed greeting",
}
returnf"{styles.get(style, styles['friendly'])} for someone named {name}."# Run with streamable HTTP transportif__name__=="__main__":
mcp.run(transport="streamable-http")Python & MCP Python SDK
Python: 3.13
MCP Python SDK: 1.22.1.dev4+b19fa6f
Initial Checks
Description
Summary
Running the example MCP server fastmcp_quickstart.py with:
FastMCP("Demo", stateless_http=True, json_response=True)and connecting to it using MCP Inspector triggers an exception inside the server’s message router:
ClosedResourceErrorThis occurs immediately after the Inspector connects.
Steps to Reproduce
uv run --with mcp examples/snippets/servers/fastmcp_quickstart.pyFastMCP("Demo", stateless_http=True, json_response=True)Environment
Example Code
Python & MCP Python SDK