Skip to content

Write nullable tool schema fields as anyOf so single-type clients accept them - #50

Merged
stphnwlsh merged 3 commits into
mainfrom
fix/portable-nullable-schemas
Nov 6, 2026
Merged

stphnwlsh merged 3 commits into
mainfrom
fix/portable-nullable-schemas

Conversation

@stphnwlsh

@stphnwlsh stphnwlsh commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

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. PortableSchemaFilter now rewrites those fields to an anyOf of 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 WithToolsFromAssembly doesn't expose SchemaCreateOptions, so TransformSchemaNode would 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

  • Bug fix
  • New feature
  • Breaking change (the generated solution or template parameters change in a way existing users will notice)
  • Refactoring or clean-up
  • Documentation
  • Build, pipeline or dependency update

Shared layers

  • This only touches the Presentation layer of this template.
  • This touches the Application or Infrastructure layers, tests, pipeline or repository setup, so it needs to be carried across all five templates.

Checklist

  • dotnet build and dotnet test pass locally with no warnings.
  • I added or updated tests, and line coverage stays at or above 95%.
  • I updated the README or docs where behaviour changed.
  • If this changes how we do something, I updated the matching skill in .agents/skills.
  • I checked the template still installs and creates a working solution (see CONTRIBUTING.md).

@stphnwlsh stphnwlsh self-assigned this Nov 6, 2026
@github-actions github-actions Bot added the bug Something isn't working label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Build Pipeline

✅ Ready to merge. Every stage passed.

Stage Result Details
Build 🟢 Passed Version 2026.11.06.190-pr-50 · Template package 233 KB
Test 🟢 Passed 249 passed · 0 failed · 0 skipped · Template installs, builds and passes its tests
Coverage 🟢 Passed 100% (836 of 836 lines) · Needs 95%
Static Analysis 🟢 Passed No open CodeQL alerts
Dependency Review 🟢 Passed 0 vulnerable packages · 0 licence problems
Container Scan 🟢 Passed Image starts and answers · No open Trivy alerts

Commit ffc7aff · Full run

@stphnwlsh
stphnwlsh merged commit b9d5cf9 into main Nov 6, 2026
13 checks passed
@stphnwlsh
stphnwlsh deleted the fix/portable-nullable-schemas branch November 6, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant