Skip to content

fix(mcp): retry initial 404 without injected codemode - #45563

Merged
rekram1-node merged 1 commit into
v2from
mcp-query-fallback
Aug 27, 2026
Merged

rekram1-node merged 1 commit into
v2from
mcp-query-fallback

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Related issue: #45499

Some MCP servers return 404 when OpenCode adds ?codemode=false, even though the configured URL works.

Type of change

  • Bug fix

What does this PR do?

On an initial connection 404, retry once with the original configured URL—but only if OpenCode added the codemode parameter.

  • Close the failed transport before creating a fresh client and transport.
  • Preserve user-supplied query parameters, headers, and the auth provider.
  • Leave other errors and the SDK's existing session recovery unchanged.

The retry lives only around connection setup, not tool calls or later requests.

How did you verify your code works?

From packages/core:

  • bun test test/mcp.test.ts test/mcp-instructions.test.ts test/plugin/mcp-codemode-exclusion.test.ts — 59 passed.
  • bun typecheck — passed.

Tests use a local HTTP server and the real MCP SDK. They cover successful fallback, encoded/repeated query parameters, preserved headers, a second 404, other HTTP errors, explicit codemode values, and a 404 after initialization. No live Figma Desktop test.

Screenshots / recordings

Not applicable; no UI changes.

Checklist

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

Requested by: @rekram1-node (Aiden via Slack)

@rekram1-node
rekram1-node merged commit 95c3c3f into v2 Aug 27, 2026
9 of 10 checks passed
@rekram1-node
rekram1-node deleted the mcp-query-fallback branch August 27, 2026 16:51
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant