SEP-1034: Default values for Elicitation Schemas#1096
Merged
felixweinberger merged 10 commits intomodelcontextprotocol:mainfrom Nov 11, 2025
Merged
Conversation
commit: |
Contributor
|
Discussed offline. I think in this approach we're doing the "assume defaults were used" on the server side. The spec says though that "All primitive types support optional default values to provide sensible starting points. Clients that support defaults SHOULD pre-populate form fields with these values." We should likely move this to the client side instead. |
9 tasks
Merged
9 tasks
felixweinberger
requested changes
Nov 11, 2025
src/server/elicitation.test.ts
Outdated
| const client = new Client({ name: 'test-client', version: '1.0.0' }, { capabilities: { elicitation: {} } }); | ||
| const client = new Client( | ||
| { name: 'test-client', version: '1.0.0' }, | ||
| { capabilities: { elicitation: {} }, jsonSchemaValidator: validatorProvider } |
Contributor
There was a problem hiding this comment.
we don't need this anymore
src/client/index.ts
Outdated
Comment on lines
+68
to
+97
| // Handle arrays | ||
| if (schema.type === 'array' && Array.isArray(data) && schema.items) { | ||
| const itemsSchema = schema.items as JsonSchemaType | JsonSchemaType[]; | ||
| if (Array.isArray(itemsSchema)) { | ||
| for (let i = 0; i < data.length && i < itemsSchema.length; i++) { | ||
| applyElicitationDefaults(itemsSchema[i], data[i]); | ||
| } | ||
| } else { | ||
| for (const item of data) { | ||
| applyElicitationDefaults(itemsSchema, item); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Combine schemas | ||
| if (Array.isArray(schema.allOf)) { | ||
| for (const sub of schema.allOf) { | ||
| applyElicitationDefaults(sub, data); | ||
| } | ||
| } | ||
| if (Array.isArray(schema.anyOf)) { | ||
| for (const sub of schema.anyOf) { | ||
| applyElicitationDefaults(sub, data); | ||
| } | ||
| } | ||
| if (Array.isArray(schema.oneOf)) { | ||
| for (const sub of schema.oneOf) { | ||
| applyElicitationDefaults(sub, data); | ||
| } | ||
| } |
Contributor
|
Tested a checkout of this PR with conformance test created in modelcontextprotocol/conformance#19 and everything passes:
|
felixweinberger
approved these changes
Nov 11, 2025
Contributor
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.


Draft PR for implementing SEP-1034.
#1054
modelcontextprotocol/modelcontextprotocol#1034
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context