Skip to main content
Glama
Jayanth-Kulkarni-Avesha

Prometheus MCP Server

Prometheus MCP Server

A Model Context Protocol (MCP) server for Prometheus.

This provides access to your Prometheus metrics and queries through standardized MCP interfaces, allowing AI assistants to execute PromQL queries and analyze your metrics data across multiple Prometheus tenants.

Features

  • Execute PromQL queries against Prometheus

  • Multi-tenant support - Query multiple Prometheus instances

  • Discover and explore metrics

    • List available metrics

    • Get metadata for specific metrics

    • View instant query results

    • View range query results with different step intervals

  • Authentication support

    • Basic auth from environment variables

    • Bearer token auth from environment variables

  • Docker containerization support

  • Cross-tenant queries

  • Provide interactive tools for AI assistants

The list of tools is configurable, so you can choose which tools you want to make available to the MCP client. This is useful if you don't use certain functionality or if you don't want to take up too much of the context window.

Related MCP server: Prometheus MCP Server

Usage

Single Tenant Configuration (Backward Compatible)

  1. Ensure your Prometheus server is accessible from the environment where you'll run this MCP server.

  2. Configure the environment variables for your Prometheus server, either through a .env file or system environment variables:

# 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

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

Multi-Tenant Configuration

For multiple Prometheus instances or tenants, use the JSON configuration:

# Multi-tenant configuration via JSON
PROMETHEUS_TENANTS='[
  {
    "name": "production",
    "url": "https://prometheus-prod.example.com",
    "username": "prod_user",
    "password": "prod_password",
    "org_id": "org-prod"
  },
  {
    "name": "staging",
    "url": "https://prometheus-staging.example.com",
    "token": "staging_bearer_token"
  },
  {
    "name": "development",
    "url": "http://localhost:9090"
  }
]'

# Optional: Set default tenant (defaults to first tenant if not specified)
PROMETHEUS_DEFAULT_TENANT=production

MCP Client Configuration

  1. Add the server configuration to your client configuration file. For example, for Claude Desktop:

Single Tenant

{
  "mcpServers": {
    "prometheus": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PROMETHEUS_URL",
        "ghcr.io/pab1it0/prometheus-mcp-server:latest"
      ],
      "env": {
        "PROMETHEUS_URL": "<url>"
      }
    }
  }
}

Multi-Tenant

{
  "mcpServers": {
    "prometheus": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PROMETHEUS_TENANTS",
        "-e",
        "PROMETHEUS_DEFAULT_TENANT",
        "ghcr.io/pab1it0/prometheus-mcp-server:latest"
      ],
      "env": {
        "PROMETHEUS_TENANTS": "[{\"name\":\"prod\",\"url\":\"https://prometheus.example.com\",\"token\":\"your_token\"}]",
        "PROMETHEUS_DEFAULT_TENANT": "prod"
      }
    }
  }
}

Available Tools

Tool

Category

Description

list_tenants

Multi-Tenant

List all configured Prometheus tenants

execute_query

Query

Execute a PromQL instant query against Prometheus (with optional tenant)

execute_range_query

Query

Execute a PromQL range query with start time, end time, and step interval (with optional tenant)

execute_query_all_tenants

Multi-Tenant

Execute a query across all configured tenants

list_metrics

Discovery

List all available metrics in Prometheus (with optional tenant)

get_metric_metadata

Discovery

Get metadata for a specific metric (with optional tenant)

get_targets

Discovery

Get information about all scrape targets (with optional tenant)

Multi-Tenant Tool Examples

# List all configured tenants
await list_tenants()

# Query specific tenant
await execute_query("up", tenant="production")

# Query default tenant (if no tenant specified)
await execute_query("up")

# Query all tenants at once
await execute_query_all_tenants("up")

# List metrics from staging environment
await list_metrics(tenant="staging")

Development

Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.

This project uses uv to manage dependencies. Install uv following the instructions for your platform:

curl -LsSf https://astral.sh/uv/install.sh | sh

You can then create a virtual environment and install the dependencies with:

