Repository navigation
Conversation
Reject undeclared tool sampling and elicitation modes before invoking client handlers, and check roots and sampling before sending server requests. Fixes modelcontextprotocol#1303
Check the roots capability in the shared client handler so modern input requests respect explicitly disabled roots, as the legacy server API does. Return the standard method-not-found error on the client rejection path. Cover both protocol versions and raw legacy requests in regression tests.
This branch has not been deployed
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.
Fixes #1303.
A sampling request with tools could reach a client that advertised only basic sampling, allowing its handler to answer without the requested tools. Check declared roots, sampling, and sampling.tools before the server sends requests, and reject undeclared tool sampling and elicitation modes before invoking client handlers.
The checks also cover multi-round-trip input requests. The client rejects roots requests when roots are explicitly disabled, including the modern 2026-07-28 path. Default roots support and explicit roots with listChanged disabled continue to work. Raw legacy roots/list requests receive the standard method-not-found error (-32601), with no roots result. Existing roots fixtures declare the capability they use.
The branch includes main at
e844b98ccb9d9febfa32253ac6d0e756491c4b76through the normal merge commita58fafda3d4bc89d8e768d5e9a33ea4e15ebfb4e. This incorporates the executable-bit restoration merged in #1415 and satisfies the current up-to-date requirement. All 227 tracked file contents and the contribution patch are byte-for-byte identical to the prior PR head7f4e83f5418b97822cdf1e8a95079417bfda1296; only the conformance script's executable mode changes. No history was rewritten.Validation (macOS arm64):
go test ./...passes, along with executable-mode, shell-syntax and diff checks.7f4e83fwith complete Go 1.26.9go test -race ./...,go vet ./...,go build ./..., and complete Go 1.25.6go test ./.... Those checks were not redundantly rerun for this mode-only merge.--help/syntax checks. Earlier independent review of the unchanged Go code passed eight targeted top-level tests / 59 subtests with race detection.Full conformance scripts were not executed locally. Remote CI and maintainer approval for this new head are separate from local validation and previous-head checks.
AI assistance was used for implementation, tests, merge verification, and this description. The independent review above was automated, not human or maintainer approval.