Skip to main content
Glama
msftnadavbh

Azure Pricing MCP Server

by msftnadavbh

azure_discover_skus

Find available SKUs for Azure services to compare pricing and features across regions, helping users select the right configuration for their needs.

Instructions

Discover available SKUs for a specific Azure service

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
service_nameYesAzure service name
regionNoAzure region (optional)
price_typeNoPrice type (default: 'Consumption')Consumption
limitNoMaximum number of SKUs to return (default: 100)

Implementation Reference

  • Core implementation of discover_skus in SKUService. This method builds filter conditions based on service_name, region, and price_type, fetches prices from the Azure pricing API, and aggregates unique SKUs with their metadata (name, price, region availability). Returns a structured response with SKU list, total count, and filter metadata.
    async def discover_skus(
        self,
        service_name: str,
        region: str | None = None,
        price_type: str = "Consumption",
        limit: int = 100,
    ) -> dict[str, Any]:
        """Discover available SKUs for a specific Azure service."""
        filter_conditions = [f"serviceName eq '{service_name}'"]
    
        if region:
            filter_conditions.append(f"armRegionName eq '{region}'")
    
        if price_type:
            filter_conditions.append(f"priceType eq '{price_type}'")
    
        data = await self._pricing_service._client.fetch_prices(
            filter_conditions=filter_conditions,
            currency_code="USD",
            limit=limit,
        )
    
        skus: dict[str, dict[str, Any]] = {}
        items = data.get("Items", [])
    
        for item in items:
            sku_name = item.get("skuName")
            arm_sku_name = item.get("armSkuName")
            product_name = item.get("productName")
            item_region = item.get("armRegionName")
            price = item.get("retailPrice", 0)
            unit = item.get("unitOfMeasure")
            meter_name = item.get("meterName")
    
            if sku_name and sku_name not in skus:
                skus[sku_name] = {
                    "sku_name": sku_name,
                    "arm_sku_name": arm_sku_name,
                    "product_name": product_name,
                    "sample_price": price,
                    "unit_of_measure": unit,
                    "meter_name": meter_name,
                    "sample_region": item_region,
                    "available_regions": [item_region] if item_region else [],
                }
            elif sku_name and item_region and item_region not in skus[sku_name]["available_regions"]:
                skus[sku_name]["available_regions"].append(item_region)
    
        sku_list = list(skus.values())
        sku_list.sort(key=lambda x: x["sku_name"])
    
        return {
            "service_name": service_name,
            "skus": sku_list,
            "total_skus": len(sku_list),
            "price_type": price_type,
            "region_filter": region,
        }
  • Tool handler that bridges MCP tool calls to the SKUService. The handle_discover_skus method receives arguments, calls the sku_service.discover_skus method, formats the result using format_discover_skus_response, and returns a TextContent object.
    async def handle_discover_skus(self, arguments: dict[str, Any]) -> list[TextContent]:
        """Handle azure_discover_skus tool calls."""
        result = await self._sku_service.discover_skus(**arguments)
        response_text = format_discover_skus_response(result)
        return [TextContent(type="text", text=response_text)]
  • Tool schema definition for azure_discover_skus. Defines the input parameters: service_name (required), region (optional), price_type (default: 'Consumption'), and limit (default: 100). This is used by MCP clients to understand the tool's interface.
    Tool(
        name="azure_discover_skus",
        description="Discover available SKUs for a specific Azure service",
        inputSchema={
            "type": "object",
            "properties": {
                "service_name": {
                    "type": "string",
                    "description": "Azure service name",
                },
                "region": {
                    "type": "string",
                    "description": "Azure region (optional)",
                },
                "price_type": {
                    "type": "string",
                    "description": "Price type (default: 'Consumption')",
                    "default": "Consumption",
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum number of SKUs to return (default: 100)",
                    "default": 100,
                },
            },
            "required": ["service_name"],
        },
    ),
  • Tool routing registration in the MCP server. This code maps the 'azure_discover_skus' tool name to its handler method (handle_discover_skus) within the server's call_tool handler.
    elif name == "azure_discover_skus":
        return await handlers.handle_discover_skus(arguments)
  • Response formatter for discover_skus output. Converts the structured result dictionary into a human-readable string, displaying the total count of SKUs found and formatting the SKU list as JSON. Returns a 'No SKUs found' message if the list is empty.
    def format_discover_skus_response(result: dict[str, Any]) -> str:
        """Format the discover SKUs response for display."""
        skus = result.get("skus", [])
        if skus:
            return f"Found {result['total_skus']} SKUs for {result['service_name']}:\n\n" + json.dumps(skus, indent=2)
        else:
            return "No SKUs found for the specified service."

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