Skip to main content
Glama

prometheus_list_metrics

Retrieve all available metrics from Prometheus monitoring systems to discover and analyze performance data for infrastructure oversight.

Instructions

List all available Prometheus metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of listing Prometheus metrics by making an HTTP GET request to the '/api/v1/label/__name__/values' endpoint via the private request method.
    async listMetrics(): Promise<LabelValues> { const endpoint = "/api/v1/label/__name__/values"; return this.request<LabelValues>(endpoint); }
  • Tool registration object defining the prometheus_list_metrics tool's metadata, input schema (empty), and thin handler delegating to PrometheusClient.listMetrics().
    defineTool<typeof EmptySchema, Labels>({ capability: "discovery", name: "prometheus_list_metrics", title: "List Prometheus Metrics", description: "List all available Prometheus metrics", inputSchema: EmptySchema, type: "readonly", handle: async (client: PrometheusClient) => client.listMetrics(), }),
  • Zod schema for input parameters. Empty object schema used by prometheus_list_metrics since it requires no parameters.
    const EmptySchema = z.object({});
  • Registers the prometheus_list_metrics tool (and others) with the MCP Server by filtering based on config and calling registerTool for each.
    const prometheusTools: ToolAny[] = tools.filter( (tool) => validatedConfig[capabilityMap[tool.capability]] ?? false, ); prometheusTools.forEach((tool) => this._registerTool(tool));
  • Wrapper handler registered with MCP that executes the specific tool.handle (for prometheus_list_metrics, calls client.listMetrics()), handles errors, and formats response as JSON text.
    private _registerTool(tool: ToolAny) { this.registerTool( tool.name, { title: tool.title, description: tool.description, inputSchema: tool.inputSchema.shape, annotations: { title: tool.title, readOnlyHint: tool.type === "readonly", destructiveHint: tool.type === "destructive", openWorldHint: false, }, }, // This tool is already typed, but the type system is not able to infer the type of the args // eslint-disable-next-line @typescript-eslint/no-explicit-any async (args: any) => { logger.info(`executing tool: ${tool.name}`); try { const result = await tool.handle(this.prometheusClient, args); logger.info(`tool ${tool.name} executed successfully`); return { isError: false, content: [{ type: "text" as const, text: JSON.stringify(result) }], }; } catch (error) { logger.error(`tool ${tool.name} execution failed`); return { isError: true, content: [ { type: "text" as const, text: error instanceof Error ? error.message : String(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