Fix: Support additionalProperties as both boolean and schema object#73
Merged
leehack merged 2 commits intoleehack:mainfrom Feb 27, 2026
Merged
Fix: Support additionalProperties as both boolean and schema object#73leehack merged 2 commits intoleehack:mainfrom
leehack merged 2 commits intoleehack:mainfrom
Conversation
JSON Schema allows additionalProperties to be either a boolean or a schema object constraining extra properties. The parser was hardcoded to cast it as bool?, crashing when MCP servers return tool schemas with additionalProperties as an object (e.g. from z.record()).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #73 +/- ##
==========================================
+ Coverage 78.45% 78.49% +0.04%
==========================================
Files 40 40
Lines 5371 5381 +10
==========================================
+ Hits 4214 4224 +10
Misses 1157 1157
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Parse additionalProperties when decoded as Map<dynamic, dynamic> so schema objects like {} are not dropped. Add regression tests and document the 2.0.0 breaking JSON Schema API update in the changelog.
Owner
|
Thanks for the contribution @benkaiser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
JsonObject.fromJson() hard-casts additionalProperties as bool?:
In https://json-schema.org/understanding-json-schema/reference/object#additionalproperties, additionalProperties can be either a boolean (true/false) or a schema object constraining the shape of extra properties. When an MCP server returns a tool schema where additionalProperties is an object (e.g., {}), the parser throws:
This crashes tools/list parsing entirely, preventing the client from connecting to the server.
Reproduction
Any MCP server whose tools use Zod's z.record() will trigger this. For example, the
https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/debug-server from the official ext-apps repo defines:
Which produces the JSON Schema:
The
additionalProperties: {}is a valid schema object (accepts any value), but mcp_dart crashes trying to cast it asbool?.
Fix
(previously it had a TODO comment acknowledging this was missing)
Notes
This PR was AI-assisted (Claude). I did review the code myself and also validated it worked end-to-end on the stated debug server from the official examples.