Skip to content

AzureProvider cannot authenticate with external Microsoft APIs - PowerBI#2447

Description

@rpgeddam

Description

I'm trying to create an MCP server that interacts with the PowerBI REST API using Azure AD authentication. I need the powerBI scope https://analysis.windows.net/powerbi/api/Report.Read.All

# Attempt #1
auth_provider = AzureProvider(
    client_id=os.getenv("AZURE_CLIENT_ID"),
    client_secret=os.getenv("AZURE_CLIENT_SECRET"),
    tenant_id=os.getenv("AZURE_TENANT_ID"),
    base_url="http://localhost:8000",
    required_scopes=["custom.scope"],
    additional_authorize_scopes=["openid", "offline_access", "https://analysis.windows.net/powerbi/api/Report.Read.All"],
)

# Wont work because custom.scope and powerbi scopes are on different resources
# AADSTS28000: Provided value for the input parameter scope is not valid 
# because it contains more than one resource.
# Attempt #2
auth_provider = AzureProvider(
    client_id=os.getenv("AZURE_CLIENT_ID"),
    client_secret=os.getenv("AZURE_CLIENT_SECRET"),
    tenant_id=os.getenv("AZURE_TENANT_ID"),
    base_url="http://localhost:8000",
    required_scopes=["https://analysis.windows.net/powerbi/api/Report.Read.All"],
)

# Wont work because AzureProvider replaces the prefix on the scope
# The application asked for scope 'Report.Read.All' that doesn't exist.

What I expect would work:

  auth_provider = AzureProvider(
      client_id=os.getenv("AZURE_CLIENT_ID"),
      client_secret=os.getenv("AZURE_CLIENT_SECRET"),
      tenant_id=os.getenv("AZURE_TENANT_ID"),
      base_url="http://localhost:8000",
      required_scopes=["https://analysis.windows.net/powerbi/api/Report.Read.All"],
      additional_authorize_scopes=["openid", "offline_access"],
  )
# Should accept full scope URIs and use the correct audience

I expect his affects anyone using AzureProvider with:

  • PowerBI
  • Azure Storage
  • Azure DevOps
  • Any Microsoft API that isn't Graph or a custom API

Version Information

$ fastmcp version

FastMCP version:                                                                            2.13.1
MCP version:                                                                                1.21.2
Python version:                                                                             3.13.2
Platform:                                                      macOS-15.6.1-arm64-arm-64bit-Mach-O
FastMCP root path: *

Metadata

Metadata

Assignees

No one assigned

    Labels

    authRelated to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions