Skip to content

Simplify JSON schema of Optionals #846

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

natehardison
Copy link

I am using msgspec to generate JSON schemas for MCP tools, and MCP clients don't recognize the descriptions of optional fields when they are embedded in an anyOf. By special-casing the Optional[...] case of Union when generating a JSON schema to not use anyOf, MCP clients are able to recognize the "description" as well as the optionality of the field.

Wrapping Optionals into an "anyOf" isn't necessary since the "required"
and "default" fields are enough to capture optionality.
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.

1 participant