list-tenants
Retrieve all available Azure tenants for simplified multi-tenant management, enabling efficient resource access and configuration across your Azure environment.
Instructions
List all available Azure tenants
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/AzureServer.ts:530-570 (handler)The handler function that executes the list-tenants tool, fetching tenants and subscriptions using Azure SubscriptionClient with retry logic, caching not used here, and proper error handling.private async handleListTenants() { try { const creds = new DefaultAzureCredential(); const client = new SubscriptionClient(creds); const [tenants, subscriptions] = await Promise.all([ this.executeWithRetry(async () => { const items = []; for await (const tenant of client.tenants.list()) { items.push({ id: tenant.tenantId, name: tenant.displayName, }); } return items; }), this.executeWithRetry(async () => { const items = []; for await (const sub of client.subscriptions.list()) { items.push({ id: sub.subscriptionId, name: sub.displayName, state: sub.state, }); } return items; }), ]); return this.createTextResponse( JSON.stringify({ tenants, subscriptions }) ); } catch (error) { this.logWithContext("error", `Error listing tenants: ${error}`, { error, }); throw new AzureAuthenticationError( `Failed to list tenants and subscriptions: ${error}` ); } }
- src/AzureServer.ts:325-333 (registration)Registration of the list-tenants tool in the handleListTools method, including name, description, and input schema (empty object).{ name: "list-tenants", description: "List all available Azure tenants", inputSchema: { type: "object", properties: {}, required: [], }, },
- src/AzureServer.ts:438-440 (handler)Switch case in handleCallTool that dispatches to the list-tenants handler.case "list-tenants": result = await this.handleListTenants(); break;