Skip to main content
Glama

prometheus_list_labels

Retrieve all available Prometheus labels for metric analysis and monitoring. Enables efficient querying and organization of metrics within the Prometheus ecosystem.

Instructions

List all available Prometheus labels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of the prometheus_list_labels tool logic. The PrometheusClient.listLabels() method makes an HTTP GET request to the Prometheus /api/v1/labels endpoint to retrieve all label names.
    async listLabels(): Promise<Labels> { const endpoint = "/api/v1/labels"; return this.request<Labels>(endpoint); }
  • Registers the prometheus_list_labels tool in the tools array. Specifies schema (EmptySchema, no input params), capability, and thin handler delegating to PrometheusClient.listLabels().
    defineTool<typeof EmptySchema, Labels>({ capability: "discovery", name: "prometheus_list_labels", title: "List Prometheus Labels", description: "List all available Prometheus labels", inputSchema: EmptySchema, type: "readonly", handle: async (client: PrometheusClient) => client.listLabels(), }),
  • Zod input schema for prometheus_list_labels tool (and other parameterless tools), defining no required input parameters.
    const EmptySchema = z.object({});
  • Filters tools by capability and registers prometheus_list_labels (if discovery enabled) to the MCP server using _registerTool, which calls registerTool with schema and execution handler.
    // Filter tools based on enabled capabilities const prometheusTools: ToolAny[] = tools.filter( (tool) => validatedConfig[capabilityMap[tool.capability]] ?? false, ); prometheusTools.forEach((tool) => this._registerTool(tool)); }
  • Private helper method used by listLabels() to perform the HTTP request to Prometheus API, including error handling and logging.
    private async request<T>( endpoint: string, params?: Record<string, string>, ): Promise<T> { const url = new URL(endpoint, this.baseUrl); const queryParams = new URLSearchParams(params); if (queryParams) { url.search = queryParams.toString(); } logger.debug("making prometheus request", { endpoint, url }); try { const response = await fetch(url.toString(), { method: "GET", headers: this.headers, }); if (!response.ok) { const error = `http ${response.status}: ${response.statusText}`; logger.error(error, { endpoint, status: response.status }); throw new Error(error); } const result: Response<T> = await response.json(); if (result.status !== "success") { const errorMsg = result.error || "unknown error"; const error = `prometheus api error: ${errorMsg}`; logger.error(error, { endpoint, status: result.status }); throw new Error(error); } logger.debug("prometheus request successful", { endpoint }); return result.data; } catch (error) { logger.error("prometheus request failed", { endpoint, error: error instanceof Error ? error.message : String(error), }); throw error; }

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

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