From d7d6376c3e4213ea5bd792fa66f5b6d41a50591a Mon Sep 17 00:00:00 2001 From: Felix Weinberger Date: Mon, 10 Nov 2025 18:07:43 +0000 Subject: [PATCH] Add SEP-1034 elicitation defaults support to everything-server Adds a new tool `test_elicitation_sep1034_defaults` that demonstrates elicitation with default values for all JSON Schema primitive types (string, integer, number, enum, boolean) as specified in SEP-1034. This enables conformance testing of SEP-1034 against the Python SDK implementation. All 5 conformance checks pass: - String default value support - Integer default value support - Number default value support - Enum default value support - Boolean default value support (regression test) The implementation uses Pydantic Field defaults which are automatically included in the generated JSON schema passed to the elicitation request. --- .../mcp_everything_server/server.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/servers/everything-server/mcp_everything_server/server.py b/examples/servers/everything-server/mcp_everything_server/server.py index a4221e522..32c3e1d91 100644 --- a/examples/servers/everything-server/mcp_everything_server/server.py +++ b/examples/servers/everything-server/mcp_everything_server/server.py @@ -166,6 +166,38 @@ async def test_elicitation(message: str, ctx: Context[ServerSession, None]) -> s return f"Elicitation not supported or error: {str(e)}" +class SEP1034DefaultsSchema(BaseModel): + """Schema for testing SEP-1034 elicitation with default values for all primitive types""" + + name: str = Field(default="John Doe", description="User name") + age: int = Field(default=30, description="User age") + score: float = Field(default=95.5, description="User score") + status: str = Field( + default="active", + description="User status", + json_schema_extra={"enum": ["active", "inactive", "pending"]}, + ) + verified: bool = Field(default=True, description="Verification status") + + +@mcp.tool() +async def test_elicitation_sep1034_defaults(ctx: Context[ServerSession, None]) -> str: + """Tests elicitation with default values for all primitive types (SEP-1034)""" + try: + # Request user input with defaults for all primitive types + result = await ctx.elicit(message="Please provide user information", schema=SEP1034DefaultsSchema) + + # Type-safe discriminated union narrowing using action field + if result.action == "accept": + content = result.data.model_dump_json() + else: # decline or cancel + content = "{}" + + return f"Elicitation result: action={result.action}, content={content}" + except Exception as e: + return f"Elicitation not supported or error: {str(e)}" + + @mcp.tool() def test_error_handling() -> str: """Tests error response handling"""