Skip to content

miiitch/azurepricing.mcp

Repository files navigation

PricingCalculator MCP Server for Microsoft Azure

A Model Context Protocol (MCP) server for querying Microsoft Azure pricing and estimating Terraform infrastructure costs.

Quick Start

See Getting Started Guide for detailed installation.

Features

  • 🔍 Search Azure Pricing - Query Microsoft 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 7 service categories
  • 📊 Terraform Estimation - Estimate complete Terraform plan costs
  • 🎯 54 Resource Types - Support for all major Microsoft Azure services via Terraform

View all 54 supported resources →

Discovery Tools (7 specialized + 1 generic)

Explore Microsoft Azure services before deployment:

  1. discoverVmOptions - Find VMs by series/OS with specs
  2. discoverStorageOptions - Compare storage tiers & redundancy
  3. discoverDatabaseOptions - Explore database SKUs by type/tier
  4. discoverComputeOptions - Functions, Container Instances, Container Apps
  5. discoverAppServiceOptions - App Service Plans by tier & OS
  6. discoverMessagingOptions - Event Hubs, Service Bus, Event Grid
  7. discoverNetworkingOptions - App Gateway, Firewall, Load Balancer, VPN
  8. discoverGenericOptions - Fallback for any Microsoft Azure service

Installation

Install the miiitchdev.pricingcalc-azure-mcp extension from the VS Code Marketplace:

code --install-extension miiitchdev.pricingcalc-azure-mcp

Available MCP Tools (14 total)

Pricing Tools

1. searchPrices

Search for Microsoft Azure retail prices with filters.

Parameters:

  • serviceName (string): Microsoft Azure service name (e.g., "Virtual Machines", "Storage")
  • armRegionName (string): Microsoft 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

2. calculateCost

Calculate cost for a specific Microsoft 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

3. discoverVmOptions

Discover available VM SKUs with pricing in a region. Helps explore VM options before deployment.

Parameters:

  • armRegionName (string, required): Microsoft Azure region (e.g., "eastus", "westeurope")
  • osType (string, required): Operating system - "Linux" or "Windows"
  • seriesFilter (string, optional): VM series filter (e.g., "d", "e", "f" for D/E/F-series)
  • limit (number, optional): Maximum results (default: 20)

Note: The osType parameter ensures accurate pricing comparisons by preventing mixing of Linux and Windows VM pricing (which includes Windows Server licensing). Spot VMs are automatically excluded for consistent results.

Example:

@azure-pricing show me available D-series Linux VMs in East US

See VM Discovery Documentation for detailed usage examples.

Terraform Tools

4. estimateTerraformCost

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

5. estimateTerraformState

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)

6. compareTerraformCosts

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

Utility Tools

7. listSupportedResources

List all 54 supported Terraform resource types.

Example:

@azure-pricing what terraform resources are supported?

Discovery Tools (7)

8. discoverStorageOptions

Explore storage SKUs with filtering.

Parameters:

  • armRegionName (required): Microsoft 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)

9. discoverDatabaseOptions

Explore database SKUs by type and tier.

Parameters:

  • armRegionName (required): Microsoft 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)

10. discoverComputeOptions

Explore Functions, Container Instances, and Container Apps options.

Parameters:

  • armRegionName (required): Microsoft Azure region
  • computeType (required): functions, appservice, containerinstances, containerapps
  • tier (optional): Basic, Standard, Premium
  • osType (optional): Linux, Windows
  • limit (optional): Max results (default: 20)

11. discoverAppServiceOptions

Discover Azure App Service Plan SKUs and pricing. Filter by tier and OS type.

Parameters:

  • armRegionName (required): Microsoft Azure region
  • tier (optional): Basic, Standard, Premium, PremiumV2, PremiumV3, Isolated, IsolatedV2
  • osType (optional): Linux, Windows
  • currencyCode (optional): Currency code (default: USD)
  • limit (optional): Max results (default: 20)

Example:

@azure-pricing show me Premium App Service Plans for Linux in westeurope

12. discoverMessagingOptions

Explore Event Hubs, Service Bus, Event Grid SKUs.

Parameters:

  • armRegionName (required): Microsoft Azure region
  • messagingType (required): eventhub, servicebus, eventgrid
  • tier (optional): Basic, Standard, Premium
  • limit (optional): Max results (default: 20)

13. discoverNetworkingOptions

Explore networking service SKUs.

Parameters:

  • armRegionName (required): Microsoft Azure region
  • networkingType (required): applicationgateway, firewall, loadbalancer, vpn
  • tier (optional): Basic, Standard, Premium, WAF
  • limit (optional): Max results (default: 20)

14. discoverGenericOptions

Fallback discovery for any Microsoft Azure service.

Parameters:

  • serviceName (required): Exact Microsoft Azure service name
  • armRegionName (required): Microsoft 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

Available MCP Prompts (6)

Prompts are reusable chat prompt templates accessible via @mcp slash commands in VS Code. They guide the AI to orchestrate the tools above into complete workflows.

1. estimateArchitecture

Estimate the monthly cost of an Azure architecture described in natural language.

Arguments:

  • description (required): Natural language description of the architecture
  • region (required): Azure region (e.g., "westeurope")
  • currency (optional): Currency code (default: USD)

Example:

/mcp.pricingcalc-azure-mcp.estimateArchitecture
→ "2 D4s_v3 Linux VMs, a PostgreSQL Flexible Server GP tier, and 500GB blob storage in westeurope"

2. reviewTerraformPlan

Analyze a Terraform plan JSON and produce a detailed cost report with per-resource breakdown.

Arguments:

  • planJson (required): Terraform plan JSON output
  • currency (optional): Currency code (default: USD)

3. compareTerraformChanges

Compare costs between current Terraform state and planned changes with delta analysis.

Arguments:

  • stateJson (required): Current Terraform state JSON
  • planJson (required): Terraform plan JSON with proposed changes
  • currency (optional): Currency code (default: USD)

4. findCheapestVm

Find the cheapest Azure VMs matching specific requirements, sorted by price.

Arguments:

  • region (required): Azure region
  • os (required): "Linux" or "Windows"
  • minCpu (optional): Minimum vCPUs required
  • minRamGb (optional): Minimum RAM in GB required

Example:

/mcp.pricingcalc-azure-mcp.findCheapestVm
→ region: westeurope, os: Linux, minCpu: 4, minRamGb: 16

5. compareRegionPricing

Compare pricing for an Azure service/SKU across multiple regions.

Arguments:

  • serviceName (required): Azure service name
  • skuName (required): SKU name
  • regions (required): Comma-separated list of regions

Example:

/mcp.pricingcalc-azure-mcp.compareRegionPricing
→ serviceName: Virtual Machines, skuName: Standard_D2s_v3, regions: eastus,westeurope,francecentral

6. estimateMonthlyBudget

Calculate the monthly budget for a specific Azure service with quantity and cost breakdown.

Arguments:

  • serviceName (required): Azure service name
  • sku (required): SKU name
  • region (required): Azure region
  • quantity (required): Number of instances
  • currency (optional): Currency code (default: USD)

How to Generate Terraform Plan JSON

# 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.

Example Terraform Plans

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 with 15 tools and 6 prompts
├── pricing/
│   ├── PricingCalculator.ts       # Azure Pricing API client with caching
│   ├── PricingDiscovery.ts        # Service discovery (VMs, storage, databases, etc.)
│   └── 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

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 - Resource type mapping 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: PricingCalculator MCP Server for Microsoft Azure 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

Terraform plan not working

  • 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:

  1. Add mapping to src/terraform/ResourceMapper.ts
  2. Define serviceName, extractSku, and skuField
  3. Rebuild and test

License

MIT

Links


Legal Notice

Microsoft, Azure, Terraform, and GitHub are trademarks of their respective owners.

This is an independent open-source project and is not affiliated with, endorsed by, or sponsored by Microsoft Corporation, HashiCorp, Inc., or GitHub, Inc.

This tool is designed to work with Microsoft Azure services and the Terraform infrastructure-as-code tool.

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors