Azure Pricing MCP Server
A Model Context Protocol (MCP) server for querying Azure pricing and estimating Terraform infrastructure costs.
Quick Start
See Getting Started Guide for detailed installation.
Features
- 🔍 Search Azure Pricing - Query Azure Retail Prices API for any service
- 💰 Calculate Costs - Estimate costs with time period conversions (hour/day/month/year)
- 🔎 Service Discovery - Auto-discover available SKUs for 6 service categories
- 📊 Terraform Estimation - Estimate complete Terraform plan costs
- 🎯 54 Resource Types - Support for all major Azure services via Terraform
- 🤖 Copilot Integration - GitHub Copilot skill for intelligent cost queries
Supported Resources (54 types - 100% coverage)
High-Priority Services:
- ⭐⭐⭐⭐⭐ Virtual Machines (Linux, Windows, AKS)
- ⭐⭐⭐⭐⭐ Functions (Consumption, Premium)
- ⭐⭐⭐⭐ Event Hubs, Service Bus, Event Grid
- ⭐⭐⭐⭐ Container Registry, Container Instances, Container Apps
- ⭐⭐⭐⭐ Application Gateway, Firewall, Load Balancer, VPN Gateway
- ⭐⭐⭐⭐ Databases (MySQL, PostgreSQL, SQL, Cosmos DB, Redis, MariaDB, SQL MI)
- ⭐⭐⭐ Storage, NetApp Files, Backup
- ⭐⭐⭐ Analytics (Data Factory, Databricks, Synapse, HDInsight)
- ⭐⭐ API Management, Logic Apps, Spring Apps
- ⭐⭐ Monitoring, Site Recovery, Maps
View all 54 supported resources →
Explore Azure services before deployment:
- discoverVmOptions - Find VMs by series/OS with specs
- discoverStorageOptions - Compare storage tiers & redundancy
- discoverDatabaseOptions - Explore database SKUs by type/tier
- discoverComputeOptions - Functions, App Service, Containers
- discoverMessagingOptions - Event Hubs, Service Bus, Event Grid
- discoverNetworkingOptions - App Gateway, Firewall, Load Balancer, VPN
- discoverGenericOptions - Fallback for any Azure service
Installation
Option 1: VS Code Extension (Recommended)
Install the miiitchdev.azure-pricing-mcp extension from the VS Code Marketplace:
code --install-extension miiitchdev.azure-pricing-mcp
Or download from GitHub Releases and install manually.
Option 2: Manual MCP Server Setup
npm run mcp:build
The server communicates via stdio and can be integrated with MCP clients like GitHub Copilot.
Integration with VS Code / GitHub Copilot
Add the server to your VS Code settings (settings.json):
{
"github.copilot.chat.mcp.servers": {
"azure-pricing": {
"command": "node",
"args": ["/absolute/path/to/azurepricing.mcp/dist/mcp/server.js"]
}
}
}
Replace /absolute/path/to/azurepricing.mcp with the actual path to this project.
Step 2: Install Copilot Skill
The Copilot skill is located in .github/skills/azure-pricing/. For repository-wide use:
- The skill is already in the correct location
- Copilot will auto-discover it when you open this repository in VS Code
For personal use (across all projects), copy the skill to your personal skills directory:
# macOS/Linux
cp -r .github/skills/azure-pricing ~/.copilot/skills/
# Windows
xcopy /E /I .github\skills\azure-pricing %USERPROFILE%\.copilot\skills\azure-pricing
Step 3: Verify Setup
- Open VS Code with this repository
- Open Copilot Chat (Cmd/Ctrl + I)
- Type
/skills to see available skills
- Look for "azure-pricing" in the list
- Ask: "@azure-pricing show me d-series vms in eastus"
1. searchPrices
Search for Azure retail prices with filters.
Parameters:
serviceName (string): Azure service name (e.g., "Virtual Machines", "Storage")
armRegionName (string): Azure region (e.g., "eastus", "westeurope")
armSkuName (string): SKU name (e.g., "Standard_D2s_v3")
productName (string): Product name pattern
unitOfMeasure (string): Unit (e.g., "1 Hour", "1 GB/Month")
limit (number): Max results (default: 10)
Example:
@azure-pricing search prices for Virtual Machines in eastus with SKU Standard_D2s_v3
3. calculateCost
Calculate cost for a specific Azure service.
Parameters:
serviceName (string, required): Service name
armRegionName (string, required): Region
armSkuName (string): SKU name
quantity (number, required): Quantity (e.g., number of VMs, GB)
period (string): Time period - "hour", "day", "month" (default), "year"
Example:
@azure-pricing calculate cost for 2 VMs with Standard_D2s_v3 in eastus for 1 month
4. discoverVmOptions
Discover available VM SKUs with pricing in a region. Helps explore VM options before deployment.
Parameters:
armRegionName (string, required): Azure region (e.g., "eastus", "westeurope")
seriesFilter (string, optional): VM series filter (e.g., "d", "e", "f" for D/E/F-series)
osType (string, optional): Operating system - "Linux" or "Windows"
limit (number, optional): Maximum results (default: 20)
Example:
@azure-pricing show me available D-series Linux VMs in East US
See VM Discovery Documentation for detailed usage examples.
Estimate total cost for a Terraform plan (resources to be created/updated).
Parameters:
planJson (string, required): Terraform plan JSON (from terraform show -json tfplan)
period (string): Time period - "hour", "day", "month" (default), "year"
Example:
# Generate plan and estimate
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
# Use with MCP
@azure-pricing estimate cost for my terraform plan
NEW - Estimate cost for existing Terraform infrastructure from state file.
Parameters:
stateJson (string, required): Terraform state JSON (from terraform show -json or .tfstate file)
period (string): Time period - "hour", "day", "month" (default), "year"
Example:
# Get current state cost
terraform show -json > state.json
# Use with MCP
@azure-pricing estimate cost for my current terraform state
Use Cases:
- Audit current infrastructure costs
- Track spending over time
- Compare environments (dev vs prod)
NEW - Compare costs between current state and planned changes. Shows before/after and delta.
Parameters:
stateJson (string, required): Current Terraform state JSON
planJson (string, required): Terraform plan JSON with changes
period (string): Time period - "hour", "day", "month" (default), "year"
Example:
# Generate both state and plan
terraform show -json > state.json
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
# Compare costs
@azure-pricing compare costs between my state and plan
Output:
- Current state cost
- After changes cost
- Delta ($ and %)
- Impact indicator (increase/decrease/no change)
Use Cases:
- Review cost impact before applying changes
- Infrastructure change approval process
- Budget planning and forecasting
8. listSupportedResources
List all 54 supported Terraform resource types.
Example:
@azure-pricing what terraform resources are supported?
9. discoverStorageOptions
Explore storage SKUs with filtering.
Parameters:
armRegionName (required): Azure region
storageType (optional): blob, file, queue, table, datalake
performanceTier (optional): Standard, Premium
redundancyFilter (optional): LRS, GRS, ZRS, GZRS
limit (optional): Max results (default: 20)
10. discoverDatabaseOptions
Explore database SKUs by type and tier.
Parameters:
armRegionName (required): Azure region
databaseType (required): mysql, postgresql, sql, cosmosdb, redis, mariadb, sqlmi, cassandra
tier (optional): Basic, GeneralPurpose, BusinessCritical
generation (optional): Gen4, Gen5
limit (optional): Max results (default: 20)
8. discoverComputeOptions
Explore Functions, App Service, Container options.
Parameters:
armRegionName (required): Azure region
computeType (required): functions, appservice, containerinstances, containerapps
tier (optional): Basic, Standard, Premium
osType (optional): Linux, Windows
limit (optional): Max results (default: 20)
9. discoverMessagingOptions
Explore Event Hubs, Service Bus, Event Grid SKUs.
Parameters:
armRegionName (required): Azure region
messagingType (required): eventhub, servicebus, eventgrid
tier (optional): Basic, Standard, Premium
limit (optional): Max results (default: 20)
10. discoverNetworkingOptions
Explore networking service SKUs.
Parameters:
armRegionName (required): Azure region
networkingType (required): applicationgateway, firewall, loadbalancer, vpn
tier (optional): Basic, Standard, Premium, WAF
limit (optional): Max results (default: 20)
11. discoverGenericOptions
Fallback discovery for any Azure service.
Parameters:
serviceName (required): Exact Azure service name
armRegionName (required): Azure region
productFilter (optional): Filter by product pattern
skuFilter (optional): Filter by SKU pattern
unitOfMeasure (optional): Filter by unit
limit (optional): Max results (default: 20)
Example:
@azure-pricing show me Azure Data Factory v2 options in eastus
# Initialize and create plan
terraform init
terraform plan -out=tfplan
# Convert to JSON
terraform show -json tfplan > plan.json
Then use the JSON content with the estimateTerraformCost tool.
See the examples/ directory:
simple-plan.json: Basic VM, storage, and public IP
aks-plan.json: Kubernetes cluster with PostgreSQL database
Testing the Server
Manual Test
# Build first
npm run build
# Run the server (it will wait for stdin)
node dist/mcp/server.js
# Send a request (paste this JSON and press Enter)
{"jsonrpc":"2.0","id":1,"method":"tools/list"}
# Or test with a tool call
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"listSupportedResources","arguments":{}}}
Using Examples
node dist/mcp/server.js
# Then send:
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"estimateTerraformCost","arguments":{"planJson":"<paste-examples/simple-plan.json-content>"}}}
Architecture
src/
├── mcp/
│ └── server.ts # MCP server and 5 tool handlers
├── pricing/
│ ├── PricingCalculator.ts # Azure Pricing API client with caching
│ ├── PricingDiscovery.ts # VM discovery service
│ └── types.ts # TypeScript interfaces
├── calculator/
│ ├── CostCalculator.ts # Cost calculation logic
│ └── UnitConverter.ts # Unit conversion (hours, GB, etc.)
└── terraform/
├── TerraformParser.ts # Parse Terraform plan JSON
├── TerraformCostEstimator.ts # Main orchestrator
└── ResourceMapper.ts # Map TF resources to Azure
Unit of Measure Handling
The server automatically handles different Azure pricing units:
- Time-based (
1 Hour): VMs, databases → multiply by hours in period
- Storage (
1 GB/Month): Storage accounts → quantity is GB capacity
- Data Transfer (
1 GB): Network egress → quantity is GB transferred
- Static (
1/Month): Public IPs → flat monthly rate
- Transactions (
100 Transactions): Storage operations
Documentation
Note: Old documentation in .github/skills/azure-pricing/ is deprecated. Use .github/skills/azure-pricing/ instead.
Key Concepts
Time Period Calculations
The server uses Azure's standard calculation:
- 1 month = 730 hours (365 days × 24 hours ÷ 12 months)
- 1 year = 8,760 hours (365 days × 24 hours)
- All calculations assume 24/7 operation unless specified
See Time Period Handling for formulas and examples.
Pricing Type
All estimates use Consumption pricing (pay-as-you-go). Reserved Instances and Spot pricing are not included.
Error Handling
- Unsupported Terraform resources are reported but don't fail estimation
- Missing pricing data returns null for specific resources
- All errors include descriptive messages
Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run basic tests (4 tests)
npm test
# Run comprehensive resource tests (17 tests)
npm run test:resources
# Run VM discovery tests
npm run test:discovery
# Run all tests
npm run test:all
# Development mode with auto-reload
npm run mcp:dev
# Build and run server
npm run mcp:build
Testing
See TESTING.md for detailed testing documentation.
Test Suites:
npm test - Basic functionality (4 tests)
npm run test:resources - All 11 resource types (17 tests)
npm run test:discovery - VM discovery
npm run test:all - Complete test suite
Note: Resource tests may show warnings for missing pricing data. This is normal due to Azure API pagination and availability. Tests validate code logic, not API data completeness.
API Reference
Azure Retail Prices API
Base URL: https://prices.azure.com/api/retail/prices
API Version: 2023-01-01-preview
OData Filters Supported:
serviceName eq 'Virtual Machines'
armRegionName eq 'eastus'
armSkuName eq 'Standard_D2s_v3'
contains(productName, 'Linux')
type eq 'Consumption'
Troubleshooting
Server not responding
Make sure the server is running and accessible:
node dist/mcp/server.js
You should see: Azure Pricing MCP Server running on stdio
No prices found
- Check region name (use
armRegionName like "eastus", not "East US")
- Verify SKU name is correct (e.g., "Standard_D2s_v3")
- Some resources may not have pricing data in all regions
- Ensure you're using JSON format:
terraform show -json tfplan
- Check that resource types are supported: use
listSupportedResources tool
- Verify the plan includes
resource_changes array
Contributing
To add support for new Terraform resource types:
- Add mapping to
src/terraform/ResourceMapper.ts
- Define
serviceName, extractSku, and skuField
- Rebuild and test
License
MIT
Links