Skip to content

Preserve nullable types in MCP tool schemas - #283

Open
Shy7777 wants to merge 1 commit into
Eigenwise:mainfrom
Shy7777:fix/mcp-nullable-types
Open

Preserve nullable types in MCP tool schemas#283
Shy7777 wants to merge 1 commit into
Eigenwise:mainfrom
Shy7777:fix/mcp-nullable-types

Conversation

@Shy7777

@Shy7777 Shy7777 commented Sep 12, 2026

Copy link
Copy Markdown

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 equivalent anyOf form has a related problem: null falls back to Any, so unrelated values are accepted.

This maps null to NoneType and 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.

Copilot AI lite review requested due to automatic review settings September 12, 2026 04:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants