Skip to content

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

Closed as not planned

Description

@chrisolszewski

Description

OAuth auth for the Sentry MCP server fails for me when OpenCode is running inside WSL2 (or a container/devcontainer) but the browser is on the host.

After auth, the provider redirects to something like http://127.0.0.1:19876/mcp/oauth/callback, but the host browser can’t reach the callback listener inside WSL/container (connection refused / timeout). OpenCode never receives the callback, so the flow doesn’t complete.

Proposed fix

Allow configuring the bind host for the callback listener per server (opt-in, default unchanged). PR #9078 implements this approach.

Note: binding to 0.0.0.0 can expose the callback port; docs should warn. In containers you may also need to publish/forward port 19876.

Plugins

none

OpenCode version

v1.1.25

Steps to reproduce

  1. Configure:
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "sentry": {
      "type": "remote",
      "url": "https://mcp.sentry.dev/mcp",
      "oauth": {}
    }
  }
}
  1. Run opencode mcp auth sentry
  2. Complete auth in the host browser
  3. Redirect back to 127.0.0.1:19876 fails / OpenCode keeps waiting.

Operating System

Windows 11 / WSL2 - Ubuntu 24.04

Terminal

Wezterm

Activity

  1. github-actions commented on Jan 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These issues all address the core problem of OAuth callback reachability in remote/containerized environments. Feel free to ignore if your specific case requires a different approach.

  2. chrisolszewski commented on Jan 17, 2026

    @chrisolszewski
    ContributorAuthor

    Bot flagged related issues, but this is about the callback listener’s bind interface. #7377/#5766 focus on redirectUri validation (provider-side), and #8274/#8798/#7887 are about remote/proxy/launch issues. In WSL2/containers, even with a valid redirectUri the host browser can still get "connection refused" if the listener is only bound to loopback. This issue/PR adds an opt‑in bind host to make the listener reachable. Complementary, not duplicate.

  3. j-token commented on Jan 21, 2026

    @j-token

    I’m having the exact same issue.

    When authenticating via opencode mcp auth, the same problem occurs, and this issue didn’t happen when I was working on a Mac.

  4. kjbetz commented on Feb 19, 2026

    @kjbetz

    It looks like there's some work to fix this. As noted in this comment: #7377 (comment)

    Changing the callback URL from 127.0.0.1 to localhost worked for me in getting the Stripe MCP set up and completing the OAuth flow.

  5. mattrossman commented on Feb 26, 2026

    @mattrossman

    I faced this issue running OpenCode through SSH on a remote Ubuntu server—I was unable to authenticate Notion MCP due to the 127.0.0.1 redirect URL.

    A workaround is after you complete authentication in the host browser, copy the/callback URL from the browser and use curl on the remote machine to complete the OAuth flow (where 127.0.0.1 can be resolved).

    # On the machine running `opencode mcp auth`
    curl "http://127.0.0.1:19876/whatever-is-in-browser-url-bar..."

    Hopefully the PR mentioned above will make this more streamlined!

  6. github-actions commented on Apr 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions