A Model Context Protocol server for querying and analyzing Azure resources at scale using Azure Resource Graph, enabling AI assistants to explore and monitor Azure infrastructure.
This document details the implementation and usage of an Azure Resource Graph Model Context Protocol (MCP) server. This server acts as a bridge, enabling Large Language Model (LLM) applications to seamlessly access and leverage the wealth of information contained within Azure Resource Graph. By providing a standardized interface, this server empowers developers to build intelligent, context-aware applications that can understand and interact with their Azure infrastructure.
This server is designed to be easily integrated into various development environments, including Cursor IDE and Visual Studio Code, allowing developers to quickly prototype and deploy LLM-powered solutions.
DefaultAzureCredential
for streamlined authentication, supporting various methods including Azure CLI, Managed Identity, and environment variables. This ensures secure and efficient access to your Azure resources.Before diving into the implementation, ensure you have the following prerequisites in place:
This MCP server can be seamlessly integrated into your preferred development environment. Below are detailed instructions for both Cursor IDE and Visual Studio Code.
Clone the Repository: Begin by cloning the repository to your local machine. For example: C:\YOUR_WORKSPACE\azure-resource-graph-mcp-server
.
Build the Project: Navigate to the cloned directory in your terminal and execute the following commands:
npm install npm run build
These commands will install the necessary dependencies and build the project.
Configure Cursor Settings: Open Cursor's settings (JSON) file and add the following configuration block:
{ "mcpServers": { "azure-resource-graph-mcp-server": { "command": "node", "args": [ "C:\\YOUR_WORKSPACE\\azure-resource-graph-mcp-server\\build\\index.js" ], "env": { "SUBSCRIPTION_ID": "xxxxxx-xx-xx-xx-xxxxxx" }, } } }
Important: Replace "C:\\YOUR_WORKSPACE\\azure-resource-graph-mcp-server"
with the actual path to your local repository. Also, replace "xxxxxx-xx-xx-xx-xxxxxx"
with your Azure Subscription ID.
Restart Cursor: Restart Cursor IDE to apply the changes and activate the MCP server integration.
Clone the Repository: Clone the repository to your local machine.
Build the Project: Navigate to the cloned directory in your terminal and execute the following commands:
npm install npm run build
These commands will install the necessary dependencies and build the project.
Open VS Code Settings (JSON): Press Ctrl+Shift+P
to open the command palette, type "Settings (JSON)", and select "Preferences: Open User Settings (JSON)".
Add Configuration: Add the following configuration block to your settings.json
file:
{ "mcp": { "servers": { "azure-resource-graph": { "type": "stdio", "command": "node", "args": [ "C:\\YOUR_WORKSPACE\\azure-resource-graph-mcp-server\\build\\index.js" ], "env": { "SUBSCRIPTION_ID": "xxxxxx-xx-xx-xx-xxxxxx" }, } } } }
Important: Replace "C:\\YOUR_WORKSPACE\\azure-resource-graph-mcp-server"
with the actual path to your local repository. Also, replace "xxxxxx-xx-xx-xx-xxxxxx"
with your Azure Subscription ID.
Save and Restart: Save the settings.json
file and restart VS Code to apply the changes.
With these steps completed, the MCP server will be readily available for use within VS Code, enhancing your development workflow with powerful LLM integration.
query-resources
The server exposes a single, powerful tool: query-resources
. This tool allows you to retrieve detailed information about your Azure resources from Azure Resource Graph.
Parameters:
subscriptionId
(optional): Specifies the Azure subscription ID to query. If not provided, the server will use the configured SUBSCRIPTION_ID
environment variable.query
(optional): Allows you to define a custom Resource Graph query. If not provided, the server will use the default query: "Resources | project id, name, type, location"
.Proper environment configuration is crucial for seamless authentication and access to your Azure resources. Follow these steps to ensure your environment is correctly set up:
Azure CLI Login: Ensure you are logged in to the Azure CLI by running the following command:
az login
This step is essential for local development, as DefaultAzureCredential
will automatically leverage your Azure CLI credentials.
Environment Variables:
.env.example
file and rename it to .env
.AZURE_SUBSCRIPTION_ID
variable in the .env
file with your actual Azure subscription ID.AZURE_TENANT_ID
, AZURE_CLIENT_ID
, and AZURE_CLIENT_SECRET
variables are optional when using Azure CLI authentication.Azure Credentials: The server utilizes DefaultAzureCredential
, which supports various authentication methods:
Environment Variable Setup (if applicable): If you choose to use environment variables for authentication, ensure the following variables are properly configured:
AZURE_SUBSCRIPTION_ID
AZURE_TENANT_ID
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
The server incorporates comprehensive error handling mechanisms to ensure stability and reliability. These mechanisms cover:
If you wish to contribute to the project, follow these steps:
src
directory.npm run build
command to build the project.By following these guidelines, you can effectively contribute to the ongoing development and improvement of this valuable tool.
๐ A gateway demo for MCP SSE Server.
๐ โ๏ธ A lightweight mcp server that tells you exactly what time is it.
#๏ธโฃ ๐ A C# SDK for building MCP servers on .NET 9 with NativeAOT compatibility โก ๐
โ Java SDK for building MCP servers using Quarkus.