Skip to content

Expose negotiated Mcp-Session-Id on StreamableHttpClientTransport / RunningService #863

@He-Pin

Description

@He-Pin

The streamable-http client transport negotiates an Mcp-Session-Id during initialize and keeps it in the internal worker (src/transport/streamable_http_client.rs), but there is no public accessor to read it from the RunningService / transport handle after connecting.

Use case

Telemetry / observability: correlate a client-side invocation with the MCP session it actually used, and debug multi-call sessions. Today a client has no supported way to learn the session id its own transport negotiated.

Request

A public accessor to read the current negotiated session id post-initialize, e.g.:

impl<C> StreamableHttpClientTransport<C> {
    pub fn session_id(&self) -> Option<Arc<str>> { /* ... */ }
}

or surface it via RunningService / Peer so it is reachable from serve_client(...) results.

Current workaround

Implement a custom StreamableHttpClient and snoop the session_id parameter that rmcp passes to post_message / get_stream. This works but is indirect, only applies to custom-client setups, and misses the id on the very first (initialize) call.

Version

rmcp 1.7.0

Happy to send a PR if the maintainers agree on the shape (accessor on the transport vs. on RunningService).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions