-
Notifications
You must be signed in to change notification settings - Fork 433
Description
Describe the bug
The role tool (e.g. role_assignment_list) returns InvalidOperationException: No accessible tenant found for tenant ID '<id>' even when:
az loginis authenticated to the correct tenant- Other MCP tools (e.g.
appservice) work against the same subscription/tenant - The
tenantparameter is passed explicitly to the tool - The equivalent CLI command
az role assignment list --scope <resource-id>works correctly
Expected behavior
The role_assignment_list tool should return role assignments for the specified scope, the same way az role assignment list --scope <resource-id> does via the CLI.
Actual behavior
The tool returns HTTP 500 with:
InvalidOperationException: No accessible tenant found for tenant ID <GUID>
Root cause in code:
In BaseAzureResourceService.cs, the GetTenantResourceAsync method calls TenantService.GetTenants() without passing the tenant parameter:
var allTenants = await TenantService.GetTenants(cancellationToken);
var tenantResource = allTenants.FirstOrDefault(t => t.Data.TenantId == tenantId.Value);And in ExecuteResourceQueryAsync, the explicitly passed tenant parameter is not forwarded:
var subscriptionResource = await _subscriptionService.GetSubscription(subscription, tenant, retryPolicy, cancellationToken);
var tenantResource = await GetTenantResourceAsync(subscriptionResource!.Data.TenantId, cancellationToken);
// ^ 'tenant' parameter from caller is not used to scope the credentialThe TenantService.GetTenants() method enumerates all tenants via ArmClient.GetTenants() without using a credential scoped to the requested tenant. If the default credential cannot enumerate the target tenant, it fails.
Reproduction Steps
- Run
az login --tenant <tenant-id> - Confirm login:
az account showreturns the correct tenant - Use the
role_assignment_listtool with a valid scope, passingtenantandsubscriptionexplicitly - Observe:
InvalidOperationException: No accessible tenant found for tenant ID '<id>' - Run
az role assignment list --scope <same-scope> --include-inherited— works correctly
Environment
- OS: Windows 11
- IDE: VS Code (latest)
- Azure MCP Server: latest
- Shell: Git Bash
Metadata
Metadata
Assignees
Labels
Type
Projects
Status