Adjust the streamable-http initialization connection waiting logic
This commit is contained in:
1 parent
79400146ea
commit
09b6811391
1 file changed
+4
-2
@@ -469,7 +469,7 @@ class McpController:
|
||||
|
||||
return asgi
|
||||
|
||||
async def _wait_transport_ready(self, transport: StreamableHTTPServerTransport, timeout_seconds: float = 2.0) -> None:
|
||||
async def _wait_transport_ready(self, transport: StreamableHTTPServerTransport, timeout_seconds: float = 3.0) -> None:
|
||||
"""Wait until StreamableHTTP transport is connected and streams are initialized.
|
||||
|
||||
The underlying transport sets internal streams in connect(); POST/GET handling
|
||||
@@ -484,7 +484,9 @@ class McpController:
|
||||
# Heuristic: writer/reader set once connect() started
|
||||
has_read_writer = getattr(transport, "_read_stream_writer", None) is not None
|
||||
has_write_reader = getattr(transport, "_write_stream_reader", None) is not None
|
||||
if has_read_writer and has_write_reader:
|
||||
initialized_session_id = getattr(transport, "mcp_session_id", None)
|
||||
initialized_flag = getattr(transport, "_initialized", False) or getattr(transport, "_has_initialized", False)
|
||||
if has_read_writer and has_write_reader and (initialized_session_id is not None or initialized_flag):
|
||||
return
|
||||
if time.time() > deadline:
|
||||
raise TimeoutError("Transport not ready")
|
||||
|
||||
Reference in new issue
Block a user