Skip to content

Track upstream: MCP Client OAuth/DCR Compatibility Issues - Scope and Authentication Problems #234

@cbcoutinho

Description

@cbcoutinho

MCP Client OAuth/DCR Compatibility: Scope and Authentication Issues

Summary

Common MCP clients (Claude Code, Google Gemini CLI, GitHub Copilot) have incomplete support for OAuth-enabled MCP servers, particularly when Dynamic Client Registration (DCR) is enabled. These clients fail to:

  1. Request required OAuth scopes
  2. Handle various OAuth discovery mechanisms
  3. Work with enterprise OAuth providers that don't support DCR
  4. Properly discover OAuth configuration from WWW-Authenticate headers

This significantly limits the ability of this Nextcloud MCP server to work with these clients in OAuth mode.

Impact on Nextcloud MCP Server

  • OAuth mode is experimental (as documented in README.md) and faces compatibility issues with major MCP clients
  • Users attempting to use OAuth with Claude Code, Gemini CLI, or Copilot may experience authentication failures
  • Enterprise deployments using Azure AD/Entra ID, Okta, or other providers face additional challenges
  • This is in addition to the existing upstream Nextcloud issues tracked in Track upstream: Bearer token authentication failing for app-specific APIs (user_oidc#1221) #209 (Bearer token support in user_oidc app)

Root Causes

1. Dynamic Client Registration (DCR) Requirements

Problem: Claude Code requires DCR support per RFC 7591, but:

  • Many enterprise OAuth providers (Azure AD, Okta) don't support DCR
  • Providers that support DCR often require pre-provisioned API keys to access the registration endpoint
  • Clients don't support manual client ID/secret specification as a fallback

Example: Azure AD integration fails with:

AADSTS70011: The provided request must include a 'scope' input parameter.
The provided value for the input parameter 'scope' is not valid.

2. Scope Parameter Issues

Problem: MCP clients are not requesting proper OAuth scopes when DCR is enabled:

  • Clients may not send scope parameter at all
  • Clients send invalid or incomplete scope values
  • No standard mechanism for MCP servers to communicate required scopes to clients

Impact: Authorization servers reject requests due to missing or invalid scopes

3. OAuth Discovery Failures

Problem: Clients fail to properly discover OAuth configuration:

  • Gemini CLI: Cannot extract resource_metadata from WWW-Authenticate header, tries wrong discovery endpoint (.well-known/oauth-authorization-server instead of following the resource_metadata URL)
  • Claude Code: "Immediately tries to connect to /.well-known/oauth-authorization-server and ignores the resource_metadata in the www-authenticate header"
  • Inconsistent handling of RFC 8414 (OAuth Authorization Server Metadata) vs RFC 9728 (OAuth Protected Resource Metadata)

4. Architectural Design Issues

Problem: Current MCP auth implementation treats MCP servers as OAuth authorization servers, requiring every MCP server to implement:

  • Discovery endpoints
  • Registration endpoints
  • Authorization endpoints
  • Token endpoints

Proposed solution: Treat MCP servers as OAuth resource servers, allowing them to leverage existing identity providers/authorization servers (see modelcontextprotocol/modelcontextprotocol#205)

Upstream Issues

MCP Specification Repository

Claude Code Repository

Google Gemini CLI Repository

FastMCP Repository

Technical Details

OAuth Discovery Mechanisms

The MCP specification supports multiple OAuth discovery mechanisms, but clients implement them inconsistently:

  1. RFC 9728 - OAuth 2.0 Protected Resource Metadata: Server returns WWW-Authenticate header with resource_metadata URL
  2. RFC 8414 - OAuth Authorization Server Metadata: Discovery at /.well-known/oauth-authorization-server

GitHub MCP Server example:

WWW-Authenticate: Bearer error="invalid_request",
  error_description="No access token was provided in this request",
  resource_metadata="https://api.githubcopilot.com/.well-known/oauth-protected-resource/mcp"

Gemini CLI fails to extract this and tries the wrong endpoint.

Scope Communication Problem

  • OAuth servers need to know which scopes to grant
  • MCP specification doesn't define standard scopes
  • Clients don't have a mechanism to discover required scopes from MCP servers
  • Some clients don't send scope parameter at all when using DCR

Provider Compatibility Matrix

Provider DCR Support Status Notes
Azure AD/Entra ID ❌ No Broken Requires pre-registration, fixed redirect URIs
Okta ⚠️ Requires API Key Broken DCR endpoint requires admin credentials
AWS Cognito ❌ No Broken Requires custom implementation with Lambda/API Gateway
Auth0 ✅ Yes May work DCR supported (requires testing)
Keycloak ✅ Yes May work DCR supported (requires testing)
GitHub ❌ Special Complex Uses RFC 9728 but clients fail to discover properly

Proposed Solutions (from Community)

SEP-991: Client ID Metadata Documents

  • Allow OAuth clients to use HTTPS URLs as client identifiers
  • URL points to JSON document with client metadata
  • Addresses MCP scenarios where servers/clients have no pre-existing relationship
  • Enables servers to trust clients based on verified metadata

SEP-1299: Simplified Flow

  • Move OAuth flow management from MCP clients to MCP servers
  • Use HTTP Message Signatures for session binding
  • Resource servers could leverage existing authorization modalities

Resource Server Pattern

  • Treat MCP servers as OAuth resource servers instead of authorization servers
  • Leverage existing identity providers/authorization servers
  • MCP server validates tokens but doesn't issue them
  • Supports token exchange flows for on-behalf-of scenarios

Status & Recommendations

Current State

Short-term Workarounds

  • Use Basic Auth mode (recommended) - works reliably with all clients
  • ⚠️ For OAuth testing: Use providers with full DCR support (Auth0, Keycloak)
  • ⚠️ Avoid enterprise providers (Azure AD, Okta) until client-side issues are resolved

Long-term

References

Blog Posts & Documentation

MCP Specification


This is a tracking issue. Updates will be added as upstream issues progress and client implementations improve.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions