Skip to content

forge mcp login OAuth flow requests hardcoded scopes instead of discovering scopes_supported #3339

@nlenepveu

Description

@nlenepveu

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

  1. Set up an MCP server with OAuth that advertises scopes_supported beyond profile email in its /.well-known/oauth-protected-resource/<endpoint> metadata
  2. Run forge mcp import --scope user with this server
  3. Run forge mcp login <server-name>
  4. 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:

  1. Fetch /.well-known/oauth-protected-resource/<endpoint> from the MCP server
  2. Parse scopes_supported from the response
  3. 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)

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