Skip to main content
Glama
pab1it0

Prometheus MCP Server

get_metric_metadata

Retrieve metadata for Prometheus metrics to understand data types, units, and structure for effective monitoring and analysis.

Instructions

Get metadata for a specific metric

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricYes

Implementation Reference

  • Registration of the get_metric_metadata tool using the @mcp.tool decorator, including description and UI annotations.
    @mcp.tool(
        description="Get metadata for a specific metric",
        annotations={
            "title": "Get Metric Metadata",
            "icon": "ℹ️",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True
        }
    )
  • The handler function that implements the core logic of get_metric_metadata: queries Prometheus /api/v1/metadata endpoint, handles different response structures ('metadata', 'data', or raw), converts single dict to list if needed, and returns the metadata.
    async def get_metric_metadata(metric: str) -> List[Dict[str, Any]]:
        """Get metadata about a specific metric.
    
        Args:
            metric: The name of the metric to retrieve metadata for
    
        Returns:
            List of metadata entries for the metric
        """
        logger.info("Retrieving metric metadata", metric=metric)
        endpoint = f"metadata?metric={metric}"
        data = make_prometheus_request(endpoint, params=None)
        if "metadata" in data:
            metadata = data["metadata"]
        elif "data" in data:
            metadata = data["data"]
        else:
            metadata = data
        if isinstance(metadata, dict):
            metadata = [metadata]
        logger.info("Metric metadata retrieved", metric=metric, metadata_count=len(metadata))
        return metadata

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/pab1it0/prometheus-mcp-server'

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