-
Notifications
You must be signed in to change notification settings - Fork 8
Description
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:
- Request required OAuth scopes
- Handle various OAuth discovery mechanisms
- Work with enterprise OAuth providers that don't support DCR
- Properly discover OAuth configuration from
WWW-Authenticateheaders
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_oidcapp)
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
scopeparameter 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_metadatafromWWW-Authenticateheader, tries wrong discovery endpoint (.well-known/oauth-authorization-serverinstead of following theresource_metadataURL) - Claude Code: "Immediately tries to connect to
/.well-known/oauth-authorization-serverand ignores theresource_metadatain thewww-authenticateheader" - 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
-
#695 - Incompatible DCR Flow When registration_endpoint Requires Credentials
- Issue: DCR incompatible with providers like Okta that require API keys for registration
- Impact: Cannot use DCR with major enterprise OAuth providers
-
#205 - Treat the MCP server as an OAuth resource server
- Issue: Current architecture requires every MCP server to be a full OAuth authorization server
- Proposal: Use resource server pattern to leverage existing identity providers
- Would enable enterprise scenarios, token exchange flows, and reduce complexity
Claude Code Repository
-
#2527 - Claude OAuth requires DCR, making Azure AD/Entra ID integration complex
- Issue: Azure AD doesn't support DCR, requires pre-registered apps with fixed redirect URIs
- Claude uses random ports requiring constant Azure AD app updates
- Missing
scopeparameter causes AADSTS70011 errors
-
#2267 - Cannot connect Remote GitHub MCP Server
- Issue: Claude Code cannot authenticate with GitHub's official MCP server
- Related to OAuth discovery and DCR issues
-
#3515 - MCP OAuth Integration Fails on Production Deployments
- Issue: OAuth flow fails immediately with
step=start_error - Affects production MCP server deployments
- Issue: OAuth flow fails immediately with
-
#1178 - Claude Code MCP Server OAuth doesn't work in SSH remote sessions
- Issue: No way to access browser remotely for OAuth flow
- Limits deployment scenarios
Google Gemini CLI Repository
-
#5011 - /mcp auth github fails to discover OAuth configuration
- Issue: Cannot extract
resource_metadatafromWWW-Authenticateheader - Tries wrong discovery endpoint instead of following RFC 9728 flow
- GitHub MCP server provides correct headers but Gemini CLI cannot parse them
- Issue: Cannot extract
-
- Related OAuth issues with GitHub MCP server
FastMCP Repository
- #972 - OAuth works with MCP Inspector but not with Claude/FastMCP Client
- Issue: OAuth works with MCP Inspector but fails with Claude Desktop and FastMCP Client
- Error:
invalid_client- "The requested OAuth 2.0 Client does not exist" - Indicates inconsistent OAuth behavior between different MCP clients
Technical Details
OAuth Discovery Mechanisms
The MCP specification supports multiple OAuth discovery mechanisms, but clients implement them inconsistently:
- RFC 9728 - OAuth 2.0 Protected Resource Metadata: Server returns
WWW-Authenticateheader withresource_metadataURL - 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
scopeparameter 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 | 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
⚠️ OAuth mode in this Nextcloud MCP server is EXPERIMENTAL- 🔴 Not recommended for production due to:
- Client compatibility issues (this issue)
- Nextcloud upstream issues (Track upstream: Bearer token authentication failing for app-specific APIs (user_oidc#1221) #209)
- Limited enterprise OAuth provider support
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
- 🕒 Monitor upstream MCP client repositories for OAuth improvements
- 🕒 Watch for SEP-991 and SEP-1299 standardization progress
- 🕒 Track Nextcloud
user_oidcBearer token support (Track upstream: Bearer token authentication failing for app-specific APIs (user_oidc#1221) #209) - 🕒 Consider implementing resource server pattern when clients support it
References
Blog Posts & Documentation
- Evolving OAuth Client Registration in MCP
- Tips to Harden OAuth Dynamic Client Registration in MCP Servers
- Diving Into the MCP Authorization Specification
- Let's fix OAuth in MCP by Aaron Parecki
- MCP and OAuth Dynamic Client Registration
- Understanding OAuth2 and implementing identity-aware MCP servers
MCP Specification
This is a tracking issue. Updates will be added as upstream issues progress and client implementations improve.