prometheus
一个简化版的Prometheus MCP服务器,用于收集和暴露MCP服务器的指标
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:
- Install Go from https://golang.org/d/ and ensure it is in your PATH.
- Clone or download the MCP server repository to your local machine.
- Set required environment variables (examples shown):
- PROMETHEUS_URL=http://localhost:9090
- APP_LOG_FILE=/path/to/logfile.log (optional)
- Run the server (from the project root):
go run cmd/server/main.go sse - 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
trpc-agent-go
trpc-agent-go is a powerful Go framework for building intelligent agent systems using large language models (LLMs) and tools.
station
Station is our open-source runtime that lets teams deploy agents on their own infrastructure with full control.
tiger-cli
Tiger CLI is the command-line interface for Tiger Cloud. It includes an MCP server for helping coding agents write production-level Postgres code.
gopls
MCP server for golang projects development: Expand AI Code Agent ability boundary to have a semantic understanding and determinisic information for golang projects.
kubernetes
A Model Context Protocol (MCP) server for the Kubernetes API.
gcp-cost
💰 An MCP server that enables AI assistants to estimate Google Cloud costs, powered by Cloud Billing Catalog API and built with Genkit for Go