[Capability] Describe nullable parameters with `anyOf` instead of a `type` array?
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Start in SchemaGenerator, where a nullable parameter currently produces a type array such as ["null", "string"]; find the branch that builds that array and the tests covering nullable scalars, enums, arrays and objects. The open question is a design one, so the first deliverable is a maintainer answer on whether anyOf should be default or opt-in before any patch. Done means every nullable parameter shape is covered and existing schema tests are updated alongside the new behaviour.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
For a nullable parameter, SchemaGenerator emits a type array. With mcp/sdk 0.9.0, the ?string $company = null parameter of a tool gets:
{"type": ["null", "string"], "description": "The company of the speaker", "default": null}
MCP Inspector 2 then reports "Schema portability: 0 errors, 1 warning" and suggests {"anyOf": [{"type": "null"}, {"type": "string"}]}. That rule is a warning on purpose (schemaLint.ts, modelcontextprotocol/inspector#2286). The array form is what OpenAI recommends. It only costs portability to clients that map tool schemas onto a dialect with a single type.
What the providers document:
- OpenAI: "it is possible to emulate an optional parameter by using a union type with
null", with"type": ["string", "null"]in the examples.anyOfworks too, except at the root. - Anthropic: strict tool use supports
anyOf, and countsanyOfand type arrays the same in its limit on union types. - Gemini: the
parametersof a function declaration use "a select subset of an OpenAPI 3.0 schema object". Itstypeis a single value, withanyOf,nullableand aNULLtype. So only theanyOfform maps onto it.parametersJsonSchematakes JSON Schema instead.
Switching to anyOf would change the schema of every nullable parameter, including enums, arrays and objects, and clients that read type wouldn't find it anymore. So I'd rather ask first. Would you take a PR that emits anyOf for nullable parameters, maybe as an option of SchemaGenerator?
Found with the submit_proposal tool of the MCP server of the Symfony showcase app.
- Vorherrschende Sprache
- PHP
- Sterne
- 1.7k
- Forks
- 206
- Ø Merge
- 1 T. 17 Std.
- Gemergte PRs (30 T.)
- 102
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/php-sdk
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/php-sdk#746 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStanOffenServer
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
modelcontextprotocol/php-sdk#468 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement P3
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
modelcontextprotocol/php-sdk#733 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Server] Handle notifications/cancelled on the handshake eraEvtl. vergeben @ump45nose hat das vor 5 Tagen übernommen. Offenhelp wanted improves spec compliance Server
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 57/100
modelcontextprotocol/php-sdk#732 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Client][Server] Ship extension classes for the two authorization extensionsEvtl. vergeben @chr-hertel hat das vor 6 Tagen übernommen. Offenauth Client Server
modelcontextprotocol/php-sdk#721 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in modelcontextprotocol/php-sdk
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedEvtl. vergeben @pcvelz hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
OpenMage/magento-lts#5869 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Map Info Window ButtonsOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
OpenGIS/waymark-wp#82 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
claude
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
sprain/sprainocchio#39 ·
Maintainer antworten meist innerhalb von 1 Tag