Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_pyroscope_label_values

Retrieve all available label values for a specific label name within profiling data, enabling targeted analysis of application performance metrics across defined time ranges.

Instructions

Lists all available label values for a particular label name in profiles

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
data_source_uidYesThe UID of the datasource to query
end_rfc_3339NoEnd time in RFC3339 format
matchersNoPrometheus-style matchers
nameYesA label name
start_rfc_3339NoStart time in RFC3339 format

Implementation Reference

  • Full ToolDefinition for 'list_pyroscope_label_values' including the inline handler function that queries the Pyroscope API (/pyroscope/api/v1/label-values) for label values using axios.
    export const listPyroscopeLabelValues: ToolDefinition = {
      name: 'list_pyroscope_label_values',
      description: 'Lists all available label values for a particular label name in profiles',
      inputSchema: ListPyroscopeLabelValuesSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = createPyroscopeClient(context.config.grafanaConfig, params.data_source_uid);
          const timeRange = params.start_rfc_3339 || params.end_rfc_3339 
            ? { start: '', end: '' } 
            : getDefaultTimeRange();
          
          const queryParams: any = {
            label: params.name,
            start: params.start_rfc_3339 || timeRange.start,
            end: params.end_rfc_3339 || timeRange.end,
          };
          
          if (params.matchers) {
            queryParams.matchers = params.matchers;
          }
          
          const response = await client.get('/pyroscope/api/v1/label-values', { params: queryParams });
          
          return createToolResult(response.data.data || []);
        } catch (error: any) {
          return createErrorResult(error.response?.data?.message || error.message);
        }
      },
    };
  • Zod schema defining the input parameters for the list_pyroscope_label_values tool.
    const ListPyroscopeLabelValuesSchema = z.object({
      data_source_uid: z.string().describe('The UID of the datasource to query'),
      name: z.string().describe('A label name'),
      start_rfc_3339: z.string().optional().describe('Start time in RFC3339 format'),
      end_rfc_3339: z.string().optional().describe('End time in RFC3339 format'),
      matchers: z.string().optional().describe('Prometheus-style matchers'),
    });
  • Registration function that registers all Pyroscope tools with the MCP server, including listPyroscopeLabelValues.
    export function registerPyroscopeTools(server: any) {
      server.registerTool(listPyroscopeLabelNames);
      server.registerTool(listPyroscopeLabelValues);
      server.registerTool(listPyroscopeProfileTypes);
      server.registerTool(fetchPyroscopeProfile);
    }
  • Helper function to create an authenticated axios client for querying a Pyroscope datasource via Grafana proxy.
    function createPyroscopeClient(config: any, datasourceUid: string) {
      const headers: any = {
        'User-Agent': 'mcp-grafana/1.0.0',
      };
      
      if (config.serviceAccountToken) {
        headers['Authorization'] = `Bearer ${config.serviceAccountToken}`;
      } else if (config.apiKey) {
        headers['Authorization'] = `Bearer ${config.apiKey}`;
      }
      
      return axios.create({
        baseURL: `${config.url}/api/datasources/proxy/uid/${datasourceUid}`,
        headers,
        timeout: 30000,
      });
    }
  • Helper function providing default time range (last hour) for queries when not specified.
    function getDefaultTimeRange(): { start: string; end: string } {
      const now = new Date();
      const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
      return {
        start: oneHourAgo.toISOString(),
        end: now.toISOString(),
      };
    }
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 but offers minimal information. It states what the tool does but doesn't cover critical aspects like whether it's a read-only operation, potential rate limits, authentication needs, error handling, or the format of returned values. This leaves significant gaps in understanding how the tool behaves in practice.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it efficient and easy to parse, with no wasted information.

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 tool has 5 parameters, no annotations, and no output schema, the description is insufficiently complete. It lacks details on behavioral traits (e.g., read-only nature, error cases), usage context, and output format, which are critical for an AI agent to invoke this tool correctly in a real-world scenario.

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%, meaning all parameters are documented in the input schema. The description doesn't add any semantic details beyond what's in the schema (e.g., explaining relationships between parameters like 'start_rfc_3339' and 'end_rfc_3339', or clarifying 'matchers' usage). Baseline score of 3 is appropriate as the schema handles parameter documentation adequately.

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 action ('Lists') and resource ('all available label values for a particular label name in profiles'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_pyroscope_label_names' or 'list_prometheus_label_values', which would require mentioning Pyroscope-specific context or contrasting with other listing tools.

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 sibling tools (e.g., 'list_pyroscope_label_names' for names instead of values, or 'list_prometheus_label_values' for a different data source), prerequisites, or specific contexts where this tool is preferred, leaving usage ambiguous.

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