uv venv
source .venv/bin/activate  # On Unix/macOS
.venv\Scripts\activate     # On Windows
uv pip install -e .

Project Structure

The project has been organized with a src directory structure:

prometheus-mcp-server/
├── src/
│   └── prometheus_mcp_server/
│       ├── __init__.py      # Package initialization
│       ├── server.py        # MCP server implementation with multi-tenant support
│       ├── main.py          # Main application logic
├── Dockerfile               # Docker configuration
├── docker-compose.yml       # Docker Compose configuration
├── .dockerignore            # Docker ignore file
├── pyproject.toml           # Project configuration
└── README.md                # This file

Testing

The project includes a comprehensive test suite that ensures functionality and helps prevent regressions.

Run the tests with pytest:

# Install development dependencies
uv pip install -e ".[dev]"

# Run the tests
pytest

# Run with coverage report
pytest --cov=src --cov-report=term-missing

Tests are organized into:

  • Configuration validation tests

  • Server functionality tests

  • Multi-tenant tests

  • Error handling tests

  • Main application tests

When adding new features, please also add corresponding tests.

Configuration Examples

Environment File (.env)

# Single tenant
PROMETHEUS_URL=http://localhost:9090
PROMETHEUS_USERNAME=admin
PROMETHEUS_PASSWORD=secret

# Or multi-tenant
PROMETHEUS_TENANTS='[
  {
    "name": "local",
    "url": "http://localhost:9090",
    "username": "admin",
    "password": "secret"
  },
  {
    "name": "remote",
    "url": "https://prometheus.example.com",
    "token": "bearer_token_here",
    "org_id": "my-org"
  }
]'
PROMETHEUS_DEFAULT_TENANT=local

Docker Compose

version: "3.8"
services:
  prometheus-mcp:
    image: ghcr.io/pab1it0/prometheus-mcp-server:latest
    environment:
      PROMETHEUS_TENANTS: |
        [
          {
            "name": "prod",
            "url": "https://prometheus-prod.example.com",
            "token": "${PROD_TOKEN}"
          },
          {
            "name": "staging", 
            "url": "https://prometheus-staging.example.com",
            "username": "${STAGING_USER}",
            "password": "${STAGING_PASS}"
          }
        ]
      PROMETHEUS_DEFAULT_TENANT: prod

Migration from Single to Multi-Tenant

Existing single-tenant configurations will continue to work without changes. The server automatically creates a tenant named "default" for backward compatibility.

To migrate to multi-tenant:

  1. Keep existing config - Your current PROMETHEUS_URL, PROMETHEUS_USERNAME, etc. will work

  2. Add tenants gradually - Use PROMETHEUS_TENANTS to add new tenants while keeping the old config

  3. Specify tenants in queries - Add the optional tenant parameter to tool calls when needed

License

MIT


Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.

  • Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.

  • The Google GKE MCP server is a managed Model Context Protocol server that provides AI applications with tools to manage Google Kubernetes Engine (GKE) clusters and Kubernetes resources. It exposes a structured, discoverable interface that allows AI agents to interact with GKE and Kubernetes APIs, enabling them to inspect cluster configurations, retrieve Kubernetes resource YAMLs, monitor operations like cluster upgrades, diagnose issues, and optimize costs—all without needing to parse text output or use complex kubectl commands.

  • Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Provides access to Prometheus metrics and queries through standardized Model Context Protocol interfaces, allowing AI assistants to execute PromQL queries and analyze metrics data.
    6
    515
    MIT
  • A
    license
    B
    quality
    F
    maintenance
    A Model Context Protocol server that enables AI assistants to query Prometheus metrics, discover available data, and analyze system performance through natural language interactions.
    5
    85
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to query Prometheus metrics, monitor alerts, and analyze system health through read-only access to your Prometheus server with built-in query safety and optional AI-powered metric analysis.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides access to Prometheus metrics and queries, allowing AI assistants to execute PromQL queries and analyze metrics data through standardized MCP interfaces.
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jayanth-Kulkarni-Avesha/prometheus-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server