Skip to content

[Client] Expose the Mcp-Session-Id from HttpTransport for cross-request session resumption #496

Description

@RobLoach

Getting the session ID can be helpful to allow resuming previous sessions.

HttpTransport captures the Mcp-Session-Id response header into a private property and there is no public accessor on the transport or on Client:

https://github.com/modelcontextprotocol/php-sdk/blob/v0.8.1/src/Client/Transport/HttpTransport.php#L41

While the BaseTransport has a protected $sessionId, the HttpTransport rescopes it to private.

Proposal

Add a public getter, e.g.:

public function getSessionId(): ?string;

on HttpTransport (optionally surfaced via Client), so callers can persist the ID after a request and feed it back via the existing $headers mechanism in a later PHP request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions