Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_prometheus_metric_metadata

Retrieve metadata for Prometheus metrics scraped from monitoring targets. Use this tool to explore available metrics, their types, and labels for a specified Grafana datasource.

Instructions

List Prometheus metric metadata. Returns metadata about metrics currently scraped from targets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasourceUidYesThe UID of the datasource to query
limitNoThe maximum number of metrics to return
limitPerMetricNoThe maximum number of metrics to return per metric
metricNoThe metric to query

Implementation Reference

  • The ToolDefinition for 'list_prometheus_metric_metadata' including its handler function that uses PrometheusClient.getMetricMetadata to fetch metric metadata.
    export const listPrometheusMetricMetadata: ToolDefinition = {
      name: 'list_prometheus_metric_metadata',
      description: 'List Prometheus metric metadata. Returns metadata about metrics currently scraped from targets.',
      inputSchema: ListPrometheusMetricMetadataSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = new PrometheusClient(context.config.grafanaConfig, params.datasourceUid);
          
          const metadata = await client.getMetricMetadata(params.metric, params.limit);
          
          return createToolResult(metadata);
        } catch (error: any) {
          return createErrorResult(error.message);
        }
      },
    };
  • Zod input schema for the tool defining parameters: datasourceUid, optional metric, limit, and limitPerMetric.
    const ListPrometheusMetricMetadataSchema = z.object({
      datasourceUid: z.string().describe('The UID of the datasource to query'),
      metric: z.string().optional().describe('The metric to query'),
      limit: z.number().optional().describe('The maximum number of metrics to return'),
      limitPerMetric: z.number().optional().describe('The maximum number of metrics to return per metric'),
    });
  • Specific registration of the listPrometheusMetricMetadata tool within the registerPrometheusTools function.
    server.registerTool(listPrometheusMetricMetadata);
  • src/cli.ts:107-108 (registration)
    Top-level conditional registration of Prometheus tools (including list_prometheus_metric_metadata) in the CLI entrypoint by invoking registerPrometheusTools.
    if (enabledTools.has('prometheus')) {
      registerPrometheusTools(server);
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the return type ('metadata about metrics') but lacks critical behavioral details: it doesn't specify if this is a read-only operation, what format the metadata is in (e.g., JSON structure), whether it's paginated or limited by default, or any authentication requirements. The description is minimal and leaves key behaviors undocumented.

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 two sentences, front-loaded with the core purpose and followed by a clarifying detail about returns. Every word earns its place with zero waste, making it highly efficient and easy to parse quickly.

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?

Given the complexity (4 parameters, no annotations, no output schema), the description is incomplete. It doesn't address the tool's behavior (e.g., read-only nature, response format), usage context, or how parameters affect results. For a tool with multiple parameters and no structured output, more detail is needed to guide effective use.

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?

Schema description coverage is 100%, so the schema already documents all parameters (datasourceUid, limit, limitPerMetric, metric). The description adds no additional meaning beyond what's in the schema—it doesn't explain how parameters interact (e.g., 'metric' filters results) or provide examples. With high schema coverage, the baseline is 3, and the description doesn't compensate further.

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 ('List') and resource ('Prometheus metric metadata'), and specifies what it returns ('metadata about metrics currently scraped from targets'). It distinguishes from some siblings like 'list_prometheus_metric_names' by focusing on metadata rather than just names, though it doesn't explicitly contrast with all relevant siblings like 'query_prometheus'.

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. It doesn't mention when to choose it over 'list_prometheus_metric_names' (for names only) or 'query_prometheus' (for metric values), nor does it specify prerequisites like needing a datasource. Usage is implied but not explicitly stated.

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/0xteamhq/mcp-grafana'

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