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

Closed
opened 2026-02-16 17:45:26 -05:00 by yindo · 3 comments
Owner

Originally created by @danlapid on GitHub (Jan 11, 2026).

Originally assigned to: @thdxr on GitHub.

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

Originally created by @danlapid on GitHub (Jan 11, 2026). Originally assigned to: @thdxr on GitHub. ### 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
yindo closed this issue 2026-02-16 17:45:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

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

  • #7114: Claude Pro/Max authentication not usable over SSH (same issue with browser opening and inability to copy authorization URLs in remote/headless environments)

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

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be a duplicate of existing issues. Please check: - #7114: Claude Pro/Max authentication not usable over SSH (same issue with browser opening and inability to copy authorization URLs in remote/headless environments) Feel free to ignore if this doesn't address your specific case.
Author
Owner

@danlapid commented on GitHub (Jan 11, 2026):

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.

@danlapid commented on GitHub (Jan 11, 2026): 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.
Author
Owner

@bretthoerner commented on GitHub (Jan 12, 2026):

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.

@bretthoerner commented on GitHub (Jan 12, 2026): 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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4789