Description
When using forge mcp login <server> with an MCP server that uses OAuth, the authorization request always uses a hardcoded scope set (profile email), ignoring the scopes_supported advertised by the server.
Expected Behavior
Per the MCP Authorization spec:
If scope is not available from the WWW-Authenticate header, clients SHOULD use all scopes defined in scopes_supported from the Protected Resource Metadata document.
Forge should discover the /.well-known/oauth-protected-resource/<endpoint> metadata and request all advertised scopes during the OAuth authorization flow.
Actual Behavior
Forge always requests scope=profile email in the OAuth authorization request, regardless of what scopes the MCP server advertises via its protected resource metadata.
This means servers that require scopes like:
mcp:tools
mcp:prompts
mcp:resources
offline_access
...receive tokens with insufficient scope, causing authorization failures downstream.
Steps to Reproduce
- Set up an MCP server with OAuth that advertises
scopes_supported beyond profile email in its /.well-known/oauth-protected-resource/<endpoint> metadata
- Run
forge mcp import --scope user with this server
- Run
forge mcp login <server-name>
- Observe that the authorization request only includes
profile email in the scope parameter
Environment
- Forge version: 2.12.14
- The server adheres to the MCP OAuth protected resource metadata spec
Suggested Fix
During the OAuth authorization flow, Forge should:
- Fetch
/.well-known/oauth-protected-resource/<endpoint> from the MCP server
- Parse
scopes_supported from the response
- Request all supported scopes in the authorization request (falling back to
openid profile email only if the endpoint is not reachable or has no scopes_supported)
Description
When using
forge mcp login <server>with an MCP server that uses OAuth, the authorization request always uses a hardcoded scope set (profile email), ignoring thescopes_supportedadvertised by the server.Expected Behavior
Per the MCP Authorization spec:
Forge should discover the
/.well-known/oauth-protected-resource/<endpoint>metadata and request all advertised scopes during the OAuth authorization flow.Actual Behavior
Forge always requests
scope=profile emailin the OAuth authorization request, regardless of what scopes the MCP server advertises via its protected resource metadata.This means servers that require scopes like:
mcp:toolsmcp:promptsmcp:resourcesoffline_access...receive tokens with insufficient scope, causing authorization failures downstream.
Steps to Reproduce
scopes_supportedbeyondprofile emailin its/.well-known/oauth-protected-resource/<endpoint>metadataforge mcp import --scope userwith this serverforge mcp login <server-name>profile emailin the scope parameterEnvironment
Suggested Fix
During the OAuth authorization flow, Forge should:
/.well-known/oauth-protected-resource/<endpoint>from the MCP serverscopes_supportedfrom the responseopenid profile emailonly if the endpoint is not reachable or has noscopes_supported)