Skip to content

docs: show the decline branch in the lead input_required example - #2999

Open
yy5652-hash wants to merge 1 commit into
modelcontextprotocol:mainfrom
yy5652-hash:docs/input-required-decline-branch
Open

yy5652-hash wants to merge 1 commit into
modelcontextprotocol:mainfrom
yy5652-hash:docs/input-required-decline-branch

Conversation

@yy5652-hash

Copy link
Copy Markdown

docs: show the decline branch in the lead input_required example

What

The first input_required example a developer meets, in the inputRequired JSDoc (packages/core-internal/src/shared/inputRequired.ts) and at the top of docs/servers/input-required.md (examples/guides/servers/input-required.examples.ts#registerTool_inputRequired), tests only for an accepted answer:

const confirmed = acceptedContent(ctx.mcpReq.inputResponses, 'confirm', confirmationSchema);
if (confirmed?.confirm !== true) {
    return inputRequired({ ... });
}

acceptedContent returns undefined for a declined or cancelled answer just as it does on the first entry, so a decline makes the handler return inputRequired() again. The client re-asks on every retry until inputRequired.maxRounds, the operator is put the same question eight times, and then the call fails with "Multi-round-trip request 'tools/call' still required input after 8 rounds". The server sees no error at any point.

The guide already explains this further down ("Read the responses on re-entry") and inputResponse() exists for exactly this; the lead example just does not use it, and it is the one that gets copied. We copied it into a hackathon server and shipped the loop.

Change

  • The lead example (JSDoc and guide) reads the response with inputResponse() first and finishes on any elicitation answer: accepted → act; declined or cancelled → an isError result. The request is only re-issued when nothing has arrived.
  • One paragraph in the guide says why: acceptedContent alone cannot tell a refusal from a first entry.
  • A test in packages/server/test/server/inputRequired.test.ts pins the one-round behaviour for decline and cancel on the 2026-07-28 era through the real server funnel, and records that acceptedContent reads both as undefined.

No runtime code changes; no changeset added. pnpm sync:snippets --check, the server and core-internal test suites and lint pass locally. The markdown page was not prettier-clean before this change (unrelated long lines), and that is left as it was.

🤖 Generated with Claude Code

The first example a developer meets (the inputRequired JSDoc and the opening
of docs/servers/input-required.md) tests only for an accepted answer, so a
declined or cancelled confirmation returns inputRequired() again: the client
re-asks on every retry until inputRequired.maxRounds, and the operator is put
the same question eight times. Read the response with inputResponse() first
and finish on any answer; the test pins the one-round behaviour for decline
and cancel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@yy5652-hash
yy5652-hash requested a review from a team as a code owner October 10, 2026 10:37
@changeset-bot

changeset-bot Bot commented Oct 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 73c0ebf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Oct 11, 2026

This branch has not been deployed

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

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant