-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
needs confirmationNeeds confirmation that the PR is actually required or needed.Needs confirmation that the PR is actually required or needed.questionFurther information is requestedFurther information is requested
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
The StreamableHTTPTransport._handle_post_request() method returns immediately when receiving a 202 Accepted HTTP status code without making the required GET request to retrieve the SSE stream, causing session.list_tools() and other JSON-RPC requests to timeout indefinitely.
Steps to Reproduce
- Connect to an MCP server that returns
202 Acceptedfor POST requests - Call
session.list_tools()or any other JSON-RPC request method - Observe that the call times out after the configured timeout period
Example Code
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def test():
server_url = "https://example.com/mcp" # Server that returns 202 Accepted
async with streamablehttp_client(server_url) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
# This will timeout if server returns 202 Accepted
tools = await asyncio.wait_for(session.list_tools(), timeout=30.0)
asyncio.run(test())Python & MCP Python SDK
Python: 3.12.x
SDK: 1.22.0
Metadata
Metadata
Assignees
Labels
needs confirmationNeeds confirmation that the PR is actually required or needed.Needs confirmation that the PR is actually required or needed.questionFurther information is requestedFurther information is requested