The Prometheus MCP Server provides standardized Model Context Protocol (MCP) interfaces to access Prometheus metrics and queries, allowing AI assistants to execute PromQL queries and analyze your metrics data through a consistent API.
Before running the server, configure your environment variables:
# Required: Prometheus configuration
PROMETHEUS_URL=http://your-prometheus-server:9090
# Optional: Authentication credentials (if needed)
# Choose one authentication method 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
docker pull ghcr.io/pab1it0/prometheus-mcp-server:latest
Run the server:
docker run -it --rm \
-e PROMETHEUS_URL=http://your-prometheus-server:9090 \
-e PROMETHEUS_USERNAME=your_username \
-e PROMETHEUS_PASSWORD=your_password \
ghcr.io/pab1it0/prometheus-mcp-server:latest
Create a .env
file with your Prometheus credentials and run:
docker-compose up
docker build -t prometheus-mcp-server .
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
Add the server to your Claude Desktop configuration file:
{
"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"
}
}
}
}
Note: If you see
Error: spawn uv ENOENT
in Claude Desktop, you may need to specify the full path touv
or set the environment variableNO_UV=1
in the configuration.
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "PROMETHEUS_URL",
"-e", "PROMETHEUS_USERNAME",
"-e", "PROMETHEUS_PASSWORD",
"ghcr.io/pab1it0/prometheus-mcp-server:latest"
],
"env": {
"PROMETHEUS_URL": "http://your-prometheus-server:9090",
"PROMETHEUS_USERNAME": "your_username",
"PROMETHEUS_PASSWORD": "your_password"
}
}
}
}
The server provides several tools for interacting with Prometheus:
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 |
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.