[Schema] Stop rejecting elicitation schemas the specification allows - #437
Conversation
The specification makes `title` optional on every elicitation schema definition. AbstractSchemaDefinition required it, so a client reading a conformant server's elicitation/create refused the request - and a server building one could not omit it either. `title` is now nullable on all seven definitions, omitted from the serialized form when absent, and rejected only when present and not a string.
There was a problem hiding this comment.
Pull request overview
Updates the SDK’s elicitation schema definitions to align with the specification by making title optional across all supported schema types, ensuring conformant server payloads can be parsed and that serialization omits title when absent.
Changes:
- Make
titlenullable across all seven elicitation schema definition classes and adjustfromArray()to accept missingtitle. - Update serialization to omit
titlewhen it’snull(notably viaAbstractSchemaDefinition::buildBaseJson()and a custom update inEnumSchemaDefinition). - Refresh unit tests to cover “missing title is accepted” and “non-string title is rejected”, and document the change in the changelog.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Schema/Elicitation/TitledMultiSelectEnumSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| tests/Unit/Schema/Elicitation/TitledEnumSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| tests/Unit/Schema/Elicitation/StringSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| tests/Unit/Schema/Elicitation/NumberSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| tests/Unit/Schema/Elicitation/MultiSelectEnumSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| tests/Unit/Schema/Elicitation/EnumSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| tests/Unit/Schema/Elicitation/BooleanSchemaDefinitionTest.php | Adds coverage for missing title being accepted and non-string title being rejected. |
| src/Schema/Elicitation/TitledMultiSelectEnumSchemaDefinition.php | Makes title nullable and optional in fromArray() for titled multi-select enums. |
| src/Schema/Elicitation/TitledEnumSchemaDefinition.php | Makes title nullable and optional in fromArray() for titled enums. |
| src/Schema/Elicitation/StringSchemaDefinition.php | Makes title nullable/optional and relies on base JSON builder to omit absent title. |
| src/Schema/Elicitation/NumberSchemaDefinition.php | Makes title nullable/optional and relies on base JSON builder to omit absent title. |
| src/Schema/Elicitation/MultiSelectEnumSchemaDefinition.php | Makes title nullable/optional and relies on base JSON builder to omit absent title. |
| src/Schema/Elicitation/EnumSchemaDefinition.php | Makes title nullable/optional and updates custom jsonSerialize() to omit absent title. |
| src/Schema/Elicitation/BooleanSchemaDefinition.php | Makes title nullable/optional and relies on base JSON builder to omit absent title. |
| src/Schema/Elicitation/AbstractSchemaDefinition.php | Centralizes “optional title” behavior in validation and base JSON building. |
| CHANGELOG.md | Documents the fix and its impact on interoperability with conformant servers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| public function __construct( | ||
| string $title, | ||
| ?string $title, | ||
| public readonly bool $integerOnly = false, |
There was a problem hiding this comment.
Fixed in 3546d94 — updated to @param ?string $title Optional human-readable title for the field.
| public function __construct( | ||
| string $title, | ||
| ?string $title, | ||
| public readonly array $enum, |
There was a problem hiding this comment.
Fixed in 3546d94 — updated to @param ?string $title Optional human-readable title for the field.
|
Follow-up: c933262 adds the missing |
Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
The specification makes
titleoptional on every elicitation schema definition.AbstractSchemaDefinitionrequired it, so a client reading a conformant server'selicitation/createrefused the request — and a server building one could not omit it either.titleis now nullable on all seven definitions, omitted from the serialized form when absent, and rejected only when present and not a string.