Skip to content

Commit e2fb677

Browse files
authored
fix(unstable): Move elicitation scope into mode variants (#966)
* fix(unstable): Move elicitation scope into mode variants Align elicitation request types and generated schema by storing scope on form and URL modes instead of the top-level request. * Refactor elicitation scopes into named structs Extract session and request elicitation scopes into reusable `ElicitationSessionScope` and `ElicitationRequestScope` types, update tests to use their constructors, and reuse the new schema definitions in the draft docs and unstable JSON schema. * Add extra test * Make builders nicer * intooption for tool call id
1 parent 44bd332 commit e2fb677

File tree

4 files changed

+401
-181
lines changed

4 files changed

+401
-181
lines changed

docs/protocol/draft/schema.mdx

Lines changed: 158 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,56 +1574,6 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/exte
15741574

15751575
**Variants:**
15761576

1577-
<ResponseField name="Session" type="object">
1578-
Tied to a session, optionally to a specific tool call within that session.
1579-
1580-
When `tool_call_id` is set, the elicitation is tied to a specific tool call.
1581-
This is useful when an agent receives an elicitation from an MCP server
1582-
during a tool call and needs to redirect it to the user.
1583-
1584-
<Expandable title="Properties">
1585-
1586-
<ResponseField
1587-
name="sessionId"
1588-
type={<a href="#sessionid">SessionId</a>}
1589-
required
1590-
>
1591-
The session this elicitation is tied to.
1592-
</ResponseField>
1593-
<ResponseField
1594-
name="toolCallId"
1595-
type={
1596-
<>
1597-
<span>
1598-
<a href="#toolcallid">ToolCallId</a>
1599-
</span>
1600-
<span> | null</span>
1601-
</>
1602-
}
1603-
>
1604-
Optional tool call within the session.
1605-
</ResponseField>
1606-
1607-
</Expandable>
1608-
</ResponseField>
1609-
1610-
<ResponseField name="Request" type="object">
1611-
Tied to a specific JSON-RPC request outside of a session
1612-
(e.g., during auth/configuration phases before any session is started).
1613-
1614-
<Expandable title="Properties">
1615-
1616-
<ResponseField
1617-
name="requestId"
1618-
type={<a href="#requestid">RequestId</a>}
1619-
required
1620-
>
1621-
The request this elicitation is tied to.
1622-
</ResponseField>
1623-
1624-
</Expandable>
1625-
</ResponseField>
1626-
16271577
<ResponseField name="form" type="object">
16281578
Form-based elicitation where the client renders a form from the provided schema.
16291579

@@ -3379,9 +3329,9 @@ This capability is not part of the spec yet, and may be removed or changed at an
33793329

33803330
Form-based elicitation mode where the client renders a form from the provided schema.
33813331

3382-
**Type:** Object
3332+
**Type:** Union
33833333

3384-
**Properties:**
3334+
**Shared properties:**
33853335

33863336
<ResponseField
33873337
name="requestedSchema"
@@ -3391,6 +3341,54 @@ Form-based elicitation mode where the client renders a form from the provided sc
33913341
A JSON Schema describing the form fields to present to the user.
33923342
</ResponseField>
33933343

3344+
**Variants:**
3345+
3346+
<ResponseField name="Session">
3347+
Tied to a session, optionally to a specific tool call within that session.
3348+
3349+
<Expandable title="Properties">
3350+
3351+
<ResponseField
3352+
name="sessionId"
3353+
type={<a href="#sessionid">SessionId</a>}
3354+
required
3355+
>
3356+
The session this elicitation is tied to.
3357+
</ResponseField>
3358+
<ResponseField
3359+
name="toolCallId"
3360+
type={
3361+
<>
3362+
<span>
3363+
<a href="#toolcallid">ToolCallId</a>
3364+
</span>
3365+
<span> | null</span>
3366+
</>
3367+
}
3368+
>
3369+
Optional tool call within the session.
3370+
</ResponseField>
3371+
3372+
</Expandable>
3373+
</ResponseField>
3374+
3375+
<ResponseField name="Request">
3376+
Tied to a specific JSON-RPC request outside of a session
3377+
(e.g., during auth/configuration phases before any session is started).
3378+
3379+
<Expandable title="Properties">
3380+
3381+
<ResponseField
3382+
name="requestId"
3383+
type={<a href="#requestid">RequestId</a>}
3384+
required
3385+
>
3386+
The request this elicitation is tied to.
3387+
</ResponseField>
3388+
3389+
</Expandable>
3390+
</ResponseField>
3391+
33943392
## <span class="font-mono">ElicitationId</span>
33953393

33963394
**UNSTABLE**
@@ -3567,6 +3565,27 @@ Multi-select array property.
35673565
</Expandable>
35683566
</ResponseField>
35693567

3568+
## <span class="font-mono">ElicitationRequestScope</span>
3569+
3570+
**UNSTABLE**
3571+
3572+
This capability is not part of the spec yet, and may be removed or changed at any point.
3573+
3574+
Request-scoped elicitation, tied to a specific JSON-RPC request outside of a session
3575+
(e.g., during auth/configuration phases before any session is started).
3576+
3577+
**Type:** Object
3578+
3579+
**Properties:**
3580+
3581+
<ResponseField
3582+
name="requestId"
3583+
type={<a href="#requestid">RequestId</a>}
3584+
required
3585+
>
3586+
The request this elicitation is tied to.
3587+
</ResponseField>
3588+
35703589
## <span class="font-mono">ElicitationSchema</span>
35713590

35723591
Type-safe elicitation schema for requesting structured user input.
@@ -3610,6 +3629,43 @@ Type discriminator for elicitation schemas.
36103629
Object schema type.
36113630
</ResponseField>
36123631

3632+
## <span class="font-mono">ElicitationSessionScope</span>
3633+
3634+
**UNSTABLE**
3635+
3636+
This capability is not part of the spec yet, and may be removed or changed at any point.
3637+
3638+
Session-scoped elicitation, optionally tied to a specific tool call.
3639+
3640+
When `tool_call_id` is set, the elicitation is tied to a specific tool call.
3641+
This is useful when an agent receives an elicitation from an MCP server
3642+
during a tool call and needs to redirect it to the user.
3643+
3644+
**Type:** Object
3645+
3646+
**Properties:**
3647+
3648+
<ResponseField
3649+
name="sessionId"
3650+
type={<a href="#sessionid">SessionId</a>}
3651+
required
3652+
>
3653+
The session this elicitation is tied to.
3654+
</ResponseField>
3655+
<ResponseField
3656+
name="toolCallId"
3657+
type={
3658+
<>
3659+
<span>
3660+
<a href="#toolcallid">ToolCallId</a>
3661+
</span>
3662+
<span> | null</span>
3663+
</>
3664+
}
3665+
>
3666+
Optional tool call within the session.
3667+
</ResponseField>
3668+
36133669
## <span class="font-mono">ElicitationStringType</span>
36143670

36153671
Items definition for untitled multi-select enum properties.
@@ -3649,9 +3705,9 @@ This capability is not part of the spec yet, and may be removed or changed at an
36493705

36503706
URL-based elicitation mode where the client directs the user to a URL.
36513707

3652-
**Type:** Object
3708+
**Type:** Union
36533709

3654-
**Properties:**
3710+
**Shared properties:**
36553711

36563712
<ResponseField
36573713
name="elicitationId"
@@ -3664,6 +3720,54 @@ URL-based elicitation mode where the client directs the user to a URL.
36643720
The URL to direct the user to.
36653721
</ResponseField>
36663722

3723+
**Variants:**
3724+
3725+
<ResponseField name="Session">
3726+
Tied to a session, optionally to a specific tool call within that session.
3727+
3728+
<Expandable title="Properties">
3729+
3730+
<ResponseField
3731+
name="sessionId"
3732+
type={<a href="#sessionid">SessionId</a>}
3733+
required
3734+
>
3735+
The session this elicitation is tied to.
3736+
</ResponseField>
3737+
<ResponseField
3738+
name="toolCallId"
3739+
type={
3740+
<>
3741+
<span>
3742+
<a href="#toolcallid">ToolCallId</a>
3743+
</span>
3744+
<span> | null</span>
3745+
</>
3746+
}
3747+
>
3748+
Optional tool call within the session.
3749+
</ResponseField>
3750+
3751+
</Expandable>
3752+
</ResponseField>
3753+
3754+
<ResponseField name="Request">
3755+
Tied to a specific JSON-RPC request outside of a session
3756+
(e.g., during auth/configuration phases before any session is started).
3757+
3758+
<Expandable title="Properties">
3759+
3760+
<ResponseField
3761+
name="requestId"
3762+
type={<a href="#requestid">RequestId</a>}
3763+
required
3764+
>
3765+
The request this elicitation is tied to.
3766+
</ResponseField>
3767+
3768+
</Expandable>
3769+
</ResponseField>
3770+
36673771
## <span class="font-mono">EmbeddedResource</span>
36683772

36693773
The contents of a resource, embedded into a prompt or tool call result.

0 commit comments

Comments
 (0)