Skip to content

mcp: apply elicitation defaults when an accept has no content - #1496

Open
chaholl wants to merge 1 commit into
modelcontextprotocol:mainfrom
chaholl:claude/go-sdk-issue-1330-bw93cd
Open

chaholl wants to merge 1 commit into
modelcontextprotocol:mainfrom
chaholl:claude/go-sdk-issue-1330-bw93cd

Conversation

@chaholl

@chaholl chaholl commented Nov 4, 2026

Copy link
Copy Markdown

Client.elicit applied requestedSchema defaults (SEP-1034) only when the handler's result had non-nil Content. 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 Required fields, is a behavior change documented in docs/client.md and is left for a separate discussion. ServerSession.Elicit is unchanged.

Behavior change: a handler that returns a bare {Action: "accept"} against a schema with a required field that has no default now gets an InvalidParams error. Before, it sent an accept with no content, which didn't satisfy the schema.

TestElicitationAcceptWithoutContent covers 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 from internal/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.

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 thread mcp/client.go
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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: client skips elicitation schema defaults when the handler returns no content, and validates before applying them

2 participants