azure-billing-mcp-server
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-billing-mcp-servershow my costs by service for 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 Billing MCP Server
MCP server for Azure spend, cost analysis, and billing via the Azure Cost Management and Billing APIs. Deployed to Google Cloud Run and connected to Gemini Enterprise.
Architecture
User in Gemini Enterprise
│
▼
Gemini Enterprise ──► Entra ID OAuth (login.microsoftonline.com)
│ receives access token (scope: api://<client-id>/mcp.access)
▼
MCP Server on Cloud Run (access gated by Cloud Run IAM)
BearerTokenMiddleware captures the token for audit logging only —
it is NOT forwarded to Azure (wrong audience for management.azure.com)
│
▼
Server's own service principal ──► Azure Cost Management + Billing APIs
│
▼
Response back to Gemini Enterprise ──► UserThe Entra ID app used for GE login and the service principal used for billing are two separate identities. The incoming token is logged for visibility but never used to call Azure.
Related MCP server: Azure FinOps Elite
Files
server.py # FastMCP app, Azure client, all 11 tools, entrypoint
requirements.txt
Dockerfile
deploy_cloudrun.sh # build image, deploy to Cloud Run, grant IAM
.env.example # for local development
SETUP.md # complete step-by-step setup guide for clientsTools (11 total)
Cost Management
Tool | Description |
| List all accessible Azure subscriptions |
| General-purpose cost query (timeframe, granularity, grouping) |
| Cost breakdown by Azure service |
| Cost breakdown by resource group |
| Day-by-day cost time series |
| Top N most expensive resources |
Billing API
Tool | Description |
| List billing accounts |
| List billing periods history |
| List invoices for a billing account |
| Detailed usage records by date range |
| Budget limits and current spend vs limit |
All tools are read-only (readOnlyHint=True).
Two Separate Credentials
Credential | Purpose | Used by |
Azure service principal ( | Queries Azure billing APIs | The MCP server itself |
Entra ID app registration ( | OAuth login screen for GE | Gemini Enterprise |
Do NOT mix these up — they serve different roles.
Gemini Enterprise Setup
MCP Server URL
https://<your-cloud-run-url>/mcpPrinted by deploy_cloudrun.sh after deploy.
Authentication Settings (fill in GE form)
Field | Value |
MCP Server URL |
|
Authorization URL |
|
Token URL |
|
Client ID | Application (client) ID of |
Client Secret | Secret from |
Scopes |
|
Enable PKCE | Leave unchecked |
MCP Agent Instructions (paste into GE)
You have access to Azure Cost Management and Billing tools for querying actual
Azure spend, invoices, budgets, and usage. All tools are read-only.
If the user doesn't specify a subscription, call list_subscriptions first.
For invoice queries, call get_billing_accounts first.
Default timeframe is "MonthToDate" unless the user asks for a different period.Required Redirect URIs (add in Entra ID App Registration → Authentication)
https://vertexaisearch.cloud.google.com/console/oauth/default_oauth.html
https://vertexaisearch.cloud.google.com/oauth-redirectLocal Development
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # fill in AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
python server.py # runs at http://0.0.0.0:8080/mcpDeploy to Cloud Run
# 1. Fill in deploy_cloudrun.sh variables:
# GCP_PROJECT, COST_MGMT_TENANT_ID, COST_MGMT_CLIENT_ID
# 2. Store the Azure client secret in Secret Manager:
printf '%s' 'YOUR_SECRET' | gcloud secrets create Azure_secret_value \
--project <your-gcp-project-id> --data-file=-
# 3. Deploy:
bash deploy_cloudrun.shFor the full step-by-step client setup guide including Azure Portal screenshots, see SETUP.md.
Subscription Type Requirement
The Cost Management and Billing APIs require a paid commercial Azure subscription:
✅ Works | ❌ Does NOT work |
Pay-As-You-Go | Free Trial |
Enterprise Agreement (EA) | Visual Studio / Dev/Test |
Microsoft Customer Agreement (MCA) | CSP / Sponsored |
Troubleshooting
Error | Cause | Fix |
| Wrong Client Secret in GE form | Use the |
| Cloud Run server not starting | Re-grant Secret Manager permission to the compute service account |
| Free Trial subscription | Upgrade to Pay-As-You-Go |
| Placeholder credentials in deploy script | Fill in real |
| Cloud Run SA lacks Secret Manager access | Run |
| GE service account missing invoker role | Re-run the IAM grant in |
| Missing Billing Reader role | Assign |
Tools return empty | Service principal has no subscription access | Assign |
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Hosted MCP server for AWS cloud spend: service breakdowns, anomalies, savings and forecasts.
Hosted MCP server for Google Ads and LinkedIn Ads analysis.
Cloudflare Workers MCP server: ai-cost-optimizer
Related MCP Servers
- AlicenseAqualityBmaintenanceCloud cost management MCP server for Azure. Ask your AI about your cloud bill.1529 npm1MIT
- AlicenseNot gradedqualityDmaintenanceProduction-grade MCP server for enterprise Azure cost optimization, enabling spend anomaly detection, multi-tenant auditing, budget validation, and compliance-aware recommendations.1MIT
- AlicenseNot gradedqualityDmaintenanceAnalyzes Azure cloud costs, audits for waste, and provides budget insights via natural language through a secure local MCP server.2MIT
- FlicenseBqualityDmaintenanceAn MCP server that gives Claude live access to Azure pricing and cost data — retail prices, VM comparisons, reservation analysis, architecture estimates, and actual subscription spend.9-