Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_pyroscope_label_names

Retrieve all label names from Pyroscope profile data within a specified time range and filtering criteria to analyze application performance metrics.

Instructions

Lists all available label names found in profiles within a Pyroscope datasource

Input Schema

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

Implementation Reference

  • The ToolDefinition export for 'list_pyroscope_label_names' including the core handler function that executes the tool logic: creates an axios client for the Pyroscope datasource, handles time ranges and matchers, queries the /pyroscope/api/v1/label-names endpoint, filters out internal labels (starting with '__'), and returns the list of label names.
    export const listPyroscopeLabelNames: ToolDefinition = {
      name: 'list_pyroscope_label_names',
      description: 'Lists all available label names found in profiles within a Pyroscope datasource',
      inputSchema: ListPyroscopeLabelNamesSchema,
      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 = {
            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-names', { params: queryParams });
          
          // Filter out internal labels (those starting with __)
          const labels = (response.data.data || []).filter((label: string) => !label.startsWith('__'));
          
          return createToolResult(labels);
        } catch (error: any) {
          return createErrorResult(error.response?.data?.message || error.message);
        }
      },
    };
  • Zod schema defining the input parameters for the list_pyroscope_label_names tool: data_source_uid (required), optional start/end times in RFC3339, and optional Prometheus-style matchers.
    const ListPyroscopeLabelNamesSchema = z.object({
      data_source_uid: z.string().describe('The UID of the datasource to query'),
      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'),
    });
  • The server.registerTool call that registers the list_pyroscope_label_names tool within the registerPyroscopeTools function.
    server.registerTool(listPyroscopeLabelNames);
  • Helper function createPyroscopeClient used by the handler to create an axios instance configured for the specific Pyroscope datasource with authentication.
    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 getDefaultTimeRange used by the handler to provide default start/end times (last hour) if not specified in parameters.
    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?

No annotations are provided, so the description carries the full burden. It mentions 'Lists all available label names' but doesn't disclose behavioral traits like whether this is a read-only operation, if it requires specific permissions, rate limits, pagination behavior, or what the output format looks like. For a tool with 4 parameters and no annotations, this is a significant gap.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to understand at a glance. Every part of the sentence earns its place.

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's complexity (4 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return values, behavioral constraints, or how parameters like matchers and time ranges affect the results. For a query tool with multiple inputs, more context is needed to guide effective usage.

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 schema description coverage is 100%, so all parameters are documented in the schema. The description doesn't add any additional meaning beyond what the schema provides (e.g., it doesn't explain how matchers interact with label names or the time range's effect). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate with extra insights.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Lists all available label names') and the resource ('found in profiles within a Pyroscope datasource'). It distinguishes itself from sibling tools like list_pyroscope_label_values and list_prometheus_label_names by specifying it's for Pyroscope label names, not values or Prometheus labels.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving label names from Pyroscope profiles, but doesn't explicitly state when to use this tool versus alternatives like list_pyroscope_label_values or list_prometheus_label_names. It provides basic context but lacks explicit guidance on exclusions or specific use cases.

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