Skip to main content
Glama
hardik-id

Azure Resource Graph MCP Server

query-resources

Search, filter, and analyze Azure resources across subscriptions using Kusto Query Language (KQL) for infrastructure auditing, inventory management, and compliance checking.

Instructions

Retrieves resources and their details from Azure Resource Graph. Use this tool to search, filter, and analyze Azure resources across subscriptions. It supports Kusto Query Language (KQL) for complex queries to find resources by type, location, tags, or properties. Useful for infrastructure auditing, resource inventory, compliance checking, and understanding your Azure environment's current state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subscriptionIdNoAzure subscription ID
queryNoResource Graph query, defaults to listing all resources

Implementation Reference

  • The asynchronous handler function that implements the core logic of the 'query-resources' tool. It executes a Kusto query on Azure Resource Graph using the provided subscription ID and query string (defaulting to a basic resource list), handles the response or errors, and formats the output as MCP content.
    async ({ subscriptionId, query }) => {
      try {
        const defaultQuery = "Resources | project id, name, type, location";
        const queryToUse = query || defaultQuery;
    
        const resources = await rgClient.resources({
          subscriptions: [subscriptionId],
          query: queryToUse,
        });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(resources, null, 2),
            },
          ],
        };
      } catch (err) {
        return {
          content: [
            {
              type: "text",
              text: `Error querying resources: ${
                err instanceof Error ? err.message : String(err)
              }`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the 'query-resources' tool: subscriptionId (string, default from env) and optional query (string). Used for validation in the tool registration.
    {
      subscriptionId: z
        .string()
        .describe("Azure subscription ID")
        .default(process.env.SUBSCRIPTION_ID || ""),
      query: z
        .string()
        .optional()
        .describe("Resource Graph query, defaults to listing all resources"),
    },
  • src/index.ts:37-82 (registration)
    The server.tool() call that registers the 'query-resources' tool with MCP server, including name, description, input schema, and handler function.
    server.tool(
      "query-resources",
      "Retrieves resources and their details from Azure Resource Graph. Use this tool to search, filter, and analyze Azure resources across subscriptions. It supports Kusto Query Language (KQL) for complex queries to find resources by type, location, tags, or properties. Useful for infrastructure auditing, resource inventory, compliance checking, and understanding your Azure environment's current state.",
      {
        subscriptionId: z
          .string()
          .describe("Azure subscription ID")
          .default(process.env.SUBSCRIPTION_ID || ""),
        query: z
          .string()
          .optional()
          .describe("Resource Graph query, defaults to listing all resources"),
      },
      async ({ subscriptionId, query }) => {
        try {
          const defaultQuery = "Resources | project id, name, type, location";
          const queryToUse = query || defaultQuery;
    
          const resources = await rgClient.resources({
            subscriptions: [subscriptionId],
            query: queryToUse,
          });
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(resources, null, 2),
              },
            ],
          };
        } catch (err) {
          return {
            content: [
              {
                type: "text",
                text: `Error querying resources: ${
                  err instanceof Error ? err.message : String(err)
                }`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool retrieves details and supports KQL for queries, but it does not disclose critical behavioral traits such as whether it's read-only or destructive, authentication requirements, rate limits, or pagination behavior. This leaves significant gaps for an agent to understand how to invoke it safely and effectively.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose and usage. Each sentence adds value, such as explaining KQL support and use cases, with no redundant information. However, it could be slightly more concise by integrating the use cases more tightly with the main description.

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

Completeness3/5

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

Given the complexity of querying Azure resources with KQL and no annotations or output schema, the description is moderately complete. It covers the purpose, usage context, and parameter hints, but it lacks details on behavioral aspects like safety, response format, and error handling, which are important for an agent to use the tool effectively in this 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?

The schema description coverage is 100%, so the schema already documents both parameters (subscriptionId and query) adequately. The description adds some context by mentioning KQL for complex queries and default behavior, but it does not provide additional semantic details beyond what the schema offers, such as query format examples or subscription ID usage nuances.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('retrieves', 'search, filter, and analyze') and resources ('Azure resources'), and it distinguishes its scope by mentioning Azure Resource Graph and KQL. It provides concrete use cases like infrastructure auditing and compliance checking, making the purpose highly specific and actionable.

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

Usage Guidelines3/5

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

The description implies usage through phrases like 'Use this tool to search, filter, and analyze' and lists scenarios such as auditing and inventory, but it does not explicitly state when to use this tool versus alternatives or provide exclusions. With no sibling tools, the lack of comparative guidance is less critical, but it still lacks explicit when/when-not instructions.

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/hardik-id/azure-resource-graph-mcp-server'

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