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.
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
{
"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 build -t prometheus-mcp-server .
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
docker-compose
:docker-compose up
{
"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"
}
}
}
}
uv
:curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate # On Unix/macOS
.venv\Scripts\activate # On Windows
uv pip install -e .
Run the test suite:
uv pip install -e ".[dev]"
pytest
pytest --cov=src --cov-report=term-missing
prometheus-mcp-server/
├── src/
│ └── prometheus_mcp_server/
│ ├── __init__.py
│ ├── server.py
│ ├── main.py
├── Dockerfile
├── docker-compose.yml
├── .dockerignore
├── pyproject.toml
└── README.md
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 |
This project is licensed under the MIT License.
The Prometheus MCP Server empowers AI assistants to interact with Prometheus metrics seamlessly, providing a standardized interface for querying and analyzing data.