Skip to content

Fix fundamental schema issue with required fields defined incorrectly on JsonSchemaType - #480

Merged
cliffhall merged 24 commits into
modelcontextprotocol:mainfrom
olaservo:fix-required
Jun 27, 2025
Merged

cliffhall merged 24 commits into
modelcontextprotocol:mainfrom
olaservo:fix-required

Conversation

@olaservo

@olaservo olaservo commented Jun 1, 2025

Copy link
Copy Markdown
Member

Fixes a critical schema architecture problem identified by @max-stytch where the JsonSchemaType definition violated the JSON Schema specification. JsonSchemaType incorrectly defined required as boolean on individual properties instead of string[] array on parent object schema, leading to unexpected behavior in some tools testing scenarios and several open issues.

Motivation and Context

Related observed issues:

How Has This Been Tested?

Did some basic testing but still working on more methodically testing the different scenarios. Thought it would be worth opening now for visibility's sake.

Breaking Changes

Technically yes due to internal API changes, however these all restore the correct behavior behind the scenes and don't require any changes on the user side:

  • generateDefaultValue() function signature changed to include propertyName and parentSchema parameters
  • JsonSchemaType.required changed from boolean to string[]
  • Components using prop.required logic needed updates

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

@olaservo
olaservo marked this pull request as ready for review June 5, 2025 01:35
@olaservo
olaservo requested a review from cliffhall June 5, 2025 13:32
Comment thread client/src/utils/schemaUtils.ts Resolved
Comment thread client/src/utils/schemaUtils.ts Resolved

@cliffhall cliffhall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Found a couple of places where isPropertyRequired helper can be used.

@olaservo
olaservo requested review from cliffhall and pcarleton June 12, 2025 10:59

@pcarleton pcarleton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Auth debugger changes lgtm!

@cliffhall

Copy link
Copy Markdown
Member

Do we have a goto in-project example, in the SDK or servers repo that could be used to exercise the various schema-related stuff like required fields and nested fields in input and output schemas?

@max-stytch

Copy link
Copy Markdown
Contributor

Do we have a goto in-project example, in the SDK or servers repo that could be used to exercise the various schema-related stuff like required fields and nested fields in input and output schemas?

I want to put together a little Cloudflare Worker that can take in a generic tool schema and then generate an unauthenticated MCP Server URL that we can share for testing purposes. Just haven't had the time 😢

@cliffhall

Copy link
Copy Markdown
Member

Do we have a goto in-project example, in the SDK or servers repo that could be used to exercise the various schema-related stuff like required fields and nested fields in input and output schemas?

I want to put together a little Cloudflare Worker that can take in a generic tool schema and then generate an unauthenticated MCP Server URL that we can share for testing purposes. Just haven't had the time 😢

That's cool and useful, and don't want to dissuade you from doing so. But I'm mainly looking for in-project stuff that we maintain with no external dependencies.

@cliffhall
cliffhall dismissed their stale review June 27, 2025 16:28

fixed.

@cliffhall cliffhall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good and the tests pass. Not going to hold it up for want of a server that has its own tests. This needs to go in.

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.

4 participants