Skip to content

OAuth discovery fails for Smithery servers due to non-standard metadata path #251

Closed

Description

@Dumbris

Summary

mcpproxy fails to authenticate with Smithery.ai hosted MCP servers because Smithery uses a non-standard path for OAuth authorization server metadata that mcpproxy doesn't discover.

Environment

  • mcpproxy version: development
  • Server: https://server.smithery.ai/googledrive
  • OS: macOS

Problem

When connecting to Smithery servers, mcpproxy correctly:

  1. Receives 401 with WWW-Authenticate header pointing to protected resource metadata
  2. Fetches protected resource metadata successfully

But fails at step 3 because Smithery uses a non-standard path for authorization server metadata.

Standard vs Smithery Paths

Endpoint Standard Path (RFC 8414) Smithery Path
Auth Server Metadata https://auth.smithery.ai/googledrive/.well-known/oauth-authorization-server https://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive

The standard puts .well-known after the path segment, but Smithery inserts .well-known between host and path.

Actual Server Responses

Protected Resource Metadata (works)

curl https://server.smithery.ai/.well-known/oauth-protected-resource/googledrive
{
  "authorization_servers": ["https://auth.smithery.ai/googledrive"],
  "resource": "https://server.smithery.ai/googledrive"
}

Auth Server Metadata - Standard Path (404)

curl https://auth.smithery.ai/googledrive/.well-known/oauth-authorization-server
# Returns: Cannot GET /googledrive/.well-known/oauth-authorization-server

Auth Server Metadata - Smithery Path (works)

curl https://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive
{
  "issuer": "https://auth.smithery.ai/googledrive",
  "authorization_endpoint": "https://auth.smithery.ai/googledrive/authorize",
  "token_endpoint": "https://auth.smithery.ai/googledrive/token",
  "registration_endpoint": "https://auth.smithery.ai/googledrive/register",
  "response_types_supported": ["code"],
  "code_challenge_methods_supported": ["S256"],
  "grant_types_supported": ["authorization_code", "refresh_token"],
  "token_endpoint_auth_methods_supported": ["none", "client_secret_post"]
}

mcpproxy Logs

ERROR | OAuth metadata validation failed | {"server": "googledrive-smithery", "error_type": "oauth_metadata_missing"}

How Other Clients Handle This

According to MCP spec and RFC 9728, clients should try multiple discovery strategies:

  1. WWW-Authenticate Header: Parse resource_metadata URL from 401 response
  2. Path insertion: For https://auth.example.com/path, try https://auth.example.com/.well-known/oauth-authorization-server/path
  3. Suffix path: Try https://auth.example.com/path/.well-known/oauth-authorization-server

The official MCP TypeScript SDK has similar issues (see modelcontextprotocol/typescript-sdk#762).

Proposed Solutions

Option 1: Try Multiple Discovery Paths

When discovering auth server metadata, try both:

{auth_server}/.well-known/oauth-authorization-server  # Standard
{auth_server_base}/.well-known/oauth-authorization-server/{path}  # Alternative

Option 2: Support Manual Metadata URL Override

Allow specifying metadata_url in OAuth config:

{
  "oauth": {
    "metadata_url": "https://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive"
  }
}

Option 3: Parse WWW-Authenticate Resource Metadata

The 401 response includes:

WWW-Authenticate: Bearer resource_metadata="https://server.smithery.ai/.well-known/oauth-protected-resource/googledrive"

Use this to discover the full OAuth chain without relying on path conventions.

Related Issues

Config Attempted (not working)

{
  "name": "googledrive-smithery",
  "url": "https://server.smithery.ai/googledrive",
  "protocol": "http",
  "oauth": {
    "provider": "google",
    "scopes": ["https://www.googleapis.com/auth/drive.readonly"],
    "issuer": "https://auth.smithery.ai/googledrive",
    "auth_url": "https://auth.smithery.ai/googledrive/authorize",
    "token_url": "https://auth.smithery.ai/googledrive/token",
    "metadata_url": "https://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive"
  }
}

The manual auth_url, token_url, and metadata_url fields are not being used by mcpproxy for OAuth discovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions