Skip to main content
Glama
msftnadavbh

Azure Pricing MCP Server

by msftnadavbh

azure_cost_estimate

Calculate Azure service costs by specifying service, SKU, region, and usage parameters to generate monthly expenditure estimates.

Instructions

Estimate Azure costs based on usage patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
service_nameYesAzure service name
sku_nameYesSKU name
regionYesAzure region
hours_per_monthNoExpected hours of usage per month (default: 730 for full month)
currency_codeNoCurrency code (default: USD)USD
discount_percentageNoDiscount percentage to apply to prices (e.g., 10 for 10% discount). If not specified and show_with_discount is false, no discount is applied. If show_with_discount is true, defaults to 10%.
show_with_discountNoSet to true to apply a discount; uses default 10% unless discount_percentage is explicitly specified.

Implementation Reference

  • The main handler function that processes azure_cost_estimate tool calls. It resolves discount settings, calls the pricing service's estimate_costs method, attaches discount metadata, and formats the response.
    async def handle_cost_estimate(self, arguments: dict[str, Any]) -> list[TextContent]:
        """Handle azure_cost_estimate tool calls."""
        discount_pct, discount_specified, used_default = self._resolve_discount(arguments)
    
        result = await self._pricing_service.estimate_costs(**arguments)
        self._attach_discount_metadata(result, discount_pct, discount_specified, used_default)
    
        response_text = format_cost_estimate_response(result)
        return [TextContent(type="text", text=response_text)]
  • The core business logic in PricingService.estimate_costs() that searches for prices, calculates hourly/daily/monthly/yearly costs, applies discounts if specified, and estimates savings plans pricing.
    async def estimate_costs(
        self,
        service_name: str,
        sku_name: str,
        region: str,
        hours_per_month: float = 730,
        currency_code: str = "USD",
        discount_percentage: float | None = None,
    ) -> dict[str, Any]:
        """Estimate monthly costs based on usage."""
        result = await self.search_prices(
            service_name=service_name,
            sku_name=sku_name,
            region=region,
            currency_code=currency_code,
            limit=5,
        )
    
        if not result["items"]:
            return {
                "error": f"No pricing found for {sku_name} in {region}",
                "service_name": service_name,
                "sku_name": sku_name,
                "region": region,
            }
    
        item = result["items"][0]
        hourly_rate = item.get("retailPrice", 0)
        original_hourly_rate = hourly_rate
    
        if discount_percentage is not None and discount_percentage > 0:
            hourly_rate = hourly_rate * (1 - discount_percentage / 100)
    
        monthly_cost = hourly_rate * hours_per_month
        daily_cost = hourly_rate * 24
        yearly_cost = monthly_cost * 12
    
        savings_plans = item.get("savingsPlan", [])
        savings_estimates = []
    
        for plan in savings_plans:
            plan_hourly = plan.get("retailPrice", 0)
            original_plan_hourly = plan_hourly
    
            if discount_percentage is not None and discount_percentage > 0:
                plan_hourly = plan_hourly * (1 - discount_percentage / 100)
    
            plan_monthly = plan_hourly * hours_per_month
            plan_yearly = plan_monthly * 12
            savings_percent = ((hourly_rate - plan_hourly) / hourly_rate) * 100 if hourly_rate > 0 else 0
    
            plan_data: dict[str, Any] = {
                "term": plan.get("term"),
                "hourly_rate": round(plan_hourly, 6),
                "monthly_cost": round(plan_monthly, 2),
                "yearly_cost": round(plan_yearly, 2),
                "savings_percent": round(savings_percent, 2),
                "annual_savings": round((yearly_cost - plan_yearly), 2),
            }
    
            if discount_percentage is not None and discount_percentage > 0:
                plan_data["original_hourly_rate"] = original_plan_hourly
                plan_data["original_monthly_cost"] = round(original_plan_hourly * hours_per_month, 2)
                plan_data["original_yearly_cost"] = round(original_plan_hourly * hours_per_month * 12, 2)
    
            savings_estimates.append(plan_data)
    
        estimate_result: dict[str, Any] = {
            "service_name": service_name,
            "sku_name": item.get("skuName"),
            "region": region,
            "product_name": item.get("productName"),
            "unit_of_measure": item.get("unitOfMeasure"),
            "currency": currency_code,
            "on_demand_pricing": {
                "hourly_rate": round(hourly_rate, 6),
                "daily_cost": round(daily_cost, 2),
                "monthly_cost": round(monthly_cost, 2),
                "yearly_cost": round(yearly_cost, 2),
            },
            "usage_assumptions": {
                "hours_per_month": hours_per_month,
                "hours_per_day": round(hours_per_month / 30.44, 2),
            },
            "savings_plans": savings_estimates,
        }
    
        if discount_percentage is not None and discount_percentage > 0:
            estimate_result["discount_applied"] = {
                "percentage": discount_percentage,
                "note": "All prices shown are after discount",
            }
            estimate_result["on_demand_pricing"]["original_hourly_rate"] = original_hourly_rate
            estimate_result["on_demand_pricing"]["original_daily_cost"] = round(original_hourly_rate * 24, 2)
            estimate_result["on_demand_pricing"]["original_monthly_cost"] = round(
                original_hourly_rate * hours_per_month, 2
            )
            estimate_result["on_demand_pricing"]["original_yearly_cost"] = round(
                original_hourly_rate * hours_per_month * 12, 2
            )
    
        return estimate_result
  • Tool schema definition for azure_cost_estimate with input validation including required fields (service_name, sku_name, region) and optional parameters (hours_per_month, currency_code, discount_percentage, show_with_discount).
    Tool(
        name="azure_cost_estimate",
        description="Estimate Azure costs based on usage patterns",
        inputSchema={
            "type": "object",
            "properties": {
                "service_name": {
                    "type": "string",
                    "description": "Azure service name",
                },
                "sku_name": {
                    "type": "string",
                    "description": "SKU name",
                },
                "region": {
                    "type": "string",
                    "description": "Azure region",
                },
                "hours_per_month": {
                    "type": "number",
                    "description": "Expected hours of usage per month (default: 730 for full month)",
                    "default": 730,
                },
                "currency_code": {
                    "type": "string",
                    "description": "Currency code (default: USD)",
                    "default": "USD",
                },
                "discount_percentage": {
                    "type": "number",
                    "description": "Discount percentage to apply to prices (e.g., 10 for 10% discount). If not specified and show_with_discount is false, no discount is applied. If show_with_discount is true, defaults to 10%.",
                },
                "show_with_discount": {
                    "type": "boolean",
                    "description": "Set to true to apply a discount; uses default 10% unless discount_percentage is explicitly specified.",
                    "default": False,
                },
            },
            "required": ["service_name", "sku_name", "region"],
        },
    ),
  • Server-side routing that maps the 'azure_cost_estimate' tool name to the handler's handle_cost_estimate method in the handle_call_tool function.
    elif name == "azure_cost_estimate":
        return await handlers.handle_cost_estimate(arguments)
  • Helper function that formats the cost estimate results into a human-readable text response, displaying usage assumptions, on-demand pricing, discount information, and savings plans options.
    def format_cost_estimate_response(result: dict[str, Any]) -> str:
        """Format the cost estimate response for display."""
        if "error" in result:
            return f"Error: {result['error']}"
    
        estimate_text = f"""
    Cost Estimate for {result['service_name']} - {result['sku_name']}
    Region: {result['region']}
    Product: {result['product_name']}
    Unit: {result['unit_of_measure']}
    Currency: {result['currency']}
    """
    
        if "discount_applied" in result:
            estimate_text += f"\nšŸ’° {result['discount_applied']['percentage']}% discount applied - {result['discount_applied']['note']}\n"
    
        estimate_text += f"""
    Usage Assumptions:
    - Hours per month: {result['usage_assumptions']['hours_per_month']}
    - Hours per day: {result['usage_assumptions']['hours_per_day']}
    
    On-Demand Pricing:
    - Hourly Rate: ${result['on_demand_pricing']['hourly_rate']}
    - Daily Cost: ${result['on_demand_pricing']['daily_cost']}
    - Monthly Cost: ${result['on_demand_pricing']['monthly_cost']}
    - Yearly Cost: ${result['on_demand_pricing']['yearly_cost']}
    """
    
        if "discount_applied" in result and "original_hourly_rate" in result["on_demand_pricing"]:
            estimate_text += f"""
    Original Pricing (before discount):
    - Hourly Rate: ${result['on_demand_pricing']['original_hourly_rate']}
    - Daily Cost: ${result['on_demand_pricing']['original_daily_cost']}
    - Monthly Cost: ${result['on_demand_pricing']['original_monthly_cost']}
    - Yearly Cost: ${result['on_demand_pricing']['original_yearly_cost']}
    """
    
        if result["savings_plans"]:
            estimate_text += "\nSavings Plans Available:\n"
            for plan in result["savings_plans"]:
                estimate_text += f"""
    {plan['term']} Term:
    - Hourly Rate: ${plan['hourly_rate']}
    - Monthly Cost: ${plan['monthly_cost']}
    - Yearly Cost: ${plan['yearly_cost']}
    - Savings: {plan['savings_percent']}% (${plan['annual_savings']} annually)
    """
                if "original_hourly_rate" in plan:
                    estimate_text += f"""- Original Hourly Rate: ${plan['original_hourly_rate']}
    - Original Monthly Cost: ${plan['original_monthly_cost']}
    - Original Yearly Cost: ${plan['original_yearly_cost']}
    """
    
        return estimate_text
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Estimate' implies a read-only calculation, the description doesn't address important behavioral aspects like whether this requires authentication, what format the estimate returns, whether it's real-time or cached data, rate limits, or error conditions. The description is too minimal for a tool with 7 parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 7 words with zero wasted language. It's front-loaded with the core purpose and uses efficient phrasing. Every word earns its place, making it easy to parse while conveying the essential function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 7 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (cost breakdown, total amount, comparison data), doesn't address authentication requirements, and provides no context about data sources or calculation methodology. The minimal description leaves too many operational questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides no parameter-specific information beyond the generic 'based on usage patterns'. However, with 100% schema description coverage, all 7 parameters are well-documented in the schema itself with clear descriptions and defaults. The description adds no value beyond what's already in the structured schema, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Estimate Azure costs based on usage patterns', which includes a specific verb ('Estimate') and resource ('Azure costs'). However, it doesn't explicitly differentiate this cost estimation tool from sibling tools like azure_price_compare or azure_ri_pricing, which also deal with Azure pricing calculations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools focused on Azure pricing (azure_price_compare, azure_ri_pricing, azure_sku_discovery, etc.), there's no indication of when this specific cost estimation approach is preferred or what distinguishes it from other pricing-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/msftnadavbh/AzurePricingMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server