Skip to main content
Glama

list-tenants

Retrieve all Azure tenants accessible through the Azure MCP Server for tenant selection and management.

Instructions

List all available Azure tenants

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handleListTenants method implements the core logic for the 'list-tenants' tool. It creates a SubscriptionClient with DefaultAzureCredential to list all accessible tenants using client.tenants.list() and subscriptions using client.subscriptions.list(), then returns a JSON object containing both lists.
    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}` ); } }
  • Registers the 'list-tenants' tool in the handleListTools response, providing name, description, and input schema (empty object, no required parameters).
    { name: "list-tenants", description: "List all available Azure tenants", inputSchema: { type: "object", properties: {}, required: [], }, },
  • In the handleCallTool switch statement, the 'list-tenants' case delegates execution to the handleListTenants handler method.
    case "list-tenants": result = await this.handleListTenants(); break;
  • Input schema for 'list-tenants' tool: an empty object with no properties or required fields.
    inputSchema: { type: "object", properties: {}, required: [], },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kalivaraprasad-gonapa/azure-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server