Skip to content

Conversation

@KKonstantinov
Copy link
Contributor

Draft PR for implementing SEP-1034.

#1054
modelcontextprotocol/modelcontextprotocol#1034

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk@1096

commit: c90f256

@felixweinberger
Copy link
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."

See https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1035/files

We should likely move this to the client side instead.

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 }
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need this anymore

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);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@felixweinberger
Copy link
Contributor

felixweinberger commented Nov 11, 2025

Tested a checkout of this PR with conformance test created in modelcontextprotocol/conformance#19 and everything passes:

CleanShot 2025-11-11 at 13 50 10

@felixweinberger
Copy link
Contributor

Ran tests after last changes:
CleanShot 2025-11-11 at 14 11 05

@felixweinberger felixweinberger merged commit ce420f8 into modelcontextprotocol:main Nov 11, 2025
6 checks passed
@felixweinberger felixweinberger changed the title DRAFT: SEP-1034: Default values for Elicitation Schemas SEP-1034: Default values for Elicitation Schemas Nov 11, 2025
@felixweinberger felixweinberger linked an issue Nov 11, 2025 that may be closed by this pull request
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.

Implement SEP-1034: Default Values for Elicitation Schemas

2 participants