Skip to main content
Glama
pab1it0

Prometheus MCP Server

Get Metric Metadata

get_metric_metadata
Read-onlyIdempotent

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
Behavior4/5

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

Annotations already provide strong behavioral hints (readOnlyHint: true, openWorldHint: true, idempotentHint: true, destructiveHint: false), indicating this is a safe, read-only operation that can handle unknown metrics and is idempotent. The description adds no additional behavioral context beyond what annotations cover, but it doesn't contradict them either, so it meets the baseline for annotations present.

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 a single, clear sentence with no wasted words. It's front-loaded with the core purpose, making it highly efficient and easy to parse at a glance.

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

Completeness4/5

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

Given the tool's low complexity (1 parameter), rich annotations covering safety and behavior, and the presence of an output schema (which handles return values), the description is reasonably complete. However, it lacks usage differentiation from siblings and parameter details, leaving some gaps in context.

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 input schema has 1 parameter with 0% description coverage, meaning the schema doesn't explain what 'metric' represents. The description adds minimal context by implying it's for a 'specific metric', but doesn't clarify format, examples, or constraints. With low schema coverage, the description should compensate more to reach a higher score.

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 verb 'Get' and the resource 'metadata for a specific metric', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_metrics' or 'get_targets', which might provide related information about metrics or targets.

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 like 'list_metrics' or 'execute_query'. It doesn't mention prerequisites, such as needing a valid metric name, or contextual cues for selecting this specific metadata retrieval tool.

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

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