Skip to content

Comments

fix: add onprogress callback to MCP tool calls for timeout renewal#14501

Open
jaried wants to merge 1 commit intoanomalyco:devfrom
jaried:bug-001-clean
Open

fix: add onprogress callback to MCP tool calls for timeout renewal#14501
jaried wants to merge 1 commit intoanomalyco:devfrom
jaried:bug-001-clean

Conversation

@jaried
Copy link

@jaried jaried commented Feb 20, 2026

Issue for this PR

Closes #14499

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes the -32001 timeout error that occurs during long-running MCP tool calls (10~20 minutes) by adding the onprogress callback to the MCP client's callTool options.

Root Cause:
The MCP SDK only injects a progressToken into the request when an onprogress callback is provided. Without this token:

  1. The MCP server cannot send progress notifications (heartbeat)
  2. The client's timeout timer never resets
  3. Long requests hit the default timeout limit

The Fix:
Added a lightweight onprogress: () => undefined callback in convertMcpTool function. This enables:

  • SDK to inject _meta.progressToken into the request
  • MCP server to send periodic progress/heartbeat notifications
  • Client timeout to reset when progress is received (via resetTimeoutOnProgress: true)

Why it works:
The progress token chain is now complete:

  1. Client includes onprogress callback
  2. SDK injects _meta.progressToken into request
  3. Server reads token and sends progress notifications
  4. SDK resets timeout on each progress notification
  5. Long-running requests can complete without timing out

How did you verify your code works?

Added unit test packages/opencode/test/mcp/progress-token.test.ts that verifies:

  • callTool options include onprogress callback
  • resetTimeoutOnProgress is still true
  • timeout is correctly passed through

Test result: ✅ Pass

Screenshots / recordings

N/A - backend fix

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- Add onprogress callback in convertMcpTool to enable progressToken injection
- This allows MCP server heartbeat to reset request timeout
- Fixes -32001 timeout errors on long-running tool calls (10-20 min)
- Add unit test to verify onprogress handler is included in call options

Closes anomalyco#14499
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.

BUG-001: MCP tool call missing progressToken injection causing timeout on long reviews (-32001)

1 participant