fix(openapi): preserve array items for Optional[List] MCP tool params#314
Open
syf2211 wants to merge 1 commit into
Open
fix(openapi): preserve array items for Optional[List] MCP tool params#314syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
Hoist array items from anyOf/oneOf variants before clean_schema_for_display
removes composition keys, and apply schema cleaning to tool input properties
so Optional[List[X]] body/query params expose valid {type, items} schemas.
Fixes tadata-org#304
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.
Summary
Fix invalid MCP tool input schemas for
Optional[List[X]]request body and query parameters. These previously exposed{type: "array"}without anitemsfield after OpenAPIanyOfcomposition was simplified.Motivation
Fixes #304. MCP clients (VS Code Copilot, Claude Code) reject tool schemas missing
itemson array-typed parameters with errors like:tool parameters array type must have items.Changes
_hoist_array_fields_from_composition()to copyitems(andtype) fromanyOf/oneOfarray variants before composition keys are removed inclean_schema_for_display()clean_schema_for_display()to each path/query/body property when building MCP toolinputSchemaOptional[List[str]]request body conversionTests
Notes
anyOfparams are simplified to a singletype; optionality remains expressed via therequiredlist (existing behavior).oneOfarray variants are handled by the same hoist logic; onlyanyOfis covered by a dedicated unit test.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.