Prometheus MCP server

Connects AI systems to Prometheus monitoring infrastructure for executing PromQL queries, discovering metrics, and retrieving target metadata to enable real-time operational analytics and performance monitoring.
Back to servers
Provider
pab1it0
Release date
Mar 20, 2025
Language
Python
Stats
97 stars

The Prometheus MCP Server provides standardized Model Context Protocol (MCP) interfaces to access Prometheus metrics and queries, allowing AI assistants to execute PromQL queries and analyze your metrics data through a consistent API.

Features

  • Execute PromQL queries against Prometheus
  • Discover and explore metrics (list available metrics, get metadata, view query results)
  • Authentication support (basic auth and bearer token)
  • Docker containerization support
  • Interactive tools for AI assistants

Installation

Environment Setup

Before running the server, configure your environment variables:

# Required: Prometheus configuration
PROMETHEUS_URL=http://your-prometheus-server:9090

# Optional: Authentication credentials (if needed)
# Choose one authentication method if required:

# For basic auth
PROMETHEUS_USERNAME=your_username
PROMETHEUS_PASSWORD=your_password

# For bearer token auth
PROMETHEUS_TOKEN=your_token

# Optional: For multi-tenant setups like Cortex, Mimir or Thanos
ORG_ID=your_organization_id

Using Docker (Recommended)

With Pre-built Docker Image

docker pull ghcr.io/pab1it0/prometheus-mcp-server:latest

Run the server:

docker run -it --rm \
  -e PROMETHEUS_URL=http://your-prometheus-server:9090 \
  -e PROMETHEUS_USERNAME=your_username \
  -e PROMETHEUS_PASSWORD=your_password \
  ghcr.io/pab1it0/prometheus-mcp-server:latest

With Docker Compose

Create a .env file with your Prometheus credentials and run:

docker-compose up

Building the Docker Image Locally

docker build -t prometheus-mcp-server .
docker run -it --rm \
  -e PROMETHEUS_URL=http://your-prometheus-server:9090 \
  -e PROMETHEUS_USERNAME=your_username \
  -e PROMETHEUS_PASSWORD=your_password \
  prometheus-mcp-server

Usage

Client Configuration

Claude Desktop Configuration

Add the server to your Claude Desktop configuration file:

{
  "mcpServers": {
    "prometheus": {
      "command": "uv",
      "args": [
        "--directory",
        "<full path to prometheus-mcp-server directory>",
        "run",
        "src/prometheus_mcp_server/main.py"
      ],
      "env": {
        "PROMETHEUS_URL": "http://your-prometheus-server:9090",
        "PROMETHEUS_USERNAME": "your_username",
        "PROMETHEUS_PASSWORD": "your_password"
      }
    }
  }
}

Note: If you see Error: spawn uv ENOENT in Claude Desktop, you may need to specify the full path to uv or set the environment variable NO_UV=1 in the configuration.

Using with Docker in Claude Desktop

{
  "mcpServers": {
    "prometheus": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e", "PROMETHEUS_URL",
        "-e", "PROMETHEUS_USERNAME",
        "-e", "PROMETHEUS_PASSWORD",
        "ghcr.io/pab1it0/prometheus-mcp-server:latest"
      ],
      "env": {
        "PROMETHEUS_URL": "http://your-prometheus-server:9090",
        "PROMETHEUS_USERNAME": "your_username",
        "PROMETHEUS_PASSWORD": "your_password"
      }
    }
  }
}

Available Tools

The server provides several tools for interacting with Prometheus:

Tool Category Description
execute_query Query Execute a PromQL instant query against Prometheus
execute_range_query Query Execute a PromQL range query with start time, end time, and step interval
list_metrics Discovery List all available metrics in Prometheus
get_metric_metadata Discovery Get metadata for a specific metric
get_targets Discovery Get information about all scrape targets

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later