Prometheus MCP Server
Provides access to Prometheus metrics and queries, allowing AI assistants to execute PromQL queries and analyze metrics data through standardized MCP interfaces.
README
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.
<a href="https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server/badge" alt="Prometheus Server MCP server" /> </a>
Quick Start
š For End Users (PyPI)
# Install and run in one command
uvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server
š ļø For Developers (Local)
# Clone and install in development mode
git clone https://github.com/raihan0824/prometheus-mcp-server.git
cd prometheus-mcp-server
uv pip install -e .
prometheus-mcp-server
Features
-
[x] Execute PromQL queries against Prometheus
-
[x] Discover and explore metrics
- [x] List available metrics
- [x] Get metadata for specific metrics
- [x] View instant query results
- [x] View range query results with different step intervals
-
[x] Authentication support
- [x] Basic auth from environment variables
- [x] Bearer token auth from environment variables
-
[x] Docker containerization support
-
[x] 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.
Installation
Option 1: Install from PyPI (Recommended for Users)
# Using uvx (recommended for Claude Desktop)
uvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server
# Using pip
pip install raihan0824-prometheus-mcp-server
# Using uv
uv add raihan0824-prometheus-mcp-server
Option 2: Install from Source (For Development)
# Clone the repository
git clone https://github.com/raihan0824/prometheus-mcp-server.git
cd prometheus-mcp-server
# Install with uv (development mode)
uv pip install -e .
# Or install with pip (development mode)
pip install -e .
Usage
For End Users (Using PyPI Package)
If you want to use the pre-built package from PyPI:
# Install and run in one command
uvx --from raihan0824-prometheus-mcp-server prometheus-mcp-server
# Or install permanently
pip install raihan0824-prometheus-mcp-server
prometheus-mcp-server
For Developers (Local Development)
If you want to modify the code or contribute:
# Clone and install in development mode
git clone https://github.com/raihan0824/prometheus-mcp-server.git
cd prometheus-mcp-server
uv pip install -e .
# Run the development version
prometheus-mcp-server
-
Ensure your Prometheus server is accessible from the environment where you'll run this MCP server.
-
Configure the environment variables for your Prometheus server, either through a
.envfile 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: Custom MCP configuration
PROMETHEUS_MCP_SERVER_TRANSPORT=stdio # Choose between http, stdio, sse. If undefined, stdio is set as the default transport.
# Optional: Only relevant for non-stdio transports
PROMETHEUS_MCP_BIND_HOST=localhost # if undefined, 127.0.0.1 is set by default.
PROMETHEUS_MCP_BIND_PORT=8080 # if undefined, 8080 is set by default.
# Optional: For multi-tenant setups like Cortex, Mimir or Thanos
ORG_ID=your_organization_id
- Add the server configuration to your client configuration file. For example, for Claude Desktop:
Option A: Using uvx with PyPI package (Recommended for Users)
{
"mcpServers": {
"prometheus": {
"command": "uvx",
"args": [
"--from",
"raihan0824-prometheus-mcp-server",
"prometheus-mcp-server"
],
"env": {
"PROMETHEUS_URL": "<your-prometheus-url>",
"PROMETHEUS_USERNAME": "<your-username>",
"PROMETHEUS_PASSWORD": "<your-password>"
}
}
}
}
Option B: Using uvx with local repository
{
"mcpServers": {
"prometheus": {
"command": "uvx",
"args": [
"--directory",
"/path/to/prometheus-mcp-server",
"run",
"prometheus-mcp-server"
],
"env": {
"PROMETHEUS_URL": "<your-prometheus-url>",
"PROMETHEUS_USERNAME": "<your-username>",
"PROMETHEUS_PASSWORD": "<your-password>"
}
}
}
}
Option C: Using uvx with Git repository
{
"mcpServers": {
"prometheus": {
"command": "uvx",
"args": [
"run",
"--from",
"git+https://github.com/raihan0824/prometheus-mcp-server.git",
"prometheus-mcp-server"
],
"env": {
"PROMETHEUS_URL": "<your-prometheus-url>",
"PROMETHEUS_USERNAME": "<your-username>",
"PROMETHEUS_PASSWORD": "<your-password>"
}
}
}
}
Option D: Using Docker (Legacy)
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"PROMETHEUS_URL",
"ghcr.io/pab1it0/prometheus-mcp-server:latest"
],
"env": {
"PROMETHEUS_URL": "<url>",
"PROMETHEUS_MCP_SERVER_TRANSPORT": "http",
"PROMETHEUS_MCP_BIND_HOST": "localhost",
"PROMETHEUS_MCP_BIND_PORT": "8080"
}
}
}
}
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
ā āāā 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
- Error handling tests
- Main application tests
When adding new features, please also add corresponding tests.
Tools
| 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 |
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.