fix: Remove JsonSchema and use a Map for inputSchema to support json schema specs #749
+159
−245
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.
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
$schemaspecified.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
inputSchemawithoneOfat the top level, for example:The current state
The schema is currently deserialized to a
JsonSchemarecord and ignoresoneOfat the top level. A specific fix for this issue would be to add a new field to theJsonSchemarecord foroneOf; however, this approach does not scale well if additional top-level entries (such asallOf) are needed. This PR shifts to using aMap<String, Object>to deserialize theinputSchemaNext 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
oneOfat 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
Checklist
Additional context