[Capability] Describe nullable parameters with `anyOf` instead of a `type` array?
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- PHP
- Étoiles
- 1.7k
- Forks
- 206
- Merge moyen
- 1 j 17 h
- PR mergées (30 j)
- 102
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/php-sdk
-
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
modelcontextprotocol/php-sdk#746 ·
Les mainteneurs répondent en général sous 1 jour
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStanOuverteServer
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
modelcontextprotocol/php-sdk#468 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement P3
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
modelcontextprotocol/php-sdk#733 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
[Server] Handle notifications/cancelled on the handshake eraPeut-être pris @ump45nose l’a pris il y a 5 jours. Ouvertehelp wanted improves spec compliance Server
Difficulté 4/5 3-5 jours Accessibilité débutants 57/100
modelcontextprotocol/php-sdk#732 ·
Les mainteneurs répondent en général sous 1 jour
-
[Client][Server] Ship extension classes for the two authorization extensionsPeut-être pris @chr-hertel l’a pris il y a 6 jours. Ouverteauth Client Server
modelcontextprotocol/php-sdk#721 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/php-sdk
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedPeut-être pris @pcvelz l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
OpenMage/magento-lts#5869 ·
Les mainteneurs répondent en général sous 2 jours
-
Map Info Window ButtonsOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
OpenGIS/waymark-wp#82 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
claude
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
sprain/sprainocchio#39 ·
Les mainteneurs répondent en général sous 1 jour