Skip to content

Allow a fixed OAuth callback port for remote MCP servers #5391

Description

@simon-hugosson-nexer

Problem

For a remote MCP server with a pre-registered OAuth client (oauthClientId and oauthPublicClient in mcp-config.json), the CLI listens on a random loopback port (listen(0, "127.0.0.1")) and sends redirect_uri=http://127.0.0.1:<random>/. Authorization servers that match redirect URIs exactly, with no wildcards and no dynamic client registration, can't be used.

Looker's managed MCP server is one. Its documentation says it needs a fixed port per client, and lists --callback-port for Claude Code and OAUTH_CALLBACK_PORT for Gemini CLI. With the Copilot CLI, sign-in fails with "redirect_uri" mismatch on most attempts (ports 35731 and 36449 seen).

Request

A per-server setting, for example oauthCallbackPort, in mcp-config.json, or a global environment variable such as COPILOT_OAUTH_CALLBACK_PORT. The CLI would then use http://127.0.0.1:<port>/ and fail clearly if the port is taken.

Version

Copilot CLI 1.0.105, Linux.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registry

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions