Prometheus MCP server
The Prometheus MCP Server is a Model Context Protocol server for cloud-native metrics observability, exporter lifecycle management, and TSDB FinOps. It exposes 28 tools, 14 prom:// resources, and 5 guided operational prompts across Prometheus, Thanos, Grafana Mimir, Cortex, and VictoriaMetrics backends.
Execute PromQL with counter-rate enforcement, deploy 19 pre-packaged Kubernetes exporters, test alert rules, and audit TSDB cardinality.
Discover active backends (prom://system/backends), scrape targets, exporter catalogs, and audit logs.
Follow step-by-step runbooks for application metric onboarding, alert rule simulation, and TSDB cardinality reduction.
Configure multi-backend routing, rate-limiting middleware, response size caps, and Kubernetes ServiceMonitor RBAC.
Core capabilities
| Capability Domain | What the Server Provides |
|---|---|
| Safe PromQL Execution | Validates PromQL syntax prior to execution, enforces rate()/increase() wrapping on counters, and downsamples range queries automatically to 100–200 data points per series. |
| Application Onboarding | Recommends instrumentation strategies (client SDK, sidecar exporter, or built-in /metrics), generates Go/Java/Python/Node.js snippets, validates OpenMetrics output, and provisions ServiceMonitor CRDs. |
| Exporter Lifecycle (19 Catalog Entries) | One-command Kubernetes deployment (Deployment/DaemonSet, Service, RBAC) for 19 common infrastructure exporters with live up{} series verification. |
| Alert Rule Testing & Simulation | Drafts Prometheus alerting rules, validates syntax via promtool, runs synthetic unit tests, and backtests rules against historical TSDB data. |
| TSDB FinOps & Cardinality Control | Identifies top-N high-cardinality metric series, generates metric_relabel_configs to drop noisy labels, creates pre-computed recording rules, and configures remote-write pipelines. |
Architecture
Quickstart
Ensure you have network reachability to a Prometheus-compatible HTTP API endpoint (Prometheus, Thanos, Mimir, Cortex, or VictoriaMetrics) and optionally a KUBECONFIG for exporter and ServiceMonitor operations.
Run the Docker container pointing to your Prometheus endpoint:
docker run --rm -it \
-p 8767:8767 \
-e PROMETHEUS_BASE_URL=http://host.docker.internal:9090 \
-e MCP_TRANSPORT=http \
talkopsai/prometheus-mcp-server:latest
Add the server URL to your MCP client configuration:
{
"mcpServers": {
"prometheus": {
"url": "http://localhost:8767/mcp",
"description": "MCP Server for Prometheus observability and monitoring management"
}
}
}
Security and middleware guardrails
- 7-layer middleware protection: Enforces response payload caps (
100 KBmax), token-bucket rate limiting (10 req/s, burst20), response caching, and structured audit logging. - Explicit
backend_idtargeting: In multi-backend deployments, every tool call requires an explicitbackend_idparameter so queries and rule updates never target an unintended environment. - Scoped backend access policies: Configure per-backend read-only or allow/deny policies via governance tools.
Project structure
prometheus-mcp-server/
├── prometheus_mcp_server/
│ ├── tools/ # 28 MCP tools across 10 functional categories
│ ├── resources/ # 14 MCP resources (prom:// URIs)
│ ├── prompts/ # 5 guided workflow prompts
│ ├── services/ # Prometheus HTTP v1 + Kubernetes API services
│ ├── server/ # FastMCP setup + 7-layer middleware stack
│ ├── utils/ # 19-exporter catalog, snippet generator, PromQL parser
│ ├── models/ # Pydantic request/response schemas
│ └── config.py # Multi-backend and environment configuration
├── tests/ # Unit and integration test suites
├── Dockerfile
└── pyproject.toml