Skip to content

Commit be4885f

Browse files
Add reference server implementation for SEP-1330 conformance test
Adds test_elicitation_sep1330_enums tool to everything-server that requests elicitation with all 5 enum schema variants. Also updates SERVER_REQUIREMENTS.md with full specification.
1 parent 3059635 commit be4885f

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

SERVER_REQUIREMENTS.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,96 @@ If no progress token provided, just execute with delays.
463463

464464
**Reference**: [SEP-1034](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1034)
465465

466+
#### `test_elicitation_sep1330_enums`
467+
468+
**Arguments**: None
469+
470+
**Behavior**: Request user input from the client using `elicitation/create` with enum schema improvements (SEP-1330)
471+
472+
**Elicitation Request**:
473+
474+
```json
475+
{
476+
"method": "elicitation/create",
477+
"params": {
478+
"message": "Please select options from the enum fields",
479+
"requestedSchema": {
480+
"type": "object",
481+
"properties": {
482+
"untitledSingle": {
483+
"type": "string",
484+
"description": "Select one option",
485+
"enum": ["option1", "option2", "option3"]
486+
},
487+
"titledSingle": {
488+
"type": "string",
489+
"description": "Select one option with titles",
490+
"oneOf": [
491+
{ "const": "value1", "title": "First Option" },
492+
{ "const": "value2", "title": "Second Option" },
493+
{ "const": "value3", "title": "Third Option" }
494+
]
495+
},
496+
"legacyEnum": {
497+
"type": "string",
498+
"description": "Select one option (legacy)",
499+
"enum": ["opt1", "opt2", "opt3"],
500+
"enumNames": ["Option One", "Option Two", "Option Three"]
501+
},
502+
"untitledMulti": {
503+
"type": "array",
504+
"description": "Select multiple options",
505+
"minItems": 1,
506+
"maxItems": 3,
507+
"items": {
508+
"type": "string",
509+
"enum": ["option1", "option2", "option3"]
510+
}
511+
},
512+
"titledMulti": {
513+
"type": "array",
514+
"description": "Select multiple options with titles",
515+
"minItems": 1,
516+
"maxItems": 3,
517+
"items": {
518+
"anyOf": [
519+
{ "const": "value1", "title": "First Choice" },
520+
{ "const": "value2", "title": "Second Choice" },
521+
{ "const": "value3", "title": "Third Choice" }
522+
]
523+
}
524+
}
525+
},
526+
"required": []
527+
}
528+
}
529+
}
530+
```
531+
532+
**Returns**: Text content with the elicitation result
533+
534+
```json
535+
{
536+
"content": [
537+
{
538+
"type": "text",
539+
"text": "Elicitation completed: action=<accept/decline/cancel>, content={...}"
540+
}
541+
]
542+
}
543+
```
544+
545+
**Implementation Note**: This tool tests SEP-1330 support for enum schema improvements including:
546+
- Untitled single-select enums (type: string with enum array)
547+
- Titled single-select enums (using oneOf with const/title objects)
548+
- Legacy titled enums (using deprecated enumNames array)
549+
- Untitled multi-select enums (type: array with items.enum)
550+
- Titled multi-select enums (using items.anyOf with const/title objects)
551+
552+
If the client doesn't support elicitation (no `elicitation` capability), return an error.
553+
554+
**Reference**: [SEP-1330](https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1330)
555+
466556
---
467557

468558
## 3. Resources Requirements

examples/servers/typescript/everything-server.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,105 @@ function createMcpServer() {
472472
}
473473
);
474474

475+
// SEP-1330: Elicitation with enum schema improvements
476+
mcpServer.registerTool(
477+
'test_elicitation_sep1330_enums',
478+
{
479+
description:
480+
'Tests elicitation with enum schema improvements per SEP-1330',
481+
inputSchema: {}
482+
},
483+
async () => {
484+
try {
485+
// Request user input with all 5 enum schema variants
486+
const result = await mcpServer.server.request(
487+
{
488+
method: 'elicitation/create',
489+
params: {
490+
message: 'Please select options from the enum fields',
491+
requestedSchema: {
492+
type: 'object',
493+
properties: {
494+
// Untitled single-select enum (basic)
495+
untitledSingle: {
496+
type: 'string',
497+
description: 'Select one option',
498+
enum: ['option1', 'option2', 'option3']
499+
},
500+
// Titled single-select enum (using oneOf with const/title)
501+
titledSingle: {
502+
type: 'string',
503+
description: 'Select one option with titles',
504+
oneOf: [
505+
{ const: 'value1', title: 'First Option' },
506+
{ const: 'value2', title: 'Second Option' },
507+
{ const: 'value3', title: 'Third Option' }
508+
]
509+
},
510+
// Legacy titled enum (using enumNames - deprecated)
511+
legacyEnum: {
512+
type: 'string',
513+
description: 'Select one option (legacy)',
514+
enum: ['opt1', 'opt2', 'opt3'],
515+
enumNames: ['Option One', 'Option Two', 'Option Three']
516+
},
517+
// Untitled multi-select enum
518+
untitledMulti: {
519+
type: 'array',
520+
description: 'Select multiple options',
521+
minItems: 1,
522+
maxItems: 3,
523+
items: {
524+
type: 'string',
525+
enum: ['option1', 'option2', 'option3']
526+
}
527+
},
528+
// Titled multi-select enum (using anyOf with const/title)
529+
titledMulti: {
530+
type: 'array',
531+
description: 'Select multiple options with titles',
532+
minItems: 1,
533+
maxItems: 3,
534+
items: {
535+
anyOf: [
536+
{ const: 'value1', title: 'First Choice' },
537+
{ const: 'value2', title: 'Second Choice' },
538+
{ const: 'value3', title: 'Third Choice' }
539+
]
540+
}
541+
}
542+
},
543+
required: []
544+
}
545+
}
546+
},
547+
z
548+
.object({ method: z.literal('elicitation/create') })
549+
.passthrough() as any
550+
);
551+
552+
const elicitResult = result as any;
553+
return {
554+
content: [
555+
{
556+
type: 'text',
557+
text: `Elicitation completed: action=${elicitResult.action}, content=${JSON.stringify(elicitResult.content || {})}`
558+
}
559+
]
560+
};
561+
} catch (error: any) {
562+
return {
563+
content: [
564+
{
565+
type: 'text',
566+
text: `Elicitation not supported or error: ${error.message}`
567+
}
568+
]
569+
};
570+
}
571+
}
572+
);
573+
475574
// Dynamic tool (registered later via timer)
476575

477576
// ===== RESOURCES =====

0 commit comments

Comments
 (0)