Skip to content

Conversation

@bilaloumehdi
Copy link

@bilaloumehdi bilaloumehdi commented Jan 14, 2026

Following the Model Context Protocol specification for JSON schemas usage, the schema should, by default follow the 2020-12 spec: json-schema-2020-12 if no $schema specified.

Motivation and Context

The need for this change arose from the requirement for a tool that can handle one of two properties objects. This can be achieved by defining an inputSchema with oneOf at the top level, for example:

 inputSchema: { 
  type: object, 
  oneOf: [ 
    { properties: {}, required: ["test"] },
    { properties: {}, required: ["test", "command"] }
  ] 
}

The current state

The schema is currently deserialized to a JsonSchema record and ignores oneOf at the top level. A specific fix for this issue would be to add a new field to the JsonSchema record for oneOf; however, this approach does not scale well if additional top-level entries (such as allOf) are needed. This PR shifts to using a Map<String, Object> to deserialize the inputSchema

Next Steps and improvements

I suggest adding validation for schemas based on the schema specifications from the SDK, not only checking for serialization errors. This would help fail fast and provide feedback about any issues in the defined schemas.

How Has This Been Tested?

Existing Tests have been adjusted for these changes, and a new test has been introduced with json schemas that have oneOf at the top level to verify that deserialization do not ignore it.

Breaking Changes

Users would need to change the tool's inputSchema data type

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

@bilaloumehdi bilaloumehdi changed the title fix: remove JsonSchema an use a Map for inputSchema to support json schema specs fix: remove JsonSchema and use a Map for inputSchema to support json schema specs Jan 14, 2026
@bilaloumehdi bilaloumehdi changed the title fix: remove JsonSchema and use a Map for inputSchema to support json schema specs fix: Remove JsonSchema and use a Map for inputSchema to support json schema specs Jan 14, 2026
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.

1 participant