Skip to content

Commit d7d6376

Browse files
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.
1 parent da4fce2 commit d7d6376

File tree

1 file changed

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

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,38 @@ 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 SEP1034DefaultsSchema(BaseModel):
170+
"""Schema for testing SEP-1034 elicitation with default values for all primitive types"""
171+
172+
name: str = Field(default="John Doe", description="User name")
173+
age: int = Field(default=30, description="User age")
174+
score: float = Field(default=95.5, description="User score")
175+
status: str = Field(
176+
default="active",
177+
description="User status",
178+
json_schema_extra={"enum": ["active", "inactive", "pending"]},
179+
)
180+
verified: bool = Field(default=True, description="Verification status")
181+
182+
183+
@mcp.tool()
184+
async def test_elicitation_sep1034_defaults(ctx: Context[ServerSession, None]) -> str:
185+
"""Tests elicitation with default values for all primitive types (SEP-1034)"""
186+
try:
187+
# Request user input with defaults for all primitive types
188+
result = await ctx.elicit(message="Please provide user information", schema=SEP1034DefaultsSchema)
189+
190+
# Type-safe discriminated union narrowing using action field
191+
if result.action == "accept":
192+
content = result.data.model_dump_json()
193+
else: # decline or cancel
194+
content = "{}"
195+
196+
return f"Elicitation result: action={result.action}, content={content}"
197+
except Exception as e:
198+
return f"Elicitation not supported or error: {str(e)}"
199+
200+
169201
@mcp.tool()
170202
def test_error_handling() -> str:
171203
"""Tests error response handling"""

0 commit comments

Comments
 (0)