Get the FREE Ultimate OpenClaw Setup Guide →

prometheus

一个简化版的Prometheus MCP服务器,用于收集和暴露MCP服务器的指标

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio qingshanyuluo-prometheus-mcp-server go run cmd/server/main.go sse \
  --env APP_LOG_FILE="/path/to/logfile.log" \
  --env PROMETHEUS_URL="Prometheus endpoint (e.g., http://localhost:9090)"

How to use

This MCP server is a lightweight Go-based Prometheus analyzer that exposes an MCP-friendly interface for querying and analyzing Prometheus metrics. It accepts a Prometheus endpoint via the PROMETHEUS_URL environment variable and serves a SSE endpoint at port 8081. Through the MCP client you can perform structured metric operations such as searching for metrics by pattern, inspecting metric labels and label values, and executing both instantaneous and range PromQL queries. The integrated tools are designed to return JSON results, facilitating AI-assisted analysis and downstream processing.

Available tools include: search_metrics (find metrics by regex pattern), get_metric_labels (list all non-name labels for a metric), get_metric_label_values (list values for a specific label), query (instant PromQL query with optional time), query_range (range PromQL query with start, end, and step), and query_chart (range query with a chart image returned as a base64-encoded PNG). Examples are provided in the README and can be invoked from your MCP client to build AI-friendly responses or dashboards.

How to install

Prerequisites:

  • Go 1.20+ (or compatible Go toolchain)
  • Access to a Prometheus endpoint (the server will query this endpoint)

Installation steps:

  1. Install Go from https://golang.org/d/ and ensure it is in your PATH.
  2. Clone or download the MCP server repository to your local machine.
  3. Set required environment variables (examples shown):
  4. Run the server (from the project root):
    go run cmd/server/main.go sse
    
  5. The server will start on port 8081 by default. You can access the SSE endpoint at http://localhost:8081/sse.

Optional build step (for production):

go build -o prometheus-mcp-server ./cmd/server
./prometheus-mcp-server sse

Additional notes

Tips and notes:

  • The server expects PROMETHEUS_URL to be set to your Prometheus instance. Without it, metric queries will fail.
  • The log file path (APP_LOG_FILE) is optional but can help with debugging by writing logs to a file.
  • The server exposes its MCP interface via a single server named 'prometheus' (mcpServers.prometheus). You can adapt the client configuration accordingly.
  • If you run into port conflicts or need to expose the server differently, you can modify the server configuration or port binding as needed.
  • For testing, you can use the provided MCP client commands (e.g., search_metrics, get_metric_labels, query, query_range, query_chart) to validate responses before integrating into higher-level tooling.

Related MCP Servers

Sponsor this space

Reach thousands of developers