Skip to content

Extensions/tools using openExternalUrl silently fail — OAuth flows broken for tools in terminal #7946

Description

@mvn-bachhuynh-dn

ACP/Extension openExternalUrl silently fails — OAuth flows broken for tools running in code-server terminal

Summary

When CLI tools running inside a code-server terminal session use the ACP (Agent Communication Protocol) openExternalUrl capability to open an OAuth authorization URL in the user's browser, the request is silently dropped. No browser window opens, no error is returned to the caller, and no fallback mechanism is provided.

This breaks OAuth authentication for any MCP (Model Context Protocol) server that requires browser-based login, including:

  • Atlassian Rovo MCP
  • Cloudflare MCP
  • Any OAuth 2.0 PKCE flow relying on localhost callback

Environment

  • code-server: accessed via HTTPS reverse proxy (e.g., https://code.example.com)
  • Host OS: Linux (Ubuntu)
  • Client: macOS browser (Safari/Chrome)
  • Tool: Kiro CLI 2.16.2 running in code-server's integrated terminal
  • Protocol: ACP with openExternalUrl capability negotiated successfully

Reproduction Steps

  1. Access code-server from a browser on macOS
  2. Open integrated terminal
  3. Run kiro-cli chat
  4. Kiro negotiates ACP capabilities including openExternalUrl: true
  5. Configure an OAuth-based MCP server (e.g., Atlassian)
  6. Trigger authentication — Kiro sends _kiro/openExternalUrl with the OAuth URL
  7. Nothing happens — no browser opens, no error surfaces

Expected Behavior

One of:

  1. code-server forwards the openExternalUrl request to the client browser and opens the URL in a new tab
  2. If opening is not possible, code-server returns an error/rejection so the calling tool can fall back (e.g., print the URL for manual copy)
  3. code-server provides a notification/toast with the URL that the user can click

Actual Behavior

  • The ACP capability openExternalUrl is advertised as supported during handshake
  • The actual openExternalUrl request is received but silently dropped
  • No browser opens on the client machine
  • No error is returned to the requesting tool
  • The tool (Kiro) waits for an OAuth callback that never arrives, eventually timing out

Analysis

code-server's integrated terminal runs on the remote host. When a tool calls openExternalUrl, there are two issues:

  1. No browser on remote: The remote Linux host typically has no display server or browser. xdg-open or equivalent fails silently.
  2. No forwarding to client: Unlike VS Code Remote SSH (which forwards vscode.env.openExternal to the local VS Code instance), code-server does not appear to relay external URL open requests to the connected browser client.

The VSCODE_PROXY_URI environment variable is set (e.g., https://code.example.com/proxy/{{port}}/), but this only handles port forwarding for HTTP services, not arbitrary URL opening.

Suggested Solutions

  1. Implement client-side URL forwarding: When openExternal / openExternalUrl is called, relay the request via WebSocket to the connected browser and open it in a new tab using window.open().
  2. Return an error when forwarding is unavailable: Instead of silently dropping the request, return a rejection so tools can implement fallback behavior (displaying the URL for manual copy).
  3. Show a notification: Display a toast/notification in the code-server UI with the URL as a clickable link, similar to how VS Code shows "open in browser" prompts for forwarded ports.

Impact

This affects any tool, extension, or CLI application running in code-server's terminal that needs to open a URL in the user's browser. OAuth flows for MCP servers are a prominent use case, but this also affects:

  • Git credential helpers with browser-based auth
  • Cloud CLI login flows (e.g., gcloud auth login, aws sso login)
  • Any tool using xdg-open or equivalent

Workaround

For OAuth specifically with fixed localhost callbacks:

  1. Configure the tool to use a fixed callback port
  2. Set up SSH local port forwarding from the client machine to the remote host
  3. Manually obtain and open the authorization URL (requires tool-specific patching or log inspection)

See related Kiro CLI issue for detailed workaround steps.

Labels

bug, feature-request, terminal, oauth, remote

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode-serverneeds-investigationThis issue needs to be further investigated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions