Skip to content

Fix CE mode OAuth to use localhost redirect for unregistered providers#349

Draft
OzairP wants to merge 3 commits into
docker:mainfrom
OzairP:fix/ce-mode-localhost-oauth-redirect
Draft

Fix CE mode OAuth to use localhost redirect for unregistered providers#349
OzairP wants to merge 3 commits into
docker:mainfrom
OzairP:fix/ce-mode-localhost-oauth-redirect

Conversation

@OzairP

@OzairP OzairP commented Jan 20, 2026

Copy link
Copy Markdown

Problem

When using CE mode (DOCKER_MCP_USE_CE=true) to authorize remote MCP servers not in Docker's provider registry (e.g., Honeycomb), OAuth fails with "provider not found" after completing consent.

Root cause: CE mode registered DCR clients with mcp.docker.com/oauth/callback, but Docker's proxy only routes callbacks for pre-registered providers.

Solution

  1. Create callback server first to get localhost URL
  2. Register DCR with localhost redirect instead of Docker proxy
  3. Only apply CE mode to remote servers (container servers still use Desktop OAuth)

Changes

  • pkg/oauth/manager.go: Add NewManagerWithRedirectURI() constructor
  • cmd/docker-mcp/oauth/auth.go: CE mode uses localhost redirect for remote servers
  • pkg/oauth/manager_test.go: Test for new constructor

Testing

  • All OAuth tests pass
  • Manual: Honeycomb OAuth works with CE mode
  • Manual: GitHub OAuth works via Desktop mode

Add a new constructor that accepts a custom redirect URI parameter.
This enables callers to specify localhost callbacks instead of the
default mcp.docker.com proxy, which is needed for OAuth providers
not registered in Docker's provider registry.

The existing NewManager() delegates to the new constructor with
the default redirect URI, maintaining backward compatibility.
Fix OAuth authorization for remote MCP servers not registered in
Docker's provider registry (e.g., Honeycomb).

Problem:
CE mode registered DCR clients with mcp.docker.com/oauth/callback as
the redirect URI, but Docker's proxy only routes callbacks for
pre-registered providers. Unregistered providers like Honeycomb would
complete the OAuth consent flow successfully, but the callback routing
would fail with 'provider not found'.

Solution:
- Create the callback server first to get the localhost URL
- Register DCR client with localhost redirect URI directly
- Only apply CE mode to remote servers (container-based servers like
  github-official still use Docker Desktop OAuth)

This allows any remote MCP server that supports OAuth Discovery
(RFC 9728) and Dynamic Client Registration (RFC 7591) to work with
the MCP Gateway, regardless of whether it's in Docker's provider
registry.
Verify that the new constructor correctly initializes all manager
components with the custom redirect URI.
@OzairP OzairP mentioned this pull request Jan 20, 2026
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.

1 participant