[Capability] Describe nullable parameters with `anyOf` instead of a `type` array?
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 1.7k
- Fork
- 206
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 102
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/php-sdk
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
modelcontextprotocol/php-sdk#746 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStanĐang mởServer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/php-sdk#468 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement P3
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
modelcontextprotocol/php-sdk#733 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Server] Handle notifications/cancelled on the handshake eraCó thể đã có người làm @ump45nose đã nhận 5 ngày trước. Đang mởhelp wanted improves spec compliance Server
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
modelcontextprotocol/php-sdk#732 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Client][Server] Ship extension classes for the two authorization extensionsCó thể đã có người làm @chr-hertel đã nhận 6 ngày trước. Đang mởauth Client Server
modelcontextprotocol/php-sdk#721 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/php-sdk
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedCó thể đã có người làm @pcvelz đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
OpenMage/magento-lts#5869 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Map Info Window ButtonsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
OpenGIS/waymark-wp#82 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
claude
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
sprain/sprainocchio#39 ·
Maintainer thường phản hồi trong vòng 1 ngày