Skip to content

fix(mcp): pass onprogress so resetTimeoutOnProgress actually works#24964

Open
fahreddinozcan wants to merge 2 commits intoanomalyco:devfrom
fahreddinozcan:fix/mcp-progress-token-injection
Open

fix(mcp): pass onprogress so resetTimeoutOnProgress actually works#24964
fahreddinozcan wants to merge 2 commits intoanomalyco:devfrom
fahreddinozcan:fix/mcp-progress-token-injection

Conversation

@fahreddinozcan
Copy link
Copy Markdown

@fahreddinozcan fahreddinozcan commented Apr 29, 2026

Issue for this PR

Closes #24965

Type of change

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

What does this PR do?

Hey, I'm from Context7 team. We've been having some issues with the long running requests on OpenCode, simply because OpenCode does not comply to the MCP spec for notifications. Basically, the client can't receive any notifications from the server right now.

The MCP SDK only injects a progressToken into outbound _meta when options.onprogress is set (see related code snippet). Without it, the server can't address progress notifications back to the in-flight request, _onprogress early-returns on "unknown token" before the timer-reset block, and resetTimeoutOnProgress: true never fires. Long-running MCP tools therefore time out at the SDK default of 60s even when the server emits progress.

Adding a no-op onprogress unblocks the existing intent of the call: the SDK now sends the progressToken, the server can ping it, and the per-request timer resets on each notification.

How did you verify your code works?

Tested against an MCP server that emits a notifications/progress every 20s during a tool call whose total runtime exceeds 60s.

Before this change, the request the client sent contained no _meta.progressToken, so the server had nothing to address its progress notifications to. The MCP client never received a single progress notification, the per-request timer fired at the 60s default, and the call ended in MCP error -32001: Request timed out.

After this change, the request includes _meta.progressToken, the server emits progress notifications normally, opencode receives them and resets its per-request timer on each one. The tool call completes successfully even when its total runtime is several minutes. opencode's logs show one progress notification log line per server emission throughout the call.

Screenshots / recordings

N/A (no UI change).

Checklist

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

The MCP SDK only injects a progressToken into outbound _meta when
options.onprogress is set (see @modelcontextprotocol/sdk Protocol.request).
Without it, the server can't address progress notifications back to the
in-flight request, _onprogress early-returns on "unknown token" before
the timer-reset block, and resetTimeoutOnProgress: true never fires.
Long-running MCP tools therefore time out at the SDK default of 60s
even when the server emits progress.

Adding a no-op onprogress unblocks the existing intent of the call: the
SDK now sends the progressToken, the server can ping it, and the per-
request timer resets on each notification.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node
Copy link
Copy Markdown
Collaborator

vouch

opencode-agent Bot pushed a commit that referenced this pull request Apr 29, 2026
oleksii-honchar pushed a commit to oleksii-honchar/better-opencode that referenced this pull request Apr 29, 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.

[BUG]: opencode doesn't receive progress notifications from MCP servers

2 participants