drewstreib/prometheus-mcp-server
If you are the rightful owner of prometheus-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server for Prometheus, providing standardized access to Prometheus metrics and queries.
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.
Features
- Execute PromQL queries against Prometheus
- Discover and explore metrics
- List available metrics
- Get metadata for specific metrics
- Get documentation - Primary discovery endpoint with query patterns
- 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
- Provide interactive tools for AI assistants
Recommended for AI/LLM Usage
When using this MCP server with AI assistants like Claude, start with the get_documentation
tool. This is the primary discovery endpoint that provides:
- Complete PromQL reference and usage patterns
- System monitoring queries and examples
- Specialized monitoring guides for specific contexts
For specialized monitoring contexts:
- Power/Energy/Lab/UPS/Battery questions: Use
get_documentation("victron")
for Victron MultiPlus power system monitoring - Temperature/HVAC/Climate/Weather questions: Use
get_documentation("weather")
for Ecobee thermostat and environmental sensor monitoring
Example prompts for Claude:
Use get_documentation to show me what kinds of queries I can make with Prometheus
Use get_documentation("victron") to learn about power monitoring
Use get_documentation("weather") to learn about temperature and HVAC monitoring
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.
Usage
-
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
.env
file or system environment variables:
# Required: Prometheus configuration
PROMETHEUS_URL=http://your-prometheus-server:9090
# Optional: MCP Server configuration (defaults shown)
FASTMCP_HOST=0.0.0.0
FASTMCP_PORT=8080
# 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
- Add the server configuration to your client configuration file. For example, for Claude Desktop:
{
"mcpServers": {
"prometheus": {
"url": "http://localhost:8080"
}
}
}
Or if running the server manually, you can also use the command-based approach:
{
"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",
"FASTMCP_PORT": "8080"
}
}
}
}
Using with Claude Desktop
Important: Claude Desktop only supports stdio transport natively, but this server runs with HTTP transport. To bridge this gap, you can use the mcp-remote
package which acts as a proxy between Claude Desktop and HTTP MCP servers.
Option 1: Using mcp-remote Bridge (Recommended)
- First, start your Prometheus MCP server (either locally or via Docker):
# Using local installation
FASTMCP_HOST=0.0.0.0 FASTMCP_PORT=8080 PROMETHEUS_URL=http://your-prometheus-server:9090 uv run src/prometheus_mcp_server/main.py
# Or using Docker
docker run -d --name prometheus-mcp \
-p 8080:8080 \
-e PROMETHEUS_URL=http://your-prometheus-server:9090 \
-e PROMETHEUS_USERNAME=your_username \
-e PROMETHEUS_PASSWORD=your_password \
prometheus-mcp-server
- Configure Claude Desktop to use the
mcp-remote
bridge by editing your Claude Desktop configuration file at~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"prometheus": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8080"
]
}
}
}
Option 2: Direct Remote MCP (Claude Pro/Team/Enterprise only)
If you have Claude Pro, Team, or Enterprise, you can use the built-in remote MCP support:
- Deploy your Prometheus MCP server to a publicly accessible endpoint
- In Claude Desktop, go to Settings > Integrations
- Add your remote MCP server URL (e.g.,
https://your-server.com:8080
)
Troubleshooting Claude Desktop Integration
- mcp-remote not found: Install it globally with
npm install -g mcp-remote
- Connection issues: Ensure your Prometheus MCP server is running and accessible on the specified port
- Authentication errors: Verify your Prometheus credentials are correct and the Prometheus server is reachable
Docker Usage
This project includes Docker support for easy deployment and isolation.
Using Docker Images
You can use pre-built Docker images or build your own locally.
Building the Docker Image Locally
If you prefer to build the image yourself:
docker build -t prometheus-mcp-server .
Running with Docker
You can run the server using Docker in several ways:
Using docker run:
docker run -d --name prometheus-mcp \
-p 8080:8080 \
-e PROMETHEUS_URL=http://your-prometheus-server:9090 \
-e PROMETHEUS_USERNAME=your_username \
-e PROMETHEUS_PASSWORD=your_password \
prometheus-mcp-server
Using docker-compose:
Create a docker-compose.yml
file:
version: '3.8'
services:
prometheus-mcp:
image: prometheus-mcp-server
ports:
- "8080:8080"
environment:
- PROMETHEUS_URL=http://your-prometheus-server:9090
- PROMETHEUS_USERNAME=your_username
- PROMETHEUS_PASSWORD=your_password
restart: unless-stopped
Then run:
docker-compose up -d
Running with Docker in Claude Desktop
To use the containerized server with Claude Desktop, first start the container:
docker run -d --name prometheus-mcp \
-p 8080:8080 \
-e PROMETHEUS_URL=http://your-prometheus-server:9090 \
-e PROMETHEUS_USERNAME=your_username \
-e PROMETHEUS_PASSWORD=your_password \
prometheus-mcp-server
Then configure Claude Desktop to use the HTTP endpoint:
{
"mcpServers": {
"prometheus": {
"url": "http://localhost:8080"
}
}
}
Attribution
This project is based on the original work by Pavel Shklovsky (pab1it0). See for full attribution details.
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
ā āāā metrics.json # Metrics documentation database
āāā docs-mcp/ # Machine-readable documentation
ā āāā usage.md # Complete usage guide and PromQL reference
ā āāā victron.md # Victron power system monitoring guide
ā āāā weather.md # Environmental sensors and HVAC monitoring
āāā docs-for-humans/ # Human-readable documentation
āāā tests/ # Test suite
āāā Dockerfile # Docker configuration
āāā 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 |
---|---|---|
get_documentation | Discovery | Primary discovery endpoint - start here for query examples and patterns |
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_series | Discovery | Find time series matching label selectors within a time range |
get_targets | Discovery | Get information about all scrape targets |
License
MIT