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
45 stars

The Prometheus MCP Server provides a standardized Model Context Protocol interface for accessing and analyzing your Prometheus metrics data. It allows AI assistants to execute PromQL queries, explore metrics, and analyze your monitoring data through a consistent API.

Installation

Prerequisites

  • A running Prometheus server accessible from the environment where you'll run this MCP server

Environment Configuration

Configure the necessary environment variables for connecting to your Prometheus server:

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

# Optional: Authentication credentials (if needed)
# Choose one of the following authentication methods if required:

# For basic auth
PROMETHEUS_USERNAME=your_username
PROMETHEUS_PASSWORD=your_password

# For bearer token auth
PROMETHEUS_TOKEN=your_token

Docker Installation

The easiest way to run the server is using Docker.

Building the Docker Image

docker build -t prometheus-mcp-server .

Running with Docker

Using docker run directly:

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

Using docker-compose:

  1. Create a .env file with your Prometheus credentials
  2. Run:
docker-compose up

Usage

Configuring with Claude Desktop

To use this MCP server with Claude Desktop, add the configuration to your client configuration file:

Direct Python Execution

{
  "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"
      }
    }
  }
}

If you encounter 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 Docker with Claude Desktop

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

Available Tools

The MCP server provides several tools that AI assistants can use:

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

These tools allow AI assistants to:

  • Run ad-hoc PromQL queries
  • Discover and explore available metrics
  • View instant query results
  • Analyze range query results with different step intervals
  • Access target information and metadata

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