home / mcp / prometheus mcp server
Provides an MCP server that lets AI assistants query Prometheus metrics via standard MCP endpoints.
Configuration
View docs{
"mcpServers": {
"cgoolsby-prometheus-mcp": {
"command": "./prometheus-mcp",
"args": [],
"env": {
"PROMETHEUS_HOST": "http://your-prometheus-instance:9090"
}
}
}
}You run an MCP server that bridges Prometheus data to AI assistants. It lets you execute PromQL queries, discover metrics, view targets and alerts, and retrieve Prometheus metadata through standardized MCP endpoints, enabling powerful querying and analysis by your AI tools.
Start the MCP server locally and point your MCP client at it. The server exposes a set of endpoints that let you run instant and range PromQL queries, discover metric series by label matchers, explore label values and names, fetch metric metadata, check scrape targets, view alerts and rules, and obtain status information from Prometheus.
To run with an AI assistant, configure the MCP client to connect to the local server as a stdio source. The client will spawn the server process and communicate with it over the configured stdio channels. Ensure your Prometheus instance is reachable at the address you provide in the environment variable. Common workflows include querying for current metric values, retrieving series matching label constraints, and inspecting alerting state. The server handles the MCP function calls behind the scenes and returns results suitable for the assistant to present or analyze.
Prerequisites you must have installed before building and running the MCP server:
Build from source and run the server with the standard commands:
# Clone the repository
git clone https://github.com/cgoolsby/prometheus-mcp.git
cd prometheus-mcp
# Build the project
go build -o prometheus-mcp ./cmd/server
# Run the server
./prometheus-mcpConfigure the server to point at your Prometheus instance using the PROMETHEUS_HOST environment variable. The default Prometheus base URL is http://localhost:9090, but you can override it by setting PROMETHEUS_HOST before starting the server.
Example environment setup to run the server locally with a specific Prometheus URL:
export PROMETHEUS_HOST=http://your-prometheus-instance:9090
./prometheus-mcpWhen using an AI assistant, you typically configure the MCP client to start the server as a subprocess and communicate via stdio. The client passes MCP-compatible function calls to the server and receives structured results that you can present to the user or use in analyses.
The server exposes a range of functions to access Prometheus data and configuration, including queries, target information, metadata, and status. Ensure the PROMETHEUS_HOST value is accurate and accessible from the environment running the MCP server.
If the server fails to start, verify that you have Go 1.20+ installed, that the build completed successfully, and that PROMETHEUS_HOST points to a reachable Prometheus instance. Check that the Prometheus API is accessible from the host running the MCP server.
Execute an instant PromQL query and return the result at a single timestamp.
Execute a PromQL range query over a specified time window and step, returning a series of samples.
Find metric series that match given label matchers, enabling targeted exploration of metrics.
Retrieve all values for a specific label name across matching series.
Fetch metadata for metrics, including help text and type information.
Get information about current scrape targets and their statuses.
Obtain information about active and recent alerts configured in Prometheus.
Get information about recording and alerting rules defined in Prometheus.
Retrieve status information about the Prometheus server and its health.