Skip to content

Conversation

tommynguyen-vungle
Copy link

@tommynguyen-vungle tommynguyen-vungle commented Aug 19, 2025

Problem

The mcp-remote npm package was failing to connect to the MCP server with the error:
Fatal error: Error: Cannot find localhost callback URI from existing client information

The issue was that the OAuth authorization server metadata endpoint (/.well-known/oauth-authorization-server) was not advertising supported redirect URIs, which mcp-remote requires
to discover valid callback URLs for the OAuth flow.

Root Cause

The HandleAuthorizationServerMetadata function in internal/oauth/metadata.go was missing the redirect_uris field in the OAuth 2.0 Authorization Server Metadata response (RFC 8414).
This prevented OAuth clients like mcp-remote from discovering which callback URIs are supported for the authorization code flow.

Solution

Added redirect_uris field to the OAuth authorization server metadata response when OAUTH_REDIRECT_URI is configured:

// Add redirect URIs for mcp-remote compatibility
if h.config.RedirectURI != "" {
metadata["redirect_uris"] = []string{h.config.RedirectURI}
}

Configuration

For this fix to work, the server must be deployed with:
export OAUTH_REDIRECT_URI="https:///oauth/callback"

Testing

After deployment with the environment variable set, verify the fix works:
curl https:///.well-known/oauth-authorization-server

Should now include:
{
"redirect_uris": ["https:///oauth/callback"],
...
}

Impact

  • ✅ Enables mcp-remote to successfully discover callback URIs
  • ✅ Maintains backward compatibility (no redirect_uris if not configured)
  • ✅ Follows OAuth 2.0 RFC 8414 specification
  • ✅ No breaking changes to existing functionality

This allows clients using mcp-remote to successfully complete the OAuth authorization flow with the MCP server.

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
@tommynguyen-vungle tommynguyen-vungle merged commit 4161587 into main Aug 19, 2025
5 checks passed
tommynguyen-vungle added a commit that referenced this pull request Aug 20, 2025
* feat(oauth): add redirect URIs for mcp-remote compatibility (#5)

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Co-authored-by: Tommy Nguyen <tuannvm@hotmail.com>

* feat(oauth): allow client registration of redirect URIs (#6)

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Co-authored-by: Tommy Nguyen <tuannvm@hotmail.com>

---------

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Co-authored-by: Tommy Nguyen <tuannvm@hotmail.com>
tommynguyen-vungle added a commit that referenced this pull request Aug 20, 2025
* feat(oauth): add redirect URIs for mcp-remote compatibility (#5)

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Co-authored-by: Tommy Nguyen <tuannvm@hotmail.com>

* feat(oauth): allow client registration of redirect URIs (#6)

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Co-authored-by: Tommy Nguyen <tuannvm@hotmail.com>

---------

Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Co-authored-by: Tommy Nguyen <tuannvm@hotmail.com>
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.

2 participants