copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

[BUG]: MCP OAuth callback unreachable when running in remote container / Codespaces — no manual token paste fallback

Open velimattiv opened this issue 7 months ago • 3 comments

Describe the bug

When running Copilot CLI inside a remote container (e.g., GitHub Codespaces, Dev Containers), the MCP OAuth flow redirects to a localhost callback URL that is unreachable from the user's browser. There is no mechanism to manually paste the authorization code/callback URL back into the CLI, unlike Claude Desktop which provides a dialog for this.

Affected version

1.0.36

Steps to reproduce

  1. Run Copilot CLI inside a GitHub Codespace or remote dev container
  2. Add an HTTP MCP server that requires OAuth
  3. Run /mcp → trigger auth → browser opens and user authorises
  4. Browser attempts to redirect to http://127.0.0.1:<port>/?code=...&state=...
  5. Redirect fails — localhost resolves to the user's local machine, not the container
  6. OAuth handshake never completes; MCP server remains unauthenticated

Expected behavior

The CLI should either: (a) detect that the callback was not received and prompt the user to paste the callback URL manually, or (b) provide a /mcp auth paste style command to accept the code out-of-band.

Workaround

Paste the callback URL to an AI agent running inside the container and have it curl the URL against the local listener. Not a user-friendly solution.

Additional context

Claude Desktop handles this via a dedicated token paste dialog. Related to #1491 (random port issue) but distinct — this is specifically about remote container environments where localhost is unreachable from the browser.

velimattiv avatar Apr 27 '26 23:04 velimattiv

+1 this is broken when using the CLI in an SSH session

petercort avatar Sep 16 '26 13:09 petercort

Thanks for the report. This is still valid: MCP OAuth relies only on a localhost callback listener and has no fallback for pasting the redirect URL or code, so it fails in Codespaces, dev containers and SSH sessions unless the port is forwarded. We've moved this to the backlog.

hstaudacher avatar Nov 18 '26 16:11 hstaudacher