Skip to content

Commit 11ad2a7

Browse files
chughtapanTapan Chughcliffhallclaudefelixweinberger
authored
SEP-1330 Elicitation Enum Schema Improvements and Standards Compliance (modelcontextprotocol#1148)
* Replace enumNames with standard-compliant oneOf pattern The enumNames property is not a valid JSON Schema keyword. Updated EnumSchema to use the standard-compliant oneOf pattern with const and title keywords for each option, as recommended by JSON Schema specification. * Refactor enum schemas to support 3 distinct types - SingleSelectEnumSchema: Supports both plain enum[] and oneOf with titles - MultiSelectEnumSchema: Array type for multi-selection with/without titles - DeprecatedEnumSchema: Maintains backward compatibility with enumNames This replaces the non-standard enumNames approach with JSON Schema-compliant patterns using oneOf/const for titled enums, while preserving backward compatibility and adding multi-select support. * nit: address tiny comment about # maxItems * Refactor enum schemas with typed variants and array support * Update enum examples in elicitation docs with validated schemas * replace deprecated with legacy * nits * improve comment * reset docs/specification/2025-06-18/schema.mdx * fix * Improve docs and add changelog entry * add another doc comment * add another doc comment * Update multi-select to align with SEP-1330 * Fix default values on new elicitation schemas * Make individual Schemas interfaces rather than type aliases * run prettier * update types based on discussion to match validation --------- Co-authored-by: Tapan Chugh <[email protected]> Co-authored-by: Cliff Hall <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Felix Weinberger <[email protected]>
1 parent d847a00 commit 11ad2a7

File tree

5 files changed

+559
-44
lines changed

5 files changed

+559
-44
lines changed

docs/specification/draft/changelog.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ the previous revision, [2025-06-18](/specification/2025-06-18).
1313
2. Allow servers to expose icons as additional metadata for tools, resources, resource templates, and prompts ([SEP-973](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/973)).
1414
3. Enhance authorization flows with incremental scope consent via `WWW-Authenticate` ([SEP-835](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/835))
1515
4. Provide guidance on tool names ([SEP-986](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1603))
16+
5. Update `ElicitResult` and `EnumSchema` to use a more standards-based approach and support titled, untitled, single-select, and multi-select enums ([SEP-1330](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1330)).
1617

1718
## Minor changes
1819

docs/specification/draft/client/elicitation.mdx

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,69 @@ The schema is restricted to these primitive types:
265265
```
266266

267267
4. **Enum Schema**
268+
269+
Single-select enum (without titles):
270+
268271
```json
269272
{
270273
"type": "string",
271-
"title": "Display Name",
272-
"description": "Description text",
273-
"enum": ["option1", "option2", "option3"],
274-
"enumNames": ["Option 1", "Option 2", "Option 3"],
275-
"default": "option1"
274+
"title": "Color Selection",
275+
"description": "Choose your favorite color",
276+
"enum": ["Red", "Green", "Blue"],
277+
"default": "Red"
278+
}
279+
```
280+
281+
Single-select enum (with titles):
282+
283+
```json
284+
{
285+
"type": "string",
286+
"title": "Color Selection",
287+
"description": "Choose your favorite color",
288+
"oneOf": [
289+
{ "const": "#FF0000", "title": "Red" },
290+
{ "const": "#00FF00", "title": "Green" },
291+
{ "const": "#0000FF", "title": "Blue" }
292+
],
293+
"default": "#FF0000"
294+
}
295+
```
296+
297+
Multi-select enum (without titles):
298+
299+
```json
300+
{
301+
"type": "array",
302+
"title": "Color Selection",
303+
"description": "Choose your favorite colors",
304+
"minItems": 1,
305+
"maxItems": 2,
306+
"items": {
307+
"type": "string",
308+
"enum": ["Red", "Green", "Blue"]
309+
},
310+
"default": ["Red", "Green"]
311+
}
312+
```
313+
314+
Multi-select enum (with titles):
315+
316+
```json
317+
{
318+
"type": "array",
319+
"title": "Color Selection",
320+
"description": "Choose your favorite colors",
321+
"minItems": 1,
322+
"maxItems": 2,
323+
"items": {
324+
"oneOf": [
325+
{ "const": "#FF0000", "title": "Red" },
326+
{ "const": "#00FF00", "title": "Green" },
327+
{ "const": "#0000FF", "title": "Blue" }
328+
]
329+
},
330+
"default": ["#FF0000", "#00FF00"]
276331
}
277332
```
278333

@@ -284,7 +339,7 @@ Clients can use this schema to:
284339

285340
All primitive types support optional default values to provide sensible starting points. Clients that support defaults SHOULD pre-populate form fields with these values.
286341

287-
Note that complex nested structures, arrays of objects, and other advanced JSON Schema features are intentionally not supported to simplify client user experience.
342+
Note that complex nested structures, arrays of objects (beyond enums), and other advanced JSON Schema features are intentionally not supported to simplify client user experience.
288343

289344
## Response Actions
290345

0 commit comments

Comments
 (0)