Skip to main content
Glama

list-subscriptions

Retrieve accessible Azure subscriptions for a configured service principal to manage multi-tenant resource access and scoping.

Instructions

List subscriptions accessible to the configured service principal for a tenant.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tenant_nameNoOptional configured tenant name

Implementation Reference

  • Handler for 'list-subscriptions' tool: resolves credentials, enumerates subscriptions via ARM or defaults, prefers MG scope, fetches display names using ARG KQL query (list_subscriptions_kql), formats and returns list.
    if name == "list-subscriptions":
        tenant_name = arguments.get("tenant_name")
        cred, default_subs = AZURE_CONFIG.get_credentials(tenant_name)
        discovered = _enumerate_subscriptions_for_credential(cred)
        mg = AZURE_CONFIG.get_management_group_id(tenant_name)
        subs = discovered or default_subs
        if not subs and not mg:
            return [types.TextContent(type="text", text=(
                "No subscriptions found and no management_group_id configured. Configure management_group_id or ensure the SP has Reader at root."
            ))]
    
        # If we were able to enumerate, we only have IDs. For user-friendly output,
        # run a small ARG query to fetch display names.
        total_count = len(subs)
        scope_line = ""
        try:
            kql = list_subscriptions_kql()
            # If a management group is configured, prefer listing by MG to include all contained subscriptions
            if mg:
                res = execute_kql(cred, None, kql, top=1000, management_groups=[mg])
                scope_line = f"Scope: managementGroup={mg}"
            else:
                res = execute_kql(cred, subs, kql, top=1000)
                scope_line = f"Scope: subscriptions={len(subs)}"
            if res.get("status") == "success" and res.get("results"):
                rows = res["results"]
                lines = [f"- {r.get('name')} ({r.get('subscriptionId')})" for r in rows]
                total_count = len(rows)
            else:
                lines = [f"- {sid}" for sid in subs]
        except Exception:
            lines = [f"- {sid}" for sid in subs]
            scope_line = f"Scope: subscriptions={len(subs)} (fallback)"
    
        body = [
            f"Tenant: {tenant_name or AZURE_CONFIG.get_default_tenant().get('name')}",
            f"Subscriptions: {total_count}",
            scope_line,
            *lines,
        ]
        return [types.TextContent(type="text", text="\n".join(body))]
  • Tool registration including name, description, and input schema for 'list-subscriptions'.
    types.Tool(
        name="list-subscriptions",
        description="List subscriptions accessible to the configured service principal for a tenant.",
        inputSchema={
            "type": "object",
            "properties": {
                "tenant_name": {"type": "string", "description": "Optional configured tenant name"}
            },
            "required": [],
        },
    ),
  • Helper function to enumerate accessible subscription IDs using Azure SubscriptionClient.
    def _enumerate_subscriptions_for_credential(credential) -> List[str]:
        """Return list of subscription IDs accessible by the given credential.
    
        Falls back to empty list if enumeration fails or dependency is missing.
        """
        try:
            from azure.mgmt.subscription import SubscriptionClient  # type: ignore
        except Exception:
            return []
        try:
            client = SubscriptionClient(credential=credential)
            return [s.subscription_id for s in client.subscriptions.list()]
        except Exception:
            return []
  • Helper function providing the KQL query template for listing subscriptions (loaded from kql/list_subscriptions.kql or .md).
    def list_subscriptions_kql() -> str:
        return _tmpl("list_subscriptions")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'accessible to the configured service principal', hinting at authentication/access control, but does not disclose key behavioral traits like pagination, rate limits, error handling, or response format. For a read operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It is front-loaded with the core purpose and appropriately sized for a simple list tool, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool that likely returns a list of subscriptions. It lacks details on return values, error cases, or operational constraints. For a tool with minimal structured data, the description should compensate more to provide adequate context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'tenant_name' documented as optional. The description adds no additional parameter semantics beyond what the schema provides (e.g., format, examples, or implications of omitting it). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('subscriptions'), specifying that it retrieves subscriptions accessible to a service principal for a tenant. It distinguishes from siblings like 'list-tenants' by focusing on subscriptions, but does not explicitly differentiate from other potential subscription-related tools (though none are present in the sibling list).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when needing to list subscriptions for a tenant, but provides no explicit guidance on when to use this tool versus alternatives (e.g., 'list-tenants' for tenants, 'vm-count-by-tenant' for VM counts). It lacks prerequisites, exclusions, or named alternatives, offering minimal contextual direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/andrewstephenson-v1/Azure-Assistant-MCP'

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