[Server] Add ClientGateway::supportsSampling() - #418
Merged
chr-hertel merged 1 commit intoAug 15, 2026
Merged
Conversation
Sampling was the one client capability a tool could not check before asking. `supportsRoots()` and `supportsElicitation()` both read the capabilities the client advertised during the handshake; sampling is stored in that same session data but had no accessor, so a tool had to issue the request and catch the refusal.
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
August 14, 2026 23:13
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a server-side capability accessor for client sampling support, enabling tools to check the client’s advertised sampling capability before attempting sampling/createMessage requests (consistent with existing supportsRoots() / supportsElicitation() patterns).
Changes:
- Add
ClientGateway::supportsSampling()which reads the advertisedclient_capabilitiessession data. - Add unit tests covering
supportsSampling()returning true/false based on advertised capabilities. - Document the new accessor in the changelog for the next release.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Server/ClientGateway.php | Adds supportsSampling() to check for the sampling capability in session-stored client capabilities. |
| tests/Unit/Server/ClientGatewayTest.php | Adds tests verifying supportsSampling() behavior when sampling is present/absent. |
| CHANGELOG.md | Notes the addition of ClientGateway::supportsSampling() and its intended usage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sampling was the one client capability a tool could not check before asking.
supportsRoots()andsupportsElicitation()both read the capabilities the client advertised during the handshake. Sampling is stored in that same session data —ClientCapabilities::jsonSerialize()emits it alongsiderootsandelicitation— but had no accessor, so a tool had to issue the request and catch the refusal:Four lines mirroring
supportsElicitation(), plus unit tests matching the existingsupportsRootspair.🤖 Generated with Claude Code