Skip to content

feat(schema): add support for JSON Schema $defs and definitions #146

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

Merged
merged 4 commits into from
Apr 23, 2025

Conversation

arcaputo3
Copy link
Contributor

Added support for $defs and definitions properties in JsonSchema record to handle JSON Schema references properly. Added tests to verify both formats work correctly.

🤖 Generated with Claude Code

Motivation and Context

This change addresses issue #145 by adding support for both $defs and definitions properties in the JsonSchema record. Previously, the schema couldn't properly handle JSON Schema references that use these properties,
which are essential for defining complex schema structures with reusable components.

How Has This Been Tested?

Added comprehensive unit tests that verify:

  • Parsing JSON Schema with $defs property
  • Parsing JSON Schema with definitions property
  • Serializing and deserializing schemas with references
  • Working with tools that use complex schemas containing references

Breaking Changes

None. This is a backward-compatible enhancement to the existing JsonSchema implementation.

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

This implementation supports both the older definitions keyword and the newer $defs keyword (introduced in JSON Schema draft 2019-09) to ensure compatibility with different JSON Schema versions.

Added support for $defs and definitions properties in JsonSchema record to handle JSON Schema references properly. Added tests to verify both formats work correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
arcaputo3 and others added 3 commits April 15, 2025 21:55
Changed the JsonSchema test approach to use serialization/deserialization round-trip validation instead of property-by-property assertions. This makes tests more maintainable and less likely to break when new properties are added.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@chemicL chemicL merged commit f70b98b into modelcontextprotocol:main Apr 23, 2025
1 check passed
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.

3 participants