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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/prometheus/client.ts:164-167 (handler)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); }
- src/server/tools.ts:95-103 (registration)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(), }),
- src/server/tools.ts:76-76 (schema)Zod schema for input parameters. Empty object schema used by prometheus_list_metrics since it requires no parameters.const EmptySchema = z.object({});
- src/server/server.ts:58-61 (registration)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));
- src/server/server.ts:74-113 (handler)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), }, ], }; } }, ); }