The Prometheus MCP Server provides a standardized Model Context Protocol interface for accessing and analyzing your Prometheus metrics data. It allows AI assistants to execute PromQL queries, explore metrics, and analyze your monitoring data through a consistent API.
Configure the necessary environment variables for connecting to your Prometheus server:
# 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
The easiest way to run the server is using Docker.
docker build -t prometheus-mcp-server .
Using docker run directly:
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
Using docker-compose:
.env
file with your Prometheus credentialsdocker-compose up
To use this MCP server with Claude Desktop, add the configuration to your client 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"
}
}
}
}
If you encounter Error: spawn uv ENOENT
in Claude Desktop, you may need to specify the full path to uv
or set the environment variable NO_UV=1
in the configuration.
{
"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"
}
}
}
}
The MCP server provides several tools that AI assistants can use:
These tools allow AI assistants to:
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.