Repository navigation
Write nullable tool schema fields as anyOf so single-type clients accept them - #50
Merged
Merged
Conversation
Contributor
Build Pipeline✅ Ready to merge. Every stage passed.
Commit |
4 of 13 tasks
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
The Inspector warns on every tool with a nullable field, because the generated schemas write
"type": ["string", "null"]. It's valid JSON Schema, but clients that map schemas onto a single-type dialect, such as Gemini's function declarations, can reject it or drop the constraint.PortableSchemaFilternow rewrites those fields to ananyOfof single types when tools are listed, in input and output schemas, and the Inspector shows no warnings on any tool.This is a temporary workaround for Gemini-style clients, and we'll remove it when they handle type arrays.
It's a list-tools filter because
WithToolsFromAssemblydoesn't exposeSchemaCreateOptions, soTransformSchemaNodewould mean replacing the SDK's tool scan with our own.The other templates don't need this. Minimal API, Web API and GraphQL don't publish MCP tool schemas.
Related issues
None.
Type of change
Shared layers
Checklist
dotnet buildanddotnet testpass locally with no warnings..agents/skills.