home / mcp / prometheus mcp server

Prometheus MCP Server

Provides an MCP server that lets AI assistants query Prometheus metrics via standard MCP endpoints.

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

Prerequisites you must have installed before building and running the MCP server:

  • Go 1.20 or higher
  • A running Prometheus instance

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-mcp

Configuration and usage notes

Configure 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-mcp

Examples of how to connect from an MCP client

When 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.

Other notes

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.

Troubleshooting tips

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.

Available tools

mcp__instant_query

Execute an instant PromQL query and return the result at a single timestamp.

mcp__range_query

Execute a PromQL range query over a specified time window and step, returning a series of samples.

mcp__get_series

Find metric series that match given label matchers, enabling targeted exploration of metrics.

mcp__get_label_values

Retrieve all values for a specific label name across matching series.

mcp__get_metadata

Fetch metadata for metrics, including help text and type information.

mcp__get_targets

Get information about current scrape targets and their statuses.

mcp__get_alerts

Obtain information about active and recent alerts configured in Prometheus.

mcp__get_rules

Get information about recording and alerting rules defined in Prometheus.

mcp__get_status

Retrieve status information about the Prometheus server and its health.