Skip to content

Map declared toolkit failures to MCP input_required results - #10090

Merged
tim-smart merged 7 commits into
Effect-TS:v4/next-minorfrom
creatifcoding:feat/mcp-toolkit-input-required
Oct 29, 2026
Merged

tim-smart merged 7 commits into
Effect-TS:v4/next-minorfrom
creatifcoding:feat/mcp-toolkit-input-required

Conversation

@creatifcoding

@creatifcoding creatifcoding commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Under 2026-07-28, a tool asks the client for input by returning an input_required result, and the client retries the call with inputResponses and the unchanged requestState (SEP-2322). McpServer.addTool handlers can do this by returning McpSchema.InputRequired. Toolkit tools could not: the toolkit bridge only produced a CallToolResult, so any failure reached the client as isError: true.

This PR lets a toolkit handler fail with a declared McpSchema.InputRequired, which McpServer.toolkit and McpServer.registerToolkit return as the input_required result. No new option or type is added; both keep their current signatures.

const ArchiveNote = Tool.make("ArchiveNote", {
  parameters: Schema.Struct({ noteId: Schema.String }),
  success: Schema.Struct({ archived: Schema.String }),
  failure: Schema.instanceOf(McpSchema.InputRequired),
  dependencies: [McpSchema.McpRequestContext]
})

NotesToolkit.toLayer({
  ArchiveNote: Effect.fnUntraced(function*({ noteId }) {
    const request = yield* McpSchema.McpRequestContext
    if (/* no verified confirmation in request.inputResponses / request.requestState */) {
      return yield* Effect.fail(new McpSchema.InputRequired({ inputRequests: { /* ... */ }, requestState }))
    }
    // ...
  })
})
  • The bridge returns the InputRequired instance as-is when a handler fails with it in "error" mode, and when a "return" mode result carries it as the handler failure. InputRequired can be one member of a union failure; tool.setFailure widens a tool you do not own.
  • Only declared handler failures are affected. Parameter errors, undeclared failures, encoding failures and defects keep their existing classification.
  • There is no protocol-version check in the bridge. The adapters already decide: earlier protocols reject the result with InvalidParams ("Client input is not supported by this MCP protocol"), exactly as for addTool, and the existing McpCore capability check (-32021, HTTP 400) applies.
  • The handler reads the retry from McpRequestContext.inputResponses and requestState, as addTool handlers do.

MCP.md gets a "Multi round-trip tool results" section with a confirmation example that signs requestState on the first call and verifies it, plus the submitted boolean, on the retry.

Tests

  • test/ai/McpServer/ProtocolAdapters.test.ts: two toolkit tools ("error" mode with InputRequired as the failure, "return" mode with a union failure) request roots on the first call and resume on the retry; both are rejected on 2025-11-25 with InvalidParams, and without the roots capability with -32021 / HTTP 400.
  • typetest/ai/McpServer.tst.ts: failure: Schema.instanceOf(McpSchema.InputRequired) is accepted and a handler can fail with it, with McpServer.toolkit requiring only McpServer.

Closes EFF-3102

@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6a98fd2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Minor
@effect/opentelemetry Minor
@effect/vitest Minor
@effect/ai-anthropic Minor
@effect/ai-cloudflare Minor
@effect/ai-openai-compat Minor
@effect/ai-openai Minor
@effect/ai-openrouter Minor
@effect/ai-typesafe Minor
@effect/atom-react Minor
@effect/atom-solid Minor
@effect/atom-vue Minor
@effect/platform-browser Minor
@effect/platform-bun Minor
@effect/platform-deno Minor
@effect/platform-node-shared Minor
@effect/platform-node Minor
@effect/sql-clickhouse Minor
@effect/sql-d1 Minor
@effect/sql-libsql Minor
@effect/sql-mssql Minor
@effect/sql-mysql2 Minor
@effect/sql-pg Minor
@effect/sql-pglite Minor
@effect/sql-sqlite-bun Minor
@effect/sql-sqlite-do Minor
@effect/sql-sqlite-node Minor
@effect/sql-sqlite-react-native Minor
@effect/sql-sqlite-wasm Minor
@effect/docgen Minor
@effect/doctest Minor
@effect/graphql-generator Minor
@effect/openapi-generator Minor

Not sure what this means? Click here to learn what changesets are.

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.35 KB 39.35 KB 0.00 KB (0.00%)
basic.ts 7.18 KB 7.18 KB 0.00 KB (0.00%)
batching.ts 11.06 KB 11.06 KB 0.00 KB (0.00%)
brand.ts 6.84 KB 6.84 KB 0.00 KB (0.00%)
cache.ts 11.49 KB 11.49 KB 0.00 KB (0.00%)
config.ts 22.77 KB 22.77 KB 0.00 KB (0.00%)
differ.ts 21.92 KB 21.92 KB 0.00 KB (0.00%)
http-client.ts 26.86 KB 26.86 KB 0.00 KB (0.00%)
http-router.ts 36.85 KB 36.85 KB 0.00 KB (0.00%)
logger.ts 11.96 KB 11.96 KB 0.00 KB (0.00%)
metric.ts 9.42 KB 9.42 KB 0.00 KB (0.00%)
optic.ts 7.05 KB 7.05 KB 0.00 KB (0.00%)
pubsub.ts 15.97 KB 15.97 KB 0.00 KB (0.00%)
queue.ts 12.77 KB 12.77 KB 0.00 KB (0.00%)
schedule.ts 11.74 KB 11.74 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.02 KB 14.02 KB 0.00 KB (0.00%)
schema-binary.ts 41.06 KB 41.06 KB 0.00 KB (0.00%)
schema-class.ts 21.65 KB 21.65 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.51 KB 29.51 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.91 KB 27.91 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.27 KB 15.27 KB 0.00 KB (0.00%)
schema-string.ts 12.26 KB 12.26 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.19 KB 16.19 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.87 KB 38.87 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.10 KB 26.10 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.83 KB 20.83 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.97 KB 20.97 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.07 KB 21.07 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.11 KB 26.11 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.16 KB 21.16 KB 0.00 KB (0.00%)
schema.ts 20.75 KB 20.75 KB 0.00 KB (0.00%)
stm.ts 14.15 KB 14.15 KB 0.00 KB (0.00%)
stream.ts 10.33 KB 10.33 KB 0.00 KB (0.00%)

@effect-bot
effect-bot force-pushed the feat/mcp-toolkit-input-required branch from dd2a883 to eb7f8a5 Compare October 29, 2026 01:29
@effect-bot
effect-bot force-pushed the feat/mcp-toolkit-input-required branch 4 times, most recently from 9bf6fcb to b0fc0d9 Compare October 29, 2026 03:07
@effect-bot
effect-bot force-pushed the feat/mcp-toolkit-input-required branch from b0fc0d9 to 742b004 Compare October 29, 2026 03:10
@effect-bot
effect-bot force-pushed the feat/mcp-toolkit-input-required branch from 742b004 to f60769b Compare October 29, 2026 03:15
@effect-bot
effect-bot force-pushed the feat/mcp-toolkit-input-required branch from f60769b to 078cff7 Compare October 29, 2026 03:16
@tim-smart
tim-smart deleted the branch Effect-TS:v4/next-minor October 29, 2026 03:31
@tim-smart tim-smart closed this Oct 29, 2026
@danizord

Copy link
Copy Markdown

Looks like this closed when v4/next-minor was reset, not on purpose. Could you reopen it? We need toolkit tools to return input_required too, and this design works for us.

@tim-smart tim-smart reopened this Oct 29, 2026
@effect-bot
effect-bot force-pushed the feat/mcp-toolkit-input-required branch from 82b9120 to de2feb3 Compare October 29, 2026 22:26
@tim-smart
tim-smart enabled auto-merge (squash) October 29, 2026 22:43
@tim-smart
tim-smart merged commit 2f6f859 into Effect-TS:v4/next-minor Oct 29, 2026
11 checks passed
effect-bot added a commit that referenced this pull request Nov 4, 2026
effect-bot added a commit that referenced this pull request Nov 4, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 5, 2026
effect-bot added a commit that referenced this pull request Nov 6, 2026
effect-bot added a commit that referenced this pull request Nov 6, 2026
effect-bot added a commit that referenced this pull request Nov 6, 2026
effect-bot added a commit that referenced this pull request Nov 6, 2026
effect-bot added a commit that referenced this pull request Nov 6, 2026
effect-bot added a commit that referenced this pull request Nov 6, 2026
effect-bot added a commit that referenced this pull request Nov 7, 2026
effect-bot added a commit that referenced this pull request Nov 7, 2026
effect-bot added a commit that referenced this pull request Nov 7, 2026
effect-bot added a commit that referenced this pull request Nov 8, 2026
tim-smart pushed a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants