Skip to content

Commit 48cb8d3

Browse files
feat: add SEP-1330 conformance test tool to everything-server
Add test_elicitation_sep1330_enum_schemas tool that demonstrates all 5 enum schema patterns introduced in SEP-1330: - Untitled single-select (simple enum array) - Titled single-select (oneOf with const/title) - Untitled multi-select (array with items.enum) - Titled multi-select (array with items.oneOf) - Legacy format (enum + enumNames for backward compatibility) This enables conformance testing of the SEP-1330 implementation in the Python SDK, matching the TypeScript server implementation.
1 parent 6ddfee7 commit 48cb8d3

File tree

1 file changed

+58
-0
lines changed
  • examples/servers/everything-server/mcp_everything_server

1 file changed

+58
-0
lines changed

examples/servers/everything-server/mcp_everything_server/server.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,64 @@ async def test_elicitation(message: str, ctx: Context[ServerSession, None]) -> s
166166
return f"Elicitation not supported or error: {str(e)}"
167167

168168

169+
class EnumSchemasTestSchema(BaseModel):
170+
"""Schema for testing enum schema variations (SEP-1330)"""
171+
172+
untitledSingle: str = Field(
173+
description="Simple enum without titles", json_schema_extra={"enum": ["active", "inactive", "pending"]}
174+
)
175+
titledSingle: str = Field(
176+
description="Enum with titled options (oneOf)",
177+
json_schema_extra={
178+
"oneOf": [
179+
{"const": "low", "title": "Low Priority"},
180+
{"const": "medium", "title": "Medium Priority"},
181+
{"const": "high", "title": "High Priority"},
182+
]
183+
},
184+
)
185+
untitledMulti: list[str] = Field(
186+
description="Multi-select without titles", json_schema_extra={"items": {"enum": ["read", "write", "execute"]}}
187+
)
188+
titledMulti: list[str] = Field(
189+
description="Multi-select with titled options",
190+
json_schema_extra={
191+
"items": {
192+
"oneOf": [
193+
{"const": "feature", "title": "New Feature"},
194+
{"const": "bug", "title": "Bug Fix"},
195+
{"const": "docs", "title": "Documentation"},
196+
]
197+
}
198+
},
199+
)
200+
legacyEnum: str = Field(
201+
description="Legacy enum with enumNames",
202+
json_schema_extra={
203+
"enum": ["small", "medium", "large"],
204+
"enumNames": ["Small Size", "Medium Size", "Large Size"],
205+
},
206+
)
207+
208+
209+
@mcp.tool()
210+
async def test_elicitation_sep1330_enum_schemas(ctx: Context[ServerSession, None]) -> str:
211+
"""Tests elicitation with enum schema variations per SEP-1330"""
212+
try:
213+
result = await ctx.elicit(
214+
message="Please select values using different enum schema types", schema=EnumSchemasTestSchema
215+
)
216+
217+
if result.action == "accept":
218+
content = result.data.model_dump_json()
219+
else:
220+
content = "{}"
221+
222+
return f"Elicitation completed: action={result.action}, content={content}"
223+
except Exception as e:
224+
return f"Elicitation not supported or error: {str(e)}"
225+
226+
169227
@mcp.tool()
170228
def test_error_handling() -> str:
171229
"""Tests error response handling"""

0 commit comments

Comments
 (0)