Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

olaservo
Copy link
Member

@olaservo olaservo commented Jun 1, 2025

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 on lines +98 to +99
const isRequired =
parentSchema?.required?.includes(propertyName || "") ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use the isPropertyRequired helper here and avoid the duplication.

Suggested change
const isRequired =
parentSchema?.required?.includes(propertyName || "") ?? false;
const isRequired = isPropertyRequired(propertyName, parentSchema);

Comment on lines +117 to +123
const isPropertyRequired = schema.required?.includes(key) ?? false;
if (isPropertyRequired) {
const value = generateDefaultValue(prop, key, schema);
if (value !== undefined) {
obj[key] = value;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isPropertyRequired = schema.required?.includes(key) ?? false;
if (isPropertyRequired) {
const value = generateDefaultValue(prop, key, schema);
if (value !== undefined) {
obj[key] = value;
}
}
if (isPropertyRequired(key, schema)) {
const value = generateDefaultValue(prop, key, schema);
if (value !== undefined) {
obj[key] = value;
}
}

Copy link
Contributor

@cliffhall cliffhall left a comment

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.

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.

2 participants