Reject listRoots when roots capability is unsupported - #1144
Open
zsewasdsdsd wants to merge 1 commit into
Open
zsewasdsdsd wants to merge 1 commit into
zsewasdsdsd wants to merge 1 commit into
Conversation
Author
|
I noticed after opening this PR that #1105 and #1137 also address #1067. |
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.
Reject
listRootsearly when the client has not initialized capabilities or does not advertise therootscapability, instead of sending an unsupportedroots/listrequest.Motivation and Context
Fixes #1067.
Other server-to-client operations already fail fast when the client does not advertise the required capability.
McpAsyncServerExchange.listRoots(...)did not perform the equivalent check and could send aroots/listrequest to a client that does not support roots.This change adds the missing capability validation and preserves the existing
"Roots not supported"error behavior.How Has This Been Tested?
Added regression coverage for:
listRootsbefore client capabilities are initializedlistRootswhen the client does not advertise therootscapabilityroots/listrequest is sent when either capability check failsTargeted core tests pass locally:
The existing roots capability integration tests were also verified successfully:
A full local test run still encounters two unrelated SSE/tool timeout failures:
Both failures were reproduced on a clean
upstream/mainworktree, so they are not introduced by this change.Breaking Changes
No.
The change only adds fail-fast validation for an operation that requires the client to advertise the
rootscapability. Supported clients continue through the existing request path unchanged.Types of changes
Checklist
Additional context
The implementation follows the existing capability-checking pattern used by other server-to-client operations.
The production change is limited to
McpAsyncServerExchange.listRoots(...), with corresponding regression tests inMcpAsyncServerExchangeTests.No documentation changes are required because this fixes SDK behavior to enforce the existing client capability contract.