mcp: expose request options through InvokeOptions - #1988
Open
leeweisern wants to merge 1 commit into
Open
leeweisern wants to merge 1 commit into
leeweisern wants to merge 1 commit into
Conversation
MCP tool calls are capped at the client SDK's 60s default request timeout with no way for a caller to extend it. Long-running tools — deployments, builds, batch operations — fail at the one-minute mark. Add four fields to InvokeOptions (timeoutMs, maxTotalTimeoutMs, resetTimeoutOnProgress, onProgress) and map them onto the MCP SDK's per-request RequestOptions inside the mcp plugin's callTool hop. InvokeOptions already threads from executor.execute() through plugin.invokeTool, so this stays additive: callers that set nothing keep the SDK defaults, and other plugins ignore fields they don't consume.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MCP tool calls are capped at the client SDK's 60s
DEFAULT_REQUEST_TIMEOUT_MSEC; a caller has no way to extend it, so long-running tools (deploys, builds, batch jobs) always die at the one-minute mark.Where the options flow
invokeOptionsalready reachesplugin.invokeTooluntouched; only the MCP plugin reads the new fields. Other plugins (openapi, graphql) keep ignoring them.New surface
Mapped to
RequestOptions(timeout/maxTotalTimeout/resetTimeoutOnProgress/onprogress) inpackages/plugins/mcp/src/sdk/invoke.ts.signalis deliberately not exposed: Effect interruption already abandons the fiber, and a caller-heldAbortSignalwould have to outlive the pooled connection lease.Progress-reset
sequenceDiagram participant C as caller participant E as executor participant S as MCP server C->>E: execute(addr, args, { timeoutMs: 60_000,<br/>resetTimeoutOnProgress: true }) E->>S: tools/call S-->>E: notifications/progress (t+50s) Note over E: request timer resets S-->>E: notifications/progress (t+100s) Note over E: request timer resets S-->>E: result (t+140s) E-->>C: resultDesign choice
Generic fields on
InvokeOptionsrather than a transport-specificrequestOptionspassthrough: callers shouldn't name MCP internals to say "let this run longer", only the MCP plugin consumes them today, and a future HTTP plugin can map the same fields onto its own timeouts.Verification
vitest run src/sdk/invoke.test.ts— 9/9 pass, including three new cases: options map ontocallToolRequestOptions,onprogressroutes toonProgress, and omittinginvokeOptionspasses no RequestOptions (SDK defaults untouched).vitest run src/sdk/elicitation.test.ts— 6/6 pass (pooled-connection path still works).vitest run src/executor.test.ts src/promise.test.ts(core/sdk) — 35/35 pass.tsgo --noEmitonpackages/plugins/mcpandpackages/core/sdk— clean (pre-existing lint suggestions only).oxlint --deny-warningsandoxfmton touched files — clean.