Skip to content

Commit 555c640

Browse files
Kludexmaxisbey
authored andcommitted
Drive resolver elicitation over the 2026-07-28 input_required flow
Resolvers that return Elicit[T] now negotiate the transport by protocol version: at >= 2026-07-28 the framework returns an InputRequiredResult carrying the batched questions and resumes when the client retries with input_responses/request_state; at <= 2025-11-25 it keeps the synchronous ctx.elicit() request. Author-facing code (Resolve/Elicit) is unchanged. resolve_arguments becomes a resumable DAG walk: it reads ctx.input_responses / ctx.request_state, memoizes resolver outcomes by a process-stable module:qualname key, batches independent pending elicitations into one round, serializes dependent ones across rounds, and carries resolved outcomes in request_state so each resolver resolves once per logical call. Outcomes restored from request_state are re-validated into their model via the Elicit[T] return arm. request_state is client-trusted for now (HMAC sealing is a follow-up). Add a render_elicitation_schema helper to elicitation.py, MRTR-loop and codec tests, and document the transport in the migration guide.
1 parent 24fdd90 commit 555c640

4 files changed

Lines changed: 501 additions & 80 deletions

File tree

src/mcp/server/elicitation.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ def _validate_rendered_properties(json_schema: dict[str, Any]) -> None:
8787
) from None
8888

8989

90+
def render_elicitation_schema(schema: type[BaseModel]) -> dict[str, Any]:
91+
"""Render a model as the spec-valid `requested_schema` for an elicitation.
92+
93+
Raises:
94+
TypeError: If a field renders as something the spec's
95+
`PrimitiveSchemaDefinition` does not accept.
96+
"""
97+
json_schema = schema.model_json_schema(schema_generator=_ElicitationJsonSchema)
98+
_validate_rendered_properties(json_schema)
99+
return json_schema
100+
101+
90102
async def elicit_with_validation(
91103
session: ServerSession,
92104
message: str,
@@ -103,8 +115,7 @@ async def elicit_with_validation(
103115
104116
For sensitive data like credentials or OAuth flows, use elicit_url() instead.
105117
"""
106-
json_schema = schema.model_json_schema(schema_generator=_ElicitationJsonSchema)
107-
_validate_rendered_properties(json_schema)
118+
json_schema = render_elicitation_schema(schema)
108119

109120
result = await session.elicit_form(
110121
message=message,

0 commit comments

Comments
 (0)