Skip to content

Update Streamable HTTP client example to use the discover/Auto lifecycle #1164

Description

@nunoya-yuma

Summary

examples/clients/src/streamable_http.rs — the example linked from the README's Streamable HTTP section — still connects using the legacy lifecycle only (client_info.serve(transport), i.e. ClientLifecycleMode::Initialize). Now that ClientLifecycleMode::Auto reliably falls back against real deployed legacy servers (#1040, fixed by #1133), would it make sense to update this example to use Auto so it demonstrates the currently-recommended pattern (prefer server/discover, fall back to legacy initialize automatically) instead of only the legacy path?

Context

  • rmcp already fully implements ClientLifecycleMode::Discover / Auto, documented in the README's "Client lifecycle modes" section.
  • There's existing precedent for a Discover-based example (examples/clients/src/subscriptions_streamhttp.rs), but that one's primary purpose is demonstrating subscriptions, not the lifecycle itself, and it uses Discover (no fallback) rather than Auto.
  • The base streamable_http.rs example is the one most likely to be copy-pasted by newcomers as a starting point, so it seems like the highest-value place to show the recommended lifecycle mode now that Auto's fallback behavior is stable.
  • The server-side example (examples/servers/src/counter_hyper_streamable_http.rs) needs no change — the Streamable HTTP server already dispatches both initialize and server/discover generically.

Question for maintainers

Before opening a PR, wanted to check preferred direction:

  1. Update streamable_http.rs in place to use ClientLifecycleMode::Auto?
  2. Leave streamable_http.rs as the legacy/simple baseline and add a new example demonstrating Auto instead?
  3. Something else (e.g. not a priority right now)?

Happy to send a PR once there's agreement on the approach.

Other examples in the same situation

streamable_http.rs isn't the only one still on the legacy-only lifecycle — the client examples in general haven't caught up with Discover/Auto yet. At least examples/clients/src/progress_client.rs (HTTP branch) and the OAuth examples (examples/clients/src/auth/oauth_client.rs, examples/clients/src/auth/client_credentials.rs) still call .serve() too. I'd rather start with just streamable_http.rs here since it's the one most people copy first, but happy to follow up on the others if that's useful.


AI assistance: drafted with Claude Code (research + writeup); analysis and questions above are my own.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: important but non-blocking improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions