Preserve nullable types in MCP tool schemas - #283
Open
Shy7777 wants to merge 1 commit into
Open
Conversation
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.
An MCP tool with a field such as
{"type": ["string", "null"]}currently disappears from discovery: the schema converter tries to use the list as a dictionary key, and the factory catches the resulting error and skips the tool. This affects both input and typed output schemas. The equivalentanyOfform has a related problem:nullfalls back toAny, so unrelated values are accepted.This maps
nulltoNoneTypeand resolves type arrays as unions, as described in the JSON Schema type reference. Array items use the same conversion path, so nullable items and nested array types are retained. Required fields remain required, with their defaults and descriptions preserved.Fourteen regression cases fail before the fix. The full core test command now passes with 353 passed and 3 skipped; the skips are existing live MiniMax tests. Tests cover nullable input/output tool discovery, requiredness, defaults, wrong-type rejection, and nested arrays without making provider calls. The repository-wide Black and Flake8 checks pass, along with the pre-commit checks for the changed files.