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, }; } } );
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