Reject roots listing before sending unsupported client requests - #1160
Open
karthiksenv wants to merge 1 commit into
Open
karthiksenv wants to merge 1 commit into
karthiksenv wants to merge 1 commit into
Conversation
karthiksenv
marked this pull request as ready for review
October 3, 2026 16:14
soyeladice-svg
left a comment
There was a problem hiding this comment.
AI-assisted review: the new integration assertion appears to check the wrong failure mode. listRoots() returns a Mono<ListRootsResult>, and the new guards return Mono.error(...); they do not throw synchronously when exchange.listRoots() is called. assertThatThrownBy(exchange::listRoots) only invokes the method reference and receives the Mono, so it should not observe the IllegalStateException unless the publisher is subscribed/blocked. Could this assertion consume the publisher (for example assertThatThrownBy(() -> exchange.listRoots().block())...) or use StepVerifier as the unit tests do? Otherwise the integration test does not actually pin the new fail-fast behavior.
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.
A server calling
listRootsagainst an uninitialized client or one without the roots capability currently sends an unsupportedroots/listrequest. Add the same fail-fast checks used by sampling and elicitation, returning anIllegalStateExceptionbefore contacting the session.Fixes #1067.
Both
listRootsoverloads are covered by regression tests that assert no session interaction before or after subscription. Roots support withlistChanged=falseremains valid. The shared client/server integration test now asserts the local exception and a successful tool response instead of allowing an unasserted call to pass.Validation on Windows with Temurin 17.0.19 and embedded Tomcat 11.0.2:
sendRequestwas called.mvnw.cmd -pl mcp-core -am clean testpassed all 457 core tests.testRootsWithoutCapabilitypassed with both Jackson 3 and Jackson 2 (two tests per backend).git diff --checkpassed.mvnw.cmd verify: core and both Jackson modules passed;mcp-testran 822 tests with 0 assertion failures and 12 errors caused by unavailable Docker / dependent class initialization. Conformance modules were skipped after that failure. This is not a fully green local CI run.workflow ci.yml not found on the default branch; the Ubuntu/Docker CI environment remains unverified.This is an AI-assisted contribution requiring human review. The repository's AI submission threshold is not met; the exact required disclosure is included in
disclosure.txt.