Skip to content

Conversation

@chrisolszewski
Copy link
Contributor

@chrisolszewski chrisolszewski commented Jan 17, 2026

Adds mcp.<name>.oauth.callbackHost to control the bind address for the OAuth callback server. This helps in WSL2, Docker, and devcontainers where the host browser can’t reach the callback listener.

Default behavior is unchanged when unset. When set, we pass hostname to Bun.serve() and restart the callback server if the host changes.

Also escapes the callback error page output and documents the troubleshooting step in the MCP server docs.

Testing:

  • bun run typecheck
  • bun test test/mcp/oauth-callback.test.ts
  • bun test test/config/config.test.ts

Fixes #9081

Add optional callbackHost field to MCP OAuth config that controls
the bind address for the OAuth callback server. Useful for WSL2,
Docker, and devcontainer environments where the default loopback
bind is not reachable from the host browser.

- Add callbackHost to McpOAuth schema with .min(1) validation
- Update ensureRunning(opts?) with backward-compatible signature
- Track currentHost and restart server on host change
- Normalize 0.0.0.0 to 127.0.0.1 for port-in-use checks
- Fix HTML injection in error page (escapeHtml)
- Add config validation tests
- Document in mcp-servers.mdx Debugging section
@github-actions
Copy link
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
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR:

The other OAuth-related PRs found (#2453, #5781, #6974, #7765, #5537, #5782) appear to be either older, closed, or addressing different OAuth features (like PKCE, GitHub Copilot, OpenRouter) rather than MCP-specific callback configuration.

Summary: While #9034 is related to MCP OAuth configuration, it appears to focus on redirect URI configuration rather than the callback host binding address that PR #9078 addresses. They could be complementary changes to the same feature area.

@chrisolszewski
Copy link
Contributor Author

Note #9034 was reverted due to regressions. This change avoids any redirectUri plumbing and is focused on the optional bind host for the callback server. I can make this more clear in the PR description if necessary.

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.

WSL2/devcontainer: MCP OAuth callback unreachable from host browser (Sentry)

1 participant