Skip to content

[Schema] Stop rejecting elicitation schemas the specification allows - #437

Merged
chr-hertel merged 4 commits into
modelcontextprotocol:mainfrom
chr-hertel:pr/elicitation-optional-title
Aug 18, 2026
Merged

[Schema] Stop rejecting elicitation schemas the specification allows#437
chr-hertel merged 4 commits into
modelcontextprotocol:mainfrom
chr-hertel:pr/elicitation-optional-title

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 title nullable across all seven elicitation schema definition classes and adjust fromArray() to accept missing title.
  • Update serialization to omit title when it’s null (notably via AbstractSchemaDefinition::buildBaseJson() and a custom update in EnumSchemaDefinition).
  • 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.

Comment thread src/Schema/Elicitation/AbstractSchemaDefinition.php
Comment thread src/Schema/Elicitation/EnumSchemaDefinition.php
Comment on lines 33 to 35
public function __construct(
string $title,
?string $title,
public readonly bool $integerOnly = false,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3546d94 — updated to @param ?string $title Optional human-readable title for the field.

Comment on lines 33 to 35
public function __construct(
string $title,
?string $title,
public readonly array $enum,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3546d94 — updated to @param ?string $title Optional human-readable title for the field.

Comment thread src/Schema/Elicitation/AbstractSchemaDefinition.php
@chr-hertel

Copy link
Copy Markdown
Member Author

Follow-up: c933262 adds the missing = null default to NumberSchemaDefinition's $title param — it was mistakenly grouped with the classes where a required param follows $title, but all of Number's subsequent params already have defaults, so it could safely take one too.

Comment thread src/Schema/Elicitation/AbstractSchemaDefinition.php Outdated
Comment thread CHANGELOG.md Outdated
Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
@chr-hertel
chr-hertel merged commit cf2c4d4 into modelcontextprotocol:main Aug 18, 2026
23 checks passed
@chr-hertel
chr-hertel deleted the pr/elicitation-optional-title branch August 18, 2026 17:49
@chr-hertel chr-hertel added this to the 0.8.0 milestone Aug 18, 2026
@chr-hertel chr-hertel added the Schema Issues & PRs related to the Schema component label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schema Issues & PRs related to the Schema component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants