Skip to content

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