Commit fa67579
Add read-only Prometheus MCP tools (#930)
Expose three read-only MCP tools so an LLM can run PromQL against the
cluster's Prometheus through radar: query_prometheus (instant + range),
discover_metrics (label/metric discovery with metadata enrichment), and
get_prometheus_rules (alerting/recording rules, filtered + flattened).
The tools shape results for LLM consumption in the MCP layer — flatten,
filter, limit, and summarize oversized results into a cardinality
breakdown with a ready-to-run rewrite — while pkg/prom stays a generic,
reusable Prometheus client. Non-finite samples serialize as JSON null
(never a fabricated 0), and the charts split line/area paths across those
gaps instead of bridging them.
The MCP path needs a longer per-query budget than the rest of radar (model
settable up to 180s), so it uses a dedicated http.Client backstop via
Client.PromForMCP(); the shared Prom() client keeps the 10s socket cap that
bounds REST/opencost. REST, opencost, and istio callers are unchanged.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent c4ebc0f commit fa67579
18 files changed
Lines changed: 2473 additions & 49 deletions
File tree
- docs
- internal
- mcp
- prometheus
- packages/k8s-ui/src/components/charts
- pkg/prom
- web/src/components
- home
- resource
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
206 | 209 | | |
207 | 210 | | |
208 | 211 | | |
| |||
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
| 236 | + | |
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
374 | 412 | | |
375 | 413 | | |
376 | 414 | | |
| |||
0 commit comments