{{ message }}
feat: client-side support for SEP-1577 sampling with tools#1722
Merged
maxisbey merged 4 commits intoDec 9, 2025
Merged
Conversation
maxisbey
requested changes
Dec 9, 2025
maxisbey
approved these changes
Dec 9, 2025
Hide details
View details
maxisbey
merged commit
0dedbd9
into
modelcontextprotocol:main
Dec 9, 2025
18 checks passed
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
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.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.
SEP-1577 added tool calling support to sampling (via #1594). This PR adds the necessary client-side support:
toolsortoolChoiceare provided butclientCapabilities.sampling.toolsis missing. The SDK's types already support this, butClientSessionhad no way to advertise it—servers would always see the capability as missing and error. This adds asampling_capabilitiesparameter. If not provided, the previous logic applies: the presence of asampling_callbackenables basic sampling support without tools.CreateMessageResultWithTools(which supports array content). TheSamplingFnTcallback andClientResultTypedidn't include this type, so the client's response validation would reject it before it could be sent back to the server. This addsCreateMessageResultWithToolsto both.FWIW, with these changes we have full agentic sampling wired up in a branch of FastMCP, which is extremely exciting!