Azure Cost Management MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Azure Cost Management MCP what was my total cost last month?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Azure Cost Management MCP Server
MCP (Model Context Protocol) server per l'integrazione con le API di Azure Cost Management, allineato alle linee guida WAF Cost Optimization e CAF (Cloud Adoption Framework) di Microsoft.
Compatibile con GitHub Copilot Chat, Claude Desktop, e qualsiasi client MCP.
Indice
Related MCP server: Azure FinOps MCP Server
Prerequisiti
Requisito | Versione minima |
Node.js | 18.0.0 |
npm | 9.x |
Azure CLI ( | qualsiasi — solo per autenticazione locale |
Installazione
cd azure-cost-management-mcp
npm install
npm run buildIl server compilato sarà disponibile in dist/index.js.
Autenticazione Azure
Il server usa DefaultAzureCredential dall'SDK @azure/identity, che tenta automaticamente le seguenti modalità in ordine:
Opzione A — Azure CLI (sviluppo locale, consigliata)
az login
# oppure, per un tenant specifico:
az login --tenant <TENANT_ID>Nessuna variabile d'ambiente necessaria. Il server rileva il token CLI in modo automatico.
Opzione B — Service Principal (CI/CD, automazione)
Imposta le seguenti variabili d'ambiente (vedi .env.example):
AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AZURE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
AZURE_CLIENT_SECRET=your-client-secret
AZURE_SUBSCRIPTION_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # default subscriptionOpzione C — Managed Identity (workload ospitati su Azure)
Nessuna configurazione. DefaultAzureCredential rileva l'identità gestita tramite IMDS in modo automatico.
Configurazione IDE
VS Code + GitHub Copilot Chat
Metodo 1 — File .vscode/mcp.json nel workspace (consigliato)
Crea o modifica il file <cartella-workspace>/.vscode/mcp.json:
{
"servers": {
"azure-cost-management": {
"type": "stdio",
"command": "node",
"args": ["${userHome}/azure-cost-management-mcp/dist/index.js"],
"env": {
"AZURE_SUBSCRIPTION_ID": "${env:AZURE_SUBSCRIPTION_ID}"
}
}
}
}Se usi
az login, la sezioneenvpuò rimanere vuota —DefaultAzureCredentialusa il token CLI. Per Service Principal aggiungiAZURE_TENANT_ID,AZURE_CLIENT_ID,AZURE_CLIENT_SECRET.
Metodo 2 — Settings utente VS Code (globale)
Apri Ctrl+Shift+P → Preferences: Open User Settings (JSON) e aggiungi:
{
"mcp.servers": {
"azure-cost-management": {
"type": "stdio",
"command": "node",
"args": ["C:/Users/<TUO_UTENTE>/azure-cost-management-mcp/dist/index.js"]
}
}
}Verifica connessione in VS Code:
Apri il pannello GitHub Copilot Chat (
Ctrl+Alt+I)Seleziona modalità Agent (
@)Scrivi:
@azure-cost-management qual è la spesa del mese corrente per la subscription xxx?
Claude Desktop
Modifica il file di configurazione di Claude Desktop:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"azure-cost-management": {
"command": "node",
"args": ["C:/Users/<TUO_UTENTE>/azure-cost-management-mcp/dist/index.js"],
"env": {
"AZURE_SUBSCRIPTION_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
}
}Riavvia Claude Desktop dopo la modifica.
Cursor
Crea o modifica .cursor/mcp.json nella home utente oppure nella cartella del progetto:
{
"mcpServers": {
"azure-cost-management": {
"command": "node",
"args": ["C:/Users/<TUO_UTENTE>/azure-cost-management-mcp/dist/index.js"],
"env": {
"AZURE_SUBSCRIPTION_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
}
}Windsurf
Modifica ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"azure-cost-management": {
"command": "node",
"args": ["C:/Users/<TUO_UTENTE>/azure-cost-management-mcp/dist/index.js"],
"env": {
"AZURE_SUBSCRIPTION_ID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
}
}Riferimento Scope
Tutti i tool accettano un parametro scope che identifica il livello Azure su cui operare.
Formato | Esempio | Scope risultante |
Path completo |
| Subscription |
Path completo |
| Resource Group |
UUID nudo |
| Subscription |
|
| Subscription |
|
| Resource Group |
|
| RG nella subscription default ( |
|
| Management Group (CAF enterprise) |
|
| Billing Account (EA/MCA) |
|
| Billing Profile (MCA) |
CAF tip: usa
mg:per analisi cross-subscription su tutti i landing zone senza dover iterare su ogni subscription singolarmente.
Tool disponibili
azure_cost_query
Interroga i costi effettivi o ammortizzati per uno scope Azure con raggruppamento e filtri temporali.
Parametri:
Parametro | Tipo | Default | Descrizione |
| string | — | Scope Azure (vedi Riferimento Scope) |
|
|
|
|
| enum |
| Finestra temporale: |
| string (ISO 8601) | — | Data inizio (solo con |
| string (ISO 8601) | — | Data fine (solo con |
|
|
|
|
| string[] |
| Dimensioni per il raggruppamento (vedi esempi sotto) |
| integer (1-1000) |
| Numero massimo di righe restituite |
Valori comuni per groupBy:
ResourceGroup ServiceName ResourceType
Location SubscriptionName MeterCategory
MeterSubCategory ChargeType
tag:CostCenter tag:Environment tag:Applicationazure_cost_forecast
Restituisce le previsioni di spesa basate sui trend di utilizzo correnti.
Parametri:
Parametro | Tipo | Default | Descrizione |
| string | — | Scope Azure |
| string (ISO 8601) | — | Data inizio previsione |
| string (ISO 8601) | — | Data fine previsione |
|
|
| Granularità della previsione |
| boolean |
| Includi i costi reali per confronto con la previsione |
azure_cost_dimensions
Elenca le dimensioni disponibili per raggruppamento e filtro allo scope indicato. Da usare prima di azure_cost_query per scoprire i valori validi di groupBy.
Parametri:
Parametro | Tipo | Descrizione |
| string | Scope Azure |
azure_cost_alerts
Elenca gli alert di costo attivi per uno scope: sforamenti budget, avvisi credito, violazioni quota, anomalie.
Parametri:
Parametro | Tipo | Descrizione |
| string | Scope Azure |
Risposta — campi principali:
{
"total": 2,
"active": 1,
"alerts": [
{
"name": "alert-xxx",
"definitionType": "Budget",
"definitionCategory": "Cost",
"status": "Active",
"creationTime": "2024-01-15T10:30:00Z"
}
]
}azure_budget_list
Elenca tutti i budget di costo allo scope con la spesa corrente, le soglie e lo stato.
Parametri:
Parametro | Tipo | Descrizione |
| string | Scope Azure (richiede subscription) |
Stati possibili nel campo status:
Status | Significato |
| Spesa < 80% del budget |
| Spesa tra 80% e 90% |
| Spesa tra 90% e 100% |
| Spesa > 100% del budget |
azure_budget_get
Recupera i dettagli completi di un budget specifico: spesa corrente, spesa prevista, soglie di notifica e filtri.
Parametri:
Parametro | Tipo | Descrizione |
| string | Scope Azure |
| string | Nome del budget |
azure_budget_create
Crea o aggiorna un budget di costo con le soglie di alert raccomandate da WAF. Se esiste già un budget con lo stesso nome nello stesso scope, verrà aggiornato.
Parametri:
Parametro | Tipo | Default | Descrizione |
| string | — | Scope Azure (richiede subscription) |
| string | — | Nome univoco del budget nello scope |
| number | — | Importo del budget nella valuta della subscription |
| enum |
| Periodo di reset: |
| string (YYYY-MM-DD) | — | Data inizio. Per grain |
| string (YYYY-MM-DD) | +10 anni | Data fine (opzionale) |
| string[] |
| Email da notificare al raggiungimento delle soglie |
| string[] |
| Ruoli RBAC da notificare |
| boolean |
| Alert WAF: avviso anticipato all'80% della spesa effettiva |
| boolean |
| Alert WAF: budget raggiunto al 100% della spesa effettiva |
| boolean |
| Alert WAF: previsione che raggiungerà il 100% prima della fine del periodo |
azure_budget_delete
Elimina permanentemente un budget. L'operazione non è reversibile.
Parametri:
Parametro | Tipo | Descrizione |
| string | Scope Azure |
| string | Nome del budget da eliminare |
azure_advisor_recommendations
Recupera le raccomandazioni di Azure Advisor per la categoria Cost Optimization.
Copre: ridimensionamento VM sottoutilizzate, eliminazione risorse idle (dischi non collegati, IP pubblici inutilizzati), acquisto Reserved Instances o Savings Plans per workload prevedibili.
Parametri:
Parametro | Tipo | Default | Descrizione |
| string | — | Scope a livello subscription (UUID, |
|
|
| Filtra per impatto. |
| integer (1-500) |
| Numero massimo di raccomandazioni |
Nota: Azure Advisor opera solo a livello di subscription. Lo scope
mg:non è supportato per questo tool.
Esempi d'uso in chat
Questi esempi funzionano sia con GitHub Copilot Chat che con Claude Desktop, Cursor, e Windsurf.
Analisi spesa corrente
Mostrami la spesa del mese corrente per la subscription aaaa-bbbb-cccc,
raggruppata per ServiceName e ordinata per costo decrescente.Qual è la spesa degli ultimi 3 mesi raggruppata per ResourceGroup?
Usa il periodo Custom da 2024-01-01 a 2024-03-31 con granularità Monthly.Mostrami la ripartizione dei costi per tag:CostCenter e tag:Environment
nella subscription aaaa — voglio fare il chargeback ai team.Previsioni e anomalie
Prevedi la spesa di marzo per la subscription aaaa.
Poi confronta con il budget esistente per capire se siamo a rischio sforamento.Ci sono alert di costo attivi nella subscription aaaa?Gestione budget
Elenca tutti i budget nella subscription aaaa con il loro stato attuale.Crea un budget mensile da 5000 EUR per il resource group "prod-rg"
nella subscription aaaa, con notifiche a mario@example.com.Il budget "monthly-prod" nella subscription aaaa è stato superato?
Mostrami i dettagli e la spesa prevista per fine mese.Ottimizzazione costi (WAF/CAF)
Quali sono le raccomandazioni di Azure Advisor ad alto impatto
per la subscription aaaa? Voglio massimizzare i risparmi.Fai un'analisi completa dei costi per il management group "my-mg":
spesa corrente per subscription, alert attivi, e raccomandazioni Advisor.Quali dimensioni sono disponibili per il raggruppamento dei costi
nella subscription aaaa? Voglio capire su quali tag posso fare showback.RBAC — Ruoli richiesti
Assegna i ruoli allo scope appropriato (subscription, resource group o management group):
Operazione | Ruolo minimo richiesto |
Leggere costi, forecast, dimensioni, alert | Cost Management Reader |
Leggere budget | Cost Management Reader |
Creare/aggiornare/eliminare budget | Cost Management Contributor |
Raccomandazioni Advisor | Reader (a livello subscription) |
CAF enterprise: assegna i ruoli a livello di Management Group per coprire tutte le subscription dei landing zone con un'unica assegnazione.
# Esempio: assegnare Cost Management Reader al management group
az role assignment create \
--role "Cost Management Reader" \
--assignee <CLIENT_ID_O_UPN> \
--scope /providers/Microsoft.Management/managementGroups/<MG_ID>Architettura del codice
azure-cost-management-mcp/
├── src/
│ ├── index.ts # Entry point MCP server, registrazione tool
│ ├── client.ts # Client Azure singleton + helper scope/risposta
│ ├── tools/
│ │ ├── cost.ts # azure_cost_query, forecast, dimensions, alerts
│ │ ├── budgets.ts # azure_budget_list/get/create/delete
│ │ └── advisor.ts # azure_advisor_recommendations
│ └── __tests__/
│ ├── client.test.ts # Unit test: normalizeScope, transformRows, ecc.
│ └── server.integration.test.ts # Integration test: protocollo MCP
├── dist/ # Output compilato TypeScript (generato da npm run build)
├── package.json
├── tsconfig.json
└── .env.exampleDipendenze principali:
Pacchetto | Versione | Uso |
| ^1.27.1 | Protocollo MCP, transport stdio |
| 1.0.0-beta.1 | Query costi, forecast, dimensioni, alert |
| ^9.2.0 | Gestione budget |
| ^3.2.0 | Raccomandazioni Cost Optimization |
| ^4.13.1 | DefaultAzureCredential (auth unificata) |
| ^3.23.0 | Validazione input schema tool |
Flusso architetturale:
GitHub Copilot / Claude / Cursor
│ MCP (stdio)
▼
src/index.ts (McpServer + StdioServerTransport)
│
src/client.ts (DefaultAzureCredential, singleton client, normalizeScope)
│
┌────┼────────────────────┐
▼ ▼ ▼
Azure Cost Azure Azure
Management Consumption Advisor
API API (Budgets) APISviluppo
# Avvia in watch mode (rebuild automatico al salvataggio)
npm run dev
# Verifica tipi senza compilare
npm run typecheck
# Build di produzione
npm run build
# Avvia il server compilato
npm start
# Esegui tutti i test (unit + integration)
npm test
# Solo unit test (client utilities)
npm run test:unit
# Solo integration test (protocollo MCP)
npm run test:integrationTest rapido del server:
# Verifica che il server si avvii e risponda al protocollo MCP
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \
| node dist/index.jsLista tool registrati:
(
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
) | node dist/index.jsAvailable Tools
9 toolsazure_advisor_recommendationsAzure Advisor Cost RecommendationsA
Retrieves Azure Advisor cost optimization recommendations for a subscription. Covers: right-sizing underutilized VMs, deleting idle resources (unattached disks, unused IPs), purchasing reservations or savings plans for predictable workloads, and removing empty resource groups. WAF Cost Optimization: address High impact recommendations first for maximum savings. CAF FinOps: run across all landing zone subscriptions to enforce cost governance. Note: Advisor operates at subscription scope; management group scope is not supported.
Inputs: scope (required), top, impact.
azure_budget_createAzure Budget Create or UpdateA
Creates or updates a cost budget with WAF-recommended alert thresholds. Default notifications: 80% actual, 100% actual, 100% forecasted — first line of defense against overruns. WAF Cost Optimization: always set both actual and forecasted alerts on every workload budget. CAF: align timeGrain with billing cycles; include Owner/Contributor in contactRoles for governance. If a budget with the same name already exists at the scope it will be updated in-place.
Inputs: name (required), scope (required), amount (required), startDate (required), +7 more.
azure_budget_deleteAzure Budget DeleteA
Permanently deletes a cost budget. This action cannot be undone.
Inputs: scope (required), budgetName (required).
azure_budget_getAzure Budget GetA
Retrieves full details of a specific budget including current and forecasted spend, all alert notification thresholds, and filter configuration.
Inputs: scope (required), budgetName (required).
azure_budget_listAzure Budget ListA
Lists all cost budgets at a given scope with current spend, thresholds, and alert status. WAF Cost Optimization: verify every workload has budget coverage with 80% and 100% alert thresholds. CAF: every landing zone subscription should have at least one monthly budget.
Inputs: scope (required).
azure_cost_alertsAzure Cost AlertsA
Lists active cost alerts for a scope (budget breaches, credit warnings, quota violations, anomalies). WAF Cost Optimization: monitor alerts to detect unexpected cost spikes before they escalate. Complement with azure_budget_list to correlate alerts with budget thresholds.
Inputs: scope (required).
azure_cost_dimensionsAzure Cost DimensionsA
Lists available dimensions for cost grouping and filtering at a given scope. Use this to discover valid values for the groupBy parameter in azure_cost_query. WAF: discover available tag keys for chargeback/showback analysis before querying.
Inputs: scope (required).
azure_cost_forecastAzure Cost ForecastA
Retrieves cost forecasts based on current usage trends. WAF Cost Optimization: compare forecast vs budget to detect overspend risk proactively. Set budgets with 100% forecasted threshold to receive early warning alerts (see azure_budget_create).
Inputs: to (required), from (required), scope (required), granularity, +1 more.
azure_cost_queryAzure Cost QueryA
Queries actual or amortized costs for an Azure scope with grouping and time filtering. WAF Cost Optimization: identify top-spending services and resource groups, track daily trends, and perform chargeback/showback using tag-based grouping. CAF: use management group scope for cross-subscription cost reports aligned to landing zones.
Inputs: scope (required), to, top, from, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct aspect of cost management: querying, forecasting, dimensions, alerts, budget CRUD, and Advisor recommendations. The descriptions clarify boundaries between similar tools like alerts vs. budget list, preventing confusion.
Names follow a consistent prefix pattern (azure_cost_, azure_budget_, azure_advisor_) with mostly verb-based actions (query, forecast, list, get, create, delete). However, 'azure_cost_dimensions' and 'azure_cost_alerts' use noun forms, which is a minor deviation from the verb_noun convention.
Nine tools is well-scoped for an Azure cost management server. Each tool serves a clear purpose without redundancy, covering the essential operations for cost analysis and budget management.
The tool surface covers the core cost management lifecycle: querying, forecasting, alerts, budget CRUD, and recommendations. Minor gaps exist, such as lacking cost export functionality or direct alert configuration, but these are not critical for most workflows.
Maintenance
Related MCP Connectors
Official Microsoft MCP Server to query Microsoft Entra data using natural language
FinOps assistant: query AWS, GCP and Azure cost, commitments, budgets and reports.
Log, query, and edit expenses, budgets, and accounts in Manilo from any MCP-compatible AI assistant.
Veqen brings together work and coding agent costs per person and team, product inference costs per customer, agent spending, protection incidents, invoice checks, chargeback and the month-end close. Ask your assistant to investigate recorded spending, compare model prices, review provider keys and incidents, record bills and credits, or manage budgets, alerts, teams and spending policies. Your account role and plan govern access. Provider-key shut-off and agent-card controls require the appropriate role and provider permissions. Destructive actions require confirmation, and organizations can require a second person to approve a shut-off. SDK budget blocking is not a guaranteed spending cap. Work and coding agents are free for up to 3 people; product inference is free up to $1,000 in monthly AI spend. Connect your Veqen account for private organization data. The separate public model-price server needs no account. Estimates remain separate from provider invoices. Setup and permissions: https://veqen-app.com/docs/mcp
Related MCP Servers
- AlicenseAqualityCmaintenanceCloud cost management MCP server for Azure. Ask your AI about your cloud bill.15149 npm1MIT
- AlicenseNot gradedqualityDmaintenanceAnalyzes Azure cloud costs, audits for waste, and provides budget insights via natural language through a secure local MCP server.35 PyPI2MIT
- AlicenseAqualityDmaintenanceEnables natural-language queries about Azure resource compliance, including VM compliance, patch status, orphaned RBAC, and infrastructure health, through read-only MCP tools.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables LLM clients to interact with Azure cost analysis, budget tracking, forecasting, and resource optimization across multiple subscriptions.MIT