fix(mcp): bind oauth callback to IPv4 loopback by he-yufeng · Pull Request #30022 · anomalyco/opencode · GitHub
Skip to content

fix(mcp): bind oauth callback to IPv4 loopback#30022

Merged
rekram1-node merged 1 commit into
anomalyco:devfrom
he-yufeng:fix/oauth-callback-ipv4
Jun 24, 2026
Merged

fix(mcp): bind oauth callback to IPv4 loopback#30022
rekram1-node merged 1 commit into
anomalyco:devfrom
he-yufeng:fix/oauth-callback-ipv4

Conversation

@he-yufeng

@he-yufeng he-yufeng commented May 30, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #30013
Closes #31824
Relates to: #28567

Type of change

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

What does this PR do?

The MCP OAuth callback server used server.listen(port) without a host. On Linux this can bind to the IPv6 wildcard address. In WSL2, callbacks opened in the Windows browser can fail to reach that socket through localhost forwarding.

This binds the callback server to 127.0.0.1 explicitly, matching the default redirect URI and keeping the server loopback-only. The port-in-use probe already checks 127.0.0.1, so startup detection and the actual listener now use the same address family.

How did you verify your code works?

  • bun --cwd packages/opencode test test/mcp/oauth-callback.test.ts
  • bun run --cwd packages/opencode typecheck
  • bunx prettier --check packages/opencode/src/mcp/oauth-callback.ts packages/opencode/test/mcp/oauth-callback.test.ts
  • bunx oxlint packages/opencode/src/mcp/oauth-callback.ts packages/opencode/test/mcp/oauth-callback.test.ts
  • git diff --check

Screenshots / recordings

No screenshot. This changes local OAuth callback socket binding, not UI layout.

Checklist

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

@he-yufeng

Copy link
Copy Markdown
Contributor Author

@he-yufeng he-yufeng force-pushed the fix/oauth-callback-ipv4 branch from 0af4263 to 5466d99 Compare June 16, 2026 08:21
@he-yufeng

Copy link
Copy Markdown
Contributor Author

@rekram1-node rekram1-node merged commit af31e97 into anomalyco:dev Jun 24, 2026
4 checks passed
BenGu3 pushed a commit to BenGu3/opencode that referenced this pull request Jun 27, 2026
josechifflet pushed a commit to josechifflet/opencode that referenced this pull request Jun 27, 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

2 participants