Skip to content

Deprecate roots, sampling, and logging per SEP-2577#406

Draft
atesgoral wants to merge 1 commit into
modelcontextprotocol:mainfrom
atesgoral:issue-390-deprecations
Draft

Deprecate roots, sampling, and logging per SEP-2577#406
atesgoral wants to merge 1 commit into
modelcontextprotocol:mainfrom
atesgoral:issue-390-deprecations

Conversation

@atesgoral

@atesgoral atesgoral commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Deprecate MCP Roots, Sampling, and Logging only when protocol version 2026-07-28 is negotiated or explicitly configured.

Context

SEP-2577 deprecates Roots, Sampling, and Logging in the 2026-07-28 protocol version.

Closes #390

Changes

  • Add 2026-07-28 as an explicitly supported stable protocol version while keeping LATEST_STABLE_PROTOCOL_VERSION at 2025-11-25.
  • Add a shared protocol deprecation helper that emits Kernel.warn messages only for 2026-07-28.
  • Warn on deprecated server APIs and session-scoped calls for roots, sampling, and logging.
  • Warn client transports when deprecated roots or sampling capabilities are used with negotiated protocol version 2026-07-28.
  • Add YARD @deprecated notes and regression tests for both warning and no-warning behavior.
  • Update the changelog.

Testing

  • GEM_HOME="$PWD/.gem-test" GEM_PATH="$PWD/.gem-test:/nix/store/jh918yiwd5cs4pjg005ac32m2q7ckw3l-ruby-4.0.5/lib/ruby/gems/4.0.0" bundle exec rake test
  • GEM_HOME="$PWD/.gem-test" GEM_PATH="$PWD/.gem-test:/nix/store/jh918yiwd5cs4pjg005ac32m2q7ckw3l-ruby-4.0.5/lib/ruby/gems/4.0.0" bundle exec rake rubocop
  • git diff --check

@atesgoral atesgoral force-pushed the issue-390-deprecations branch 4 times, most recently from d8066ae to 6cabe09 Compare June 14, 2026 15:04
@atesgoral atesgoral changed the base branch from main to rubocop-cleanup-existing-offenses June 14, 2026 15:04
@atesgoral atesgoral force-pushed the rubocop-cleanup-existing-offenses branch from 0e694e3 to 460adaf Compare June 14, 2026 15:46
@atesgoral atesgoral force-pushed the issue-390-deprecations branch 2 times, most recently from 26a27ad to 9533204 Compare June 15, 2026 07:03
@atesgoral atesgoral changed the base branch from rubocop-cleanup-existing-offenses to main June 15, 2026 07:03
@atesgoral atesgoral force-pushed the issue-390-deprecations branch 4 times, most recently from 3f8cf4a to 0c7a871 Compare June 15, 2026 07:39
Warn when Roots, Sampling, or Logging APIs are used with MCP protocol version 2026-07-28, while leaving the latest stable default at 2025-11-25.

Add a shared protocol deprecation helper, YARD deprecation notes, and regression tests covering warnings for 2026-07-28 and no warnings for older protocol versions.

Closes modelcontextprotocol#390
@atesgoral atesgoral force-pushed the issue-390-deprecations branch from 0c7a871 to be41c3c Compare June 15, 2026 08:25
@atesgoral atesgoral marked this pull request as ready for review June 15, 2026 08:29
@atesgoral atesgoral requested a review from koic June 15, 2026 08:30
@atesgoral atesgoral changed the title feat: deprecate roots, sampling, and logging for 2026-07-28 feat: deprecate roots, sampling, and logging per SEP-2577 Jun 16, 2026
@atesgoral atesgoral changed the title feat: deprecate roots, sampling, and logging per SEP-2577 Deprecate roots, sampling, and logging per SEP-2577 Jun 16, 2026
@atesgoral

Copy link
Copy Markdown
Contributor Author

@koic Happy to push this through or were you thinking of doing the deprecation later?

@koic

koic commented Jun 24, 2026

Copy link
Copy Markdown
Member

I'd lean toward doing the deprecation later rather than merging the full behavior change now.

This SEP introduces a behavioral switch tied to protocol versioning, and I think that design makes sense because it preserves compatibility with existing protocol versions. However, the 2026-07-28 specification hasn't actually been released yet, and it doesn't appear to have been added to SUPPORTED_STABLE_PROTOCOL_VERSIONS in the Python or TypeScript SDKs either.

Given that, I'd prefer to wait until the 2026-07-28 release is closer before enabling the deprecation behavior.

In the meantime, it might be reasonable to land the advisory annotations on their own.

@atesgoral

Copy link
Copy Markdown
Contributor Author

@koic Sounds good! I can split out the advisory.

@atesgoral atesgoral marked this pull request as draft June 26, 2026 22:25
atesgoral added a commit to atesgoral/ruby-sdk that referenced this pull request Jun 27, 2026
Split the advisory YARD @deprecated annotations out of modelcontextprotocol#406 so the
documentation can land ahead of the 2026-07-28 protocol release.

Per maintainer feedback, this drops the protocol-version-gated runtime
Kernel.warn behavior and the new 2026-07-28 supported protocol version,
leaving only the @deprecated notes for the Roots, Sampling, and Logging
APIs deprecated by SEP-2577.

Refs modelcontextprotocol#390

Co-authored-by: 🦞 Qlaw <noreply@qlaw.quick.shopify.io>
@atesgoral

Copy link
Copy Markdown
Contributor Author

Split the advisory annotations out into #429 so they can land independently of the protocol-version behavior change. I'll keep this PR open for the 2026-07-28-gated runtime warnings and rebase it once that release is closer.

koic added a commit that referenced this pull request Jul 15, 2026
## Motivation and Context

The MCP specification defines `sampling/createMessage` as a server-to-client request
that lets a server ask the client to generate an LLM completion, so the server can leverage
the client's model access without its own API keys.
The Ruby SDK already supports the server side (sending the request) and, on the client side,
the generic server-to-client request infrastructure introduced for elicitation
(the standalone GET SSE listening stream and `on_server_request` dispatch).
This adds the client-side `sampling/createMessage` handler on top of that infrastructure.

## Changes

- Add `MCP::Client#on_sampling`, a thin wrapper that registers a `sampling/createMessage` handler
  via `transport.on_server_request`, mirroring `on_elicitation`. The handler receives the request params
  and returns a `CreateMessageResult`-shaped Hash sent back as the JSON-RPC result.
- Document client-side sampling in the README, including the `sampling` (and `sampling.tools`)
  capability declaration and the human-in-the-loop guidance from the specification.

## How Has This Been Tested?

- Unit tests for `on_sampling` covering handler registration on the transport
  and the error raised when the transport does not support server-to-client requests.
- An HTTP transport test that dispatches a `sampling/createMessage` server request delivered on
  the SSE stream and returns a `CreateMessageResult`.

## Deprecation Note

SEP-2577 deprecates sampling (along with roots and logging) starting with protocol version `2026-07-28`.
The deprecation warnings are added in #406.
Sampling remains fully supported under the current `2025-11-25` protocol version and stays available
throughout the spec's deprecation window, so the client side is implemented here for parity with
the server side and with the Python and TypeScript SDKs.

`MCP::Client#on_sampling` carries the same `@deprecated` annotation as the server-side senders
annotated in #429, tailored to the receiving side: the handler exists to interoperate with servers
that still send sampling requests during the deprecation window. The README section carries
the same note.

Ref: https://modelcontextprotocol.io/specification/2025-11-25/client/sampling
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.

SEP-2577: Deprecate Roots, Sampling, and Logging

2 participants