prometheus_label_values
Retrieve all values for a specified Prometheus label to streamline metric analysis and monitoring. This tool enables precise querying and enhances integration with monitoring infrastructure.
Instructions
Get all values for a specific Prometheus label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | label name to get values for |
Implementation Reference
- src/server/tools.ts:123-131 (handler)Tool handler for 'prometheus_label_values': takes client and args, calls client.getLabelValues(args.label). This is the direct implementation of the MCP tool execution logic.defineTool<typeof PrometheusLabelValuesSchema, LabelValues>({ capability: "discovery", name: "prometheus_label_values", title: "Get Label Values", description: "Get all values for a specific Prometheus label", inputSchema: PrometheusLabelValuesSchema, type: "readonly", handle: async (client: PrometheusClient, args) => client.getLabelValues(args.label), }),
- src/server/tools.ts:68-70 (schema)Zod input schema for the prometheus_label_values tool, defining the required 'label' parameter.const PrometheusLabelValuesSchema = z.object({ label: z.string().describe("label name to get values for"), });
- src/prometheus/client.ts:218-221 (helper)Core helper method in PrometheusClient that performs the HTTP GET request to Prometheus API endpoint /api/v1/label/{label}/values to fetch label values.async getLabelValues(label: string): Promise<LabelValues> { const endpoint = `/api/v1/label/${encodeURIComponent(label)}/values`; return this.request<LabelValues>(endpoint); }
- src/server/tools.ts:123-131 (registration)The tool definition is added to the exported 'tools' array for registration in the MCP server.defineTool<typeof PrometheusLabelValuesSchema, LabelValues>({ capability: "discovery", name: "prometheus_label_values", title: "Get Label Values", description: "Get all values for a specific Prometheus label", inputSchema: PrometheusLabelValuesSchema, type: "readonly", handle: async (client: PrometheusClient, args) => client.getLabelValues(args.label), }),