fix(mcp): bind oauth callback to IPv4 loopback
Merged
HE
4mo ago+45+45+01234567890123456789-1-1-0123456789
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.tsbun run --cwd packages/opencode typecheckbunx prettier --check packages/opencode/src/mcp/oauth-callback.ts packages/opencode/test/mcp/oauth-callback.test.tsbunx oxlint packages/opencode/src/mcp/oauth-callback.ts packages/opencode/test/mcp/oauth-callback.test.tsgit 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