Skip to content

Commit ce03a03

Browse files
committed
fix(client): reinitialize expired streamable HTTP sessions
1 parent 52ad0a8 commit ce03a03

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/mcp/client/_transport.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from contextlib import AbstractAsyncContextManager
6-
from typing import Protocol
6+
from typing import Final, Protocol
77

88
from mcp.shared._stream_protocols import ReadStream, WriteStream
99
from mcp.shared.message import SessionMessage
@@ -12,6 +12,11 @@
1212

1313
TransportStreams = tuple[ReadStream[SessionMessage | Exception], WriteStream[SessionMessage]]
1414

15+
# SDK-private signal emitted by StreamableHTTPTransport after a request with an
16+
# established MCP session receives HTTP 404. It never crosses the wire.
17+
SESSION_EXPIRED: Final = -32003
18+
SESSION_EXPIRED_MARKER: Final = "mcp.client.session_expired"
19+
1520

1621
class Transport(AbstractAsyncContextManager[TransportStreams], Protocol):
1722
"""Protocol for MCP transports.

0 commit comments

Comments
 (0)