Skip to main content
Glama
idanfishman

prometheus-mcp

by idanfishman

prometheus_build_info

Retrieve Prometheus server build information to verify version and configuration details for monitoring infrastructure integration.

Instructions

Get Prometheus build information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'prometheus_build_info' tool, defining its metadata, empty input schema, and handler that delegates to PrometheusClient.getBuildInfo()
    defineTool<typeof EmptySchema, BuildInfo>({
      capability: "info",
      name: "prometheus_build_info",
      title: "Get Build Info",
      description: "Get Prometheus build information",
      inputSchema: EmptySchema,
      type: "readonly",
      handle: async (client: PrometheusClient) => client.getBuildInfo(),
    }),
  • Core handler logic for fetching Prometheus build information via HTTP GET to the /api/v1/status/buildinfo API endpoint using the generic request method
    async getBuildInfo(): Promise<BuildInfo> {
      const endpoint = "/api/v1/status/buildinfo";
      return this.request<BuildInfo>(endpoint);
    }
  • Zod input schema (empty object) used by the prometheus_build_info tool
    const EmptySchema = z.object({});
  • Generic private request method used by getBuildInfo() and all other PrometheusClient methods to perform HTTP requests to the Prometheus API with proper 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