Skip to content

opencode mcp auth fails silently in remote/headless sessions (SSH, devcontainer) #7887

Closed

Description

@danlapid

Description

When running opencode mcp auth in a remote or headless environment (SSH, devcontainer, WSL without display), the command fails with a cryptic "Something went wrong" error because it cannot open a browser.

The open package tries to launch xdg-open (on Linux) which either:

  • Doesn't exist (ENOENT error)
  • Exists but fails because there's no display server

In both cases, the user has no way to complete the OAuth flow because the authorization URL is not shown.

Expected Behavior

When browser opening fails, the authorization URL should be displayed so users can manually copy it and open it in a browser on their local machine.

Actual Behavior

$ opencode mcp auth jira --log-level DEBUG --print-logs true
...
INFO  opening browser for oauth
▲  Something went wrong
ERROR e=Executable not found in $PATH: "xdg-open" exception

OpenCode version

1.1.8

Steps to reproduce

  1. SSH into a remote server or use a devcontainer
  2. Run opencode mcp auth <server-name>
  3. Observe the error with no actionable information

Operating System

Linux (tested in devcontainer)

Terminal

Any

Activity

  1. github-actions commented on Jan 11, 2026

    @github-actions
    Contributor

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

    Feel free to ignore if this doesn't address your specific case.

  2. danlapid commented on Jan 11, 2026

    @danlapid
    ContributorAuthor

    I did read #7114 and I don't think it's an exact duplicate, this issue is very specific the other is a bit general and vague.

  3. bretthoerner commented on Jan 12, 2026

    @bretthoerner

    I ran into this, too. Getting around xdg-open requirement is one step, I did this to try and move forward:

    #!/bin/bash
    # Install at: /usr/local/bin/xdg-open
    # Opens URL in host browser via VS Code's browser helper
    if [[ -n "$BROWSER" ]]; then
        "$BROWSER" "$1"
    else
        echo "xdg-open: $1"
    fi
    

    That opens the browser for auth just fine, but the callback URL is http://127.0.0.1:19876/mcp/oauth/callback and when I look in my devcontainer (which is patiently waiting now, rather than giving the Something went wrong error) I don't see opencode (or anything) listening on 19876. So even with the port forwarded to the devcontainer, clicking anything in my browser just hangs.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions