From 1d18278d71630394a00a33b5fbfdcc5dfd23ccbd Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 25 Oct 2026 22:34:51 -0700 Subject: [PATCH] fix(mcp-elicit): skipping every field of an optional form declines The all-skipped guard only fired when the form had a required field, so a user who skipped every field of an all-optional form (no defaults) sent "accept" with empty content. Any fully skipped form without defaults now declines. --- tests/tools/test_mcp_elicitation_form.py | 7 +++++++ tools/mcp_elicitation_form.py | 5 +++-- website/docs/user-guide/features/mcp.md | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/tools/test_mcp_elicitation_form.py b/tests/tools/test_mcp_elicitation_form.py index 77743da66b..a33925a2da 100644 --- a/tests/tools/test_mcp_elicitation_form.py +++ b/tests/tools/test_mcp_elicitation_form.py @@ -156,3 +156,10 @@ def test_enum_pick_is_never_swapped_for_another_option(answer, outcome): field = parse_form({"properties": {"region": {"type": "string", "enum": ["US", "us"]}}})[0] assert coerce_answer(field, answer) == outcome + +def test_skipping_every_optional_field_declines(): + schema = {"type": "object", "properties": {"note": {"type": "string"}, "rating": {"type": "integer"}}} + ctx = _call_context(lambda _questions: {"outcome": "submitted", "answers": {}}) + handler = ElicitationHandler("formprobe", {"timeout": 5}, call_context=lambda: ctx) + result = asyncio.run(handler(context=None, params=_params(schema))) + assert result.action == "decline" diff --git a/tools/mcp_elicitation_form.py b/tools/mcp_elicitation_form.py index 883bf564ca..47b363c7a2 100644 --- a/tools/mcp_elicitation_form.py +++ b/tools/mcp_elicitation_form.py @@ -309,8 +309,9 @@ def _collect(asker: FormAsker, fields: list[FormField], header: str, ended: Call break if pending: # still invalid after the re-asks return FormOutcome("decline") - # A form whose every field was skipped and has no default is the user saying no. - if not answered_any and not content and any(f.required for f in fields): + # A form whose every field was skipped and has no default is the user saying no (optional + # fields included: an accepted empty form would read as the user agreeing). + if not answered_any and not content: return FormOutcome("decline") return FormOutcome("accept", content) diff --git a/website/docs/user-guide/features/mcp.md b/website/docs/user-guide/features/mcp.md index 3053a04994..9e68ace721 100644 --- a/website/docs/user-guide/features/mcp.md +++ b/website/docs/user-guide/features/mcp.md @@ -1017,7 +1017,7 @@ A [portable plugin package](../../developer-guide/plugins/index.md#portable-agen ## MCP Elicitation Support -MCP servers can ask the user for structured input mid-tool-call via the `elicitation/create` protocol (mcp Python SDK ≥ 1.11.0). Hermes asks **form-mode** elicitations on the session's own clarify surface — the question panel in the CLI/TUI, a card in Desktop, the clarify prompt on messaging platforms — so the request reaches you wherever the session lives. Each field the server asks for becomes a question (choices for enums and yes/no fields, free text otherwise); answers are checked against the server's schema (whole numbers, ranges, lengths, `email`/`uri`/`date`/`date-time` formats) and a wrong answer is asked again, twice at most, before the form is declined. Skipping every field of a form with required fields declines; dismissing the prompt cancels. Your answers go to that MCP server only, not into the conversation. A form with no fields is a yes/no question. Where no clarify surface is bound, the request falls back to the approval prompt, which can only answer forms that a single Allow Once can fill. YOLO and `approvals.mode: off` do not answer these for you: the server is asking you a question, not asking permission. Cron and other unattended sessions decline. **URL-mode** elicitations (where a server points you at an external URL) are declined as unsupported. +MCP servers can ask the user for structured input mid-tool-call via the `elicitation/create` protocol (mcp Python SDK ≥ 1.11.0). Hermes asks **form-mode** elicitations on the session's own clarify surface — the question panel in the CLI/TUI, a card in Desktop, the clarify prompt on messaging platforms — so the request reaches you wherever the session lives. Each field the server asks for becomes a question (choices for enums and yes/no fields, free text otherwise); answers are checked against the server's schema (whole numbers, ranges, lengths, `email`/`uri`/`date`/`date-time` formats) and a wrong answer is asked again, twice at most, before the form is declined. Skipping every field (with no defaults to fall back on) declines; dismissing the prompt cancels. Your answers go to that MCP server only, not into the conversation. A form with no fields is a yes/no question. Where no clarify surface is bound, the request falls back to the approval prompt, which can only answer forms that a single Allow Once can fill. YOLO and `approvals.mode: off` do not answer these for you: the server is asking you a question, not asking permission. Cron and other unattended sessions decline. **URL-mode** elicitations (where a server points you at an external URL) are declined as unsupported. Elicitation is **enabled by default** per server. Configure it under the `elicitation` key: