pab1it0_prometheus_mcp_server

pab1it0_prometheus_mcp_server

by pab1it0
An MCP server enabling AI assistants to query and analyze Prometheus metrics through standardized interfaces.

Prometheus MCP Server for AI Assistants

Overview

The Prometheus MCP Server is a specialized implementation of the Model Context Protocol (MCP) that enables AI assistants to query and analyze Prometheus metrics through standardized interfaces. This server provides seamless access to Prometheus data, allowing AI tools like Claude to execute PromQL queries and explore metrics efficiently.

Features

  • Execute PromQL Queries: Run instant and range queries against Prometheus.
  • Metric Discovery:
  • List all available metrics.
  • Retrieve metadata for specific metrics.
  • View instant and range query results with customizable step intervals.
  • Authentication Support:
  • Basic authentication via environment variables.
  • Bearer token authentication via environment variables.
  • Docker Containerization: Easy deployment using Docker.
  • Interactive Tools for AI Assistants: Configurable tools to optimize context window usage.

Configuration

Environment Variables

Configure the server using environment variables:

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

# Optional: Authentication credentials (if needed)
# For basic auth
PROMETHEUS_USERNAME=your_username
PROMETHEUS_PASSWORD=your_password

# For bearer token auth
PROMETHEUS_TOKEN=your_token

Client Configuration (Claude Desktop Example)

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

Docker Usage

Building the Docker Image

docker build -t prometheus-mcp-server .

Running with Docker

Using docker run:

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:

docker-compose up

Docker Configuration for 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"
      }
    }
  }
}

Development

Setup

  1. Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create a virtual environment and install dependencies:
uv venv
source .venv/bin/activate  # On Unix/macOS
.venv\Scripts\activate     # On Windows
uv pip install -e .

Testing

Run the test suite:

uv pip install -e ".[dev]"
pytest
pytest --cov=src --cov-report=term-missing

Project Structure

prometheus-mcp-server/
├── src/
│   └── prometheus_mcp_server/
│       ├── __init__.py
│       ├── server.py
│       ├── main.py
├── Dockerfile
├── docker-compose.yml
├── .dockerignore
├── pyproject.toml
└── README.md

Tools

Tool Category Description
execute_query Query Execute a PromQL instant query
execute_range_query Query Execute a PromQL range query with step intervals
list_metrics Discovery List all available metrics
get_metric_metadata Discovery Get metadata for a specific metric
get_targets Discovery Get information about all scrape targets

License

This project is licensed under the MIT License.

About

The Prometheus MCP Server empowers AI assistants to interact with Prometheus metrics seamlessly, providing a standardized interface for querying and analyzing data.

Features & Capabilities

Categories
mcp_server model_context_protocol prometheus python docker api_integration ai_assistants

Implementation Details

Stats

0 Views
9 GitHub Stars

Repository Info

pab1it0 Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300