Let the typed elicitation overload reach the interceptor - #1853
Open
ConnorMoss02 wants to merge 1 commit into
Open
Let the typed elicitation overload reach the interceptor#1853ConnorMoss02 wants to merge 1 commit into
ConnorMoss02 wants to merge 1 commit into
Conversation
ElicitAsync<T> called ThrowIfElicitationUnsupported before delegating to the untyped overload, which skips that check when an outgoing-request interceptor is installed because the interceptor delivers the request instead. The typed overload therefore threw where the untyped one succeeded, so a server eliciting from a background task could use one API and not the other. Leave the check to the untyped overload, which already runs it on the path that needs it. SampleAsync and RequestRootsAsync already order it this way; this was the only outlier. Add the first test to exercise WithOutgoingRequestInterceptor at all.
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.
Closes #1854
Problem
ElicitAsync<T>runs the capability check itself before delegating:The untyped overload it delegates to skips that check when an outgoing-request interceptor is installed, and says so (
McpServer.Methods.cs:348-351):So with an interceptor installed and a client that does not advertise elicitation, the untyped overload succeeds and the typed one throws
Elicitation is not supported in stateless mode. The interceptor is how the Tasks package delivers outgoing requests, so a server eliciting from a background task can use one API and not the other.SampleAsync(:96-107) andRequestRootsAsync(:302-312) both check the interceptor first. This was the only overload that did not.Change
Remove the early check and let the untyped overload run it, with a comment recording why it belongs there. One line of behavior.
Test
ElicitAsync_Generic_Should_Use_Interceptor_When_Client_Does_Not_Support_Elicitationinitializes with emptyClientCapabilities, installs an interceptor that returns an acceptedElicitResult, and asserts the typed overload reaches the interceptor and deserializes the payload.This is the first test in the repo to exercise
WithOutgoingRequestInterceptor.grepfinds no other reference undertests/.Verified red then green: the test fails on unmodified
mainand passes with the change.Validation
2360 passed, 2 failed, 3 skipped. The two failures areDockerEverythingServerTests.Sampling_Sse_EverythingServerandConnectAndReceiveMessage_EverythingServerWithSse, which fail the same way on an unmodified clean checkout without a Docker daemon. Baseline before this change was 2359 passed / 2 failed, so this adds one passing test and changes nothing else.Note on scope
WithOutgoingRequestInterceptorisMCPEXP002, so this is an inconsistency between two overloads of an experimental seam rather than a break in stable API. The test suppresses the diagnostic with a reason comment, matching the existing pattern inMcpServerTaskTestsandTaskCallToolFilterCompositionTests.Note
This pull request was prepared with AI assistance.