Repository navigation
Conversation
Client.elicit applied requestedSchema defaults (SEP-1034) only when the
handler's result had non-nil Content. A handler that accepts what the
form offered returns &ElicitResult{Action: "accept"}, so the server
received an accept with no values, and the schema was not checked
either.
Treat an accept without content as an empty answer: start from an empty
map, then validate and apply defaults as before. A required property
without a default is still rejected.
TestElicitationAcceptWithoutContent covers both; each case fails
without the change. docs/client.md now says an accept without content
takes every default.
Fixes modelcontextprotocol#1330
Signed-off-by: Charlie Holland <charlie@hollandtech.net>
Comment on lines
+778
to
+784
| // An accept without content answers nothing, so every field takes its | ||
| // default. | ||
| if res.Action == "accept" && schema != nil && res.Content == nil { | ||
| res.Content = map[string]any{} | ||
| } | ||
| // Validate elicitation result content against requested schema. | ||
| if res.Action == "accept" && schema != nil && res.Content != nil { | ||
| if res.Action == "accept" && schema != nil { |
Contributor
There was a problem hiding this comment.
Suggested change
| // An accept without content answers nothing, so every field takes its | |
| // default. | |
| if res.Action == "accept" && schema != nil && res.Content == nil { | |
| res.Content = map[string]any{} | |
| } | |
| // Validate elicitation result content against requested schema. | |
| if res.Action == "accept" && schema != nil && res.Content != nil { | |
| if res.Action == "accept" && schema != nil { | |
| // Validate elicitation result content against requested schema. | |
| if res.Action == "accept" && schema != nil { | |
| // An accept without content answers nothing, so every field takes its | |
| // default. | |
| if res.Content == nil { | |
| res.Content = map[string]any{} | |
| } |
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.
Client.elicitappliedrequestedSchemadefaults (SEP-1034) only when the handler's result had non-nilContent. A handler that accepts the form as offered returns&ElicitResult{Action: "accept"}, so the server received an accept with no values, and the result was never checked against the schema.This change treats an accept without content as an empty answer: the client starts from an empty map, then validates and applies defaults as before. This is the first point of #1330. The second point, defaults for
Requiredfields, is a behavior change documented indocs/client.mdand is left for a separate discussion.ServerSession.Elicitis unchanged.Behavior change: a handler that returns a bare
{Action: "accept"}against a schema with a required field that has no default now gets anInvalidParamserror. Before, it sent an accept with no content, which didn't satisfy the schema.TestElicitationAcceptWithoutContentcovers both cases (defaults applied; required field without a default rejected with the schema validation error). Each case fails without the change.docs/client.md(generated frominternal/docs/client.src.md) now describes a bare accept.Fixes #1330
Developed with AI assistance (Claude Code); I've reviewed the change and can explain it.