Skip to content

Remove unused StreamableHTTPTransport.get_session_id() - #3205

Merged
maxisbey merged 1 commit into
mainfrom
remove-client-get-session-id
Jul 28, 2026
Merged

Remove unused StreamableHTTPTransport.get_session_id()#3205
maxisbey merged 1 commit into
mainfrom
remove-client-get-session-id

Conversation

@maxisbey

Copy link
Copy Markdown
Contributor

Removes the dead StreamableHTTPTransport.get_session_id() method from the client streamable HTTP transport, along with the two stale TODO(Marcelo) comments about it.

Motivation and Context

The method existed to back the get_session_id callback that v1's streamable_http_client yielded as the third tuple element. That callback was already removed on main (documented in docs/migration.md), which left the getter with no callers in src/, tests/, or examples/ (it was # pragma: no cover) and no way to reach a transport instance through the public entry point anyway — streamable_http_client yields only the two streams.

The session_id attribute the getter wrapped is unchanged; it's the transport's own working state (header stamping, GET/DELETE gating, terminate-on-close).

How Has This Been Tested?

Existing client streamable HTTP tests pass. Also drove streamable_http_client end-to-end against a real MCPServer streamable HTTP app on a local port (initialize → tool call → DELETE on close) to confirm the client path is unaffected.

Breaking Changes

StreamableHTTPTransport.get_session_id() no longer exists. This was public in v1, so the removal is added to the existing "get_session_id callback removed from streamable_http_client" section of docs/migration.md, which already points users at httpx2 event hooks for capturing the session ID.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

No pragmas or type-ignores added; the removal drops one # pragma: no cover.

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.
@maxisbey
maxisbey marked this pull request as ready for review July 28, 2026 12:50
@github-actions

Copy link
Copy Markdown
Contributor

📚 Documentation preview

Preview https://pr-3205.mcp-python-docs.pages.dev
Deployment https://64a5ab88.mcp-python-docs.pages.dev
Commit d8a416f
Triggered by @maxisbey
Updated 2026-07-28 12:51:43 UTC

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — straightforward dead-code removal with the required migration-guide note.

What was reviewed:

  • Confirmed get_session_id() has no callers anywhere in src/, tests/, or examples/ — only doc mentions and the unrelated server-side private _get_session_id() remain.
  • Checked that the session_id attribute the getter wrapped is untouched — header stamping, GET/DELETE gating, and terminate-on-close all read the attribute directly.
  • Verified the migration note was added to the existing get_session_id callback section rather than a new standalone one, per the repo's guidelines.
Extended reasoning...

Overview

The PR deletes the dead StreamableHTTPTransport.get_session_id() method (four lines, previously # pragma: no cover) and two stale TODO(Marcelo) comments from src/mcp/client/streamable_http.py, and appends one sentence to the existing get_session_id callback section of docs/migration.md. No behavior changes: the session_id attribute itself is untouched and continues to drive header stamping, GET/DELETE gating, and terminate-on-close.

Security risks

None. The change removes a trivial read-only getter; it does not touch auth, headers, session validation, or any request/response handling logic.

Level of scrutiny

Low. This is a mechanical dead-code removal. The only real question is whether anything still calls the method — a repo-wide grep confirms zero callers in src/, tests/, or examples/; the only get_session_id hits outside docs are the server-side private _get_session_id() in src/mcp/server/streamable_http.py, which is a different symbol entirely. The public entry point streamable_http_client never exposed a transport instance on main (it yields only the two streams), so the method was unreachable through the public API anyway.

Other factors

The bug hunting system found no issues. The PR follows the repo's breaking-change policy: the removal is documented in docs/migration.md, grouped into the existing get_session_id callback section rather than a new standalone one, as AGENTS.md requires. The removal also drops a # pragma: no cover rather than adding one, in line with the coverage guidelines. main is the V2 rework branch where intentional breaking removals like this are expected.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@maxisbey
maxisbey merged commit af06330 into main Jul 28, 2026
39 checks passed
@maxisbey
maxisbey deleted the remove-client-get-session-id branch July 28, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant