Skip to content

Commit d8a416f

Browse files
committed
Remove unused StreamableHTTPTransport.get_session_id()
The method backed the get_session_id callback that streamable_http_client used to yield as the third tuple element. That callback was removed in v2, leaving the getter with no callers and no way to reach the transport instance through the public entry point. Drop it along with the stale TODO comments, and note the removal in the existing migration-guide section.
1 parent c9c431b commit d8a416f

2 files changed

Lines changed: 1 addition & 9 deletions

File tree

docs/migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ Client-side stream resumption is also unchanged: the transport reconnects a drop
21102110

21112111
The `get_session_id` callback (third element of the returned tuple) has been removed from `streamable_http_client`. The function now returns a 2-tuple `(read_stream, write_stream)` instead of a 3-tuple.
21122112

2113-
The `GetSessionIdCallback` type alias is gone as well, so `from mcp.client.streamable_http import GetSessionIdCallback` now raises `ImportError`. Drop the annotation, or inline `Callable[[], str | None]` if your own wrapper code still needs the type.
2113+
The `GetSessionIdCallback` type alias is gone as well, so `from mcp.client.streamable_http import GetSessionIdCallback` now raises `ImportError`. Drop the annotation, or inline `Callable[[], str | None]` if your own wrapper code still needs the type. The `StreamableHTTPTransport.get_session_id()` method that backed the callback is removed too.
21142114

21152115
If you need to capture the session ID (e.g., for session resumption testing), you can use httpx2 event hooks to capture it from the response headers:
21162116

src/mcp/client/streamable_http.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,15 +635,7 @@ async def terminate_session(self, client: httpx2.AsyncClient) -> None:
635635
except Exception as exc: # pragma: no cover
636636
logger.warning(f"Session termination failed: {exc}")
637637

638-
# TODO(Marcelo): Check the TODO below, and cover this with tests if necessary.
639-
def get_session_id(self) -> str | None:
640-
"""Get the current session ID."""
641-
return self.session_id # pragma: no cover
642638

643-
644-
# TODO(Marcelo): I've dropped the `get_session_id` callback because it breaks the Transport protocol. Is that needed?
645-
# It's a completely wrong abstraction, so removal is a good idea. But if we need the client to find the session ID,
646-
# we should think about a better way to do it. I believe we can achieve it with other means.
647639
@asynccontextmanager
648640
async def streamable_http_client(
649641
url: str,

0 commit comments

Comments
 (0)