Skip to content

Conversation

@danlapid
Copy link

@danlapid danlapid commented Jan 11, 2026

When running opencode mcp auth in headless environments (SSH, devcontainers, WSL), the browser cannot be opened automatically. Previously this would fail with a cryptic "Something went wrong" error. Now the auth URL is displayed so users can manually open it in their local browser.

The fix catches three failure modes from the open package:

  • Synchronous exception: thrown when open() itself fails
  • "error" event: fires when the command doesn't exist (ENOENT)
  • "exit" event with non-zero code: fires when the command exists but fails (e.g., xdg-open can't connect to a display server)

What does this PR do?

Description above.

How did you verify your code works?

I tested this on my vscode devcontainer that was initially having this issue.

Fixes #7887

When running `opencode mcp auth` in headless environments (SSH,
devcontainers, WSL), the browser cannot be opened automatically.
Previously this would fail with a cryptic "Something went wrong" error.
Now the auth URL is displayed so users can manually open it in their
local browser.

The fix catches three failure modes from the `open` package:
- Synchronous exception: thrown when open() itself fails
- "error" event: fires when the command doesn't exist (ENOENT)
- "exit" event with non-zero code: fires when the command exists but
  fails (e.g., xdg-open can't connect to a display server)
@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:

No duplicate PRs found

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.

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

1 participant