Skip to content

Remove Server#create_sampling_message direct call#311

Open
koic wants to merge 1 commit intomodelcontextprotocol:mainfrom
koic:remove_server_sampling_direct_call
Open

Remove Server#create_sampling_message direct call#311
koic wants to merge 1 commit intomodelcontextprotocol:mainfrom
koic:remove_server_sampling_direct_call

Conversation

@koic
Copy link
Copy Markdown
Member

@koic koic commented Apr 12, 2026

Motivation and Context

Sampling is a one-to-one request/response interaction between a server and a specific client. Server#create_sampling_message does not scope requests to a specific session, which could lead to unintended broadcasts on multi-client transports. ServerSession#create_sampling_message should be used instead, as it routes the request to the correct client session.

This aligns with the Python SDK, which also exposes sampling only at the session level.

How Has This Been Tested?

Existing tests updated to call ServerSession#create_sampling_message instead of Server#create_sampling_message. All tests pass (rake test), RuboCop is clean, and conformance tests pass.

Breaking Changes

Server#create_sampling_message is removed without a deprecation warning. The sampling feature was released recently and the method was not intended to be the primary API for this feature.

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

## Motivation and Context

Sampling is a one-to-one request/response interaction between a server and a specific client.
`Server#create_sampling_message` does not scope requests to a specific session, which could
lead to unintended broadcasts on multi-client transports. `ServerSession#create_sampling_message`
should be used instead, as it routes the request to the correct client session.

This aligns with the Python SDK, which also exposes sampling only at the session level.

## How Has This Been Tested?

Existing tests updated to call `ServerSession#create_sampling_message` instead of
`Server#create_sampling_message`. All tests pass (`rake test`), RuboCop is clean,
and conformance tests pass.

## Breaking Changes

`Server#create_sampling_message` is removed without a deprecation warning.
The sampling feature was released recently and the method was not intended
to be the primary API for this feature.
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