Skip to content

fix: call tasks/result when task status is input_required#1174

Merged
cliffhall merged 2 commits into
modelcontextprotocol:mainfrom
galagaevdc:fix/task-input-required-status
Jun 7, 2026
Merged

fix: call tasks/result when task status is input_required#1174
cliffhall merged 2 commits into
modelcontextprotocol:mainfrom
galagaevdc:fix/task-input-required-status

Conversation

@galagaevdc

@galagaevdc galagaevdc commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1073

Per the MCP spec https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks#input-required-status, when a client observes input_required status during task polling it must call tasks/result to give the server a chance to deliver queued elicitation/sampling requests. Previously the polling loop only called tasks/result after completed status, leaving the server unable to trigger elicitation.

After elicitation is handled the task transitions back to working so taskCompleted is not set — polling continues until a terminal status is reached.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates
  • Build/CI improvements

Changes Made

The fix adds an explicit input_required branch in the polling loop that calls tasks/result as required by the
https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks#input-required-status. After elicitation is handled the server transitions the task back to working, so the loop
continues polling until a terminal status is reached.

Related Issues

#1073

Testing

  • Tested in UI mode
  • Tested in CLI mode
  • Tested with STDIO transport
  • Tested with SSE transport
  • Tested with Streamable HTTP transport
  • Added/updated automated tests
  • Manual testing performed

Test Results and/or Instructions

Screenshots are encouraged to share your testing results for this change.

Checklist

  • Code follows the style guidelines (ran npm run prettier-fix)
  • Self-review completed
  • Code is commented where necessary
  • Documentation updated (README, comments, etc.)

Breaking Changes

None

Per the MCP spec (2025-11-25), when a client observes input_required
status during task polling it must call tasks/result to give the server
a chance to deliver queued elicitation/sampling requests. Previously the
polling loop only called tasks/result after completed status, leaving
the server unable to trigger elicitation.

After elicitation is handled the task transitions back to working so
taskCompleted is not set — polling continues until a terminal status
is reached.
@galagaevdc galagaevdc force-pushed the fix/task-input-required-status branch from 5f141b5 to ffc0b6d Compare April 20, 2026 15:51
Comment thread client/src/App.tsx
Comment thread client/src/App.tsx

@cliffhall cliffhall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and tested locally: rebased cleanly on main (v0.22.0), builds, the new App.taskPolling.test.tsx passes, and I exercised the flow against the server-everything task PR (modelcontextprotocol/servers#3816) — the input_required → elicitation hand-off works end-to-end. 👍

The core change is correct and the added test coverage is appreciated. Two robustness points worth considering before merge (left as inline comments):

  1. Repeated tasks/result while input_required persists — the branch doesn't terminate the poll loop, so if the task reports input_required across multiple polls, tasks/result is re-issued each interval with no guard. Could redeliver duplicate elicitation/sampling requests. Gating on the transition into input_required would avoid that. (Also: the awaited response is discarded here, unlike the completed branch.)

  2. Error handling — the new tasks/result call shares the loop's try, whose catch ends polling and shows an error. A server that rejects tasks/result on a non-completed task would cause the inspector to abandon the task instead of continuing to poll. Catching this specific call locally would be more resilient.

Neither blocks the happy path I tested; they're about behavior against slower or stricter task servers.

@cliffhall cliffhall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

All tests and checks pass locally with this PR branch rebased against main. Tested manually against server-everything at PR #3816

Image Image

@cliffhall cliffhall enabled auto-merge (squash) June 7, 2026 22:42
@cliffhall cliffhall merged commit a523a0f into modelcontextprotocol:main Jun 7, 2026
3 checks passed
@cliffhall

Copy link
Copy Markdown
Member

Thanks for this, @galagaevdc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

input_required not being handled correctly

2 participants