Prometheus MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
About
This is an MCP server to allow LLMs to interact with a running Prometheus instance via the API to do things like generate and execute promql queries, list and analyze metrics, etc.
Demos and Examples
Asking Claude to Investigate Slow Queries
The prompt used was:
> querying my metrics is slow, can you help me figure out why?
Investigate metrics produced by the MCP server itself and suggest recording rules for SLOs
The prompt used was:
> use the tools from the prometheus mcp server to investigate the metrics from
> the mcp server and suggest prometheus recording rules for SLOs
Summarize Prometheus metric/label naming best practices
The prompt used was:
> summarize prometheus metric/label name best practices
Report on the health of the Prometheus instance that powers prometheus.demo.prometheus.io
The prompt used was:
> please provide a comprehensive review and summary of the prometheus server.
> review it's configuration, flags, runtime/build info, and anything else that
> you feel may provide insight into the status of the prometheus instance,
> including analyzing metrics and executing queries
Tools
The Prometheus HTTP API outputs JSON data, and the tools in this MCP server return that JSON to the LLM for processing as it's structured and well understood by LLMs.
LLMs and Token/Context Efficiency
This MCP server supports the following options which have the potential to reduce token/context usage:
TOON Encoding
If token/context usage is a concern, this MCP server also supports converting the API's JSON data to the Token-Oriented Object Notation (TOON) format.
While it is not guaranteed to reduce token usage, it is designed with token efficiency in mind.
As noted on TOON's documentation, it excels at uniform arrays of objects; non-uniform/complex objects may still be more token-efficient in JSON.
Real world token usage will depend on usage patterns, please review common workflows to determine if TOON output may be beneficial.
Please see Flags for more information on the available flags and their corresponding environment variables.
API Response Truncation
This feature allows you to set a maximum limit on the number of lines or entries returned from the Prometheus API for, which can help in reducing the amount of data sent to the LLM.
Setting the limit to 0 disables truncation.
Truncation is disabled by default.
Note that LLMs capable of handling tool request arguments can override this global truncation limit on a per-tool-call basis for supported tools.
Please see Flags for more information on the available flags and their corresponding environment variables.
Full Tool List
| Tool Name | Description |
| --- | --- |
| alertmanagers | Get overview of Prometheus Alertmanager discovery |
| build_info | Get Prometheus build information |
| config | Get Prometheus configuration |
| docs_list | List of Official Prometheus Documentation Files |
| docs_read | Read the named markdown file containing official Prometheus documentation from the prometheus/docs repo |
| docs_search | Search the markdown files containing official Prometheus documentation from the prometheus/docs repo |
| exemplar_query | Performs a query for exemplars by the given query and time range |
| flags | Get runtime flags |
| healthy | Management API endpoint that can be used to check Prometheus health |
| label_names | Returns the unique label names present in the block in sorted order by given time range and matchers |
| label_values | Performs a query for the values of the given label, time range and matchers |
| list_alerts | List all active alerts |
| list_rules | List all alerting and recording rules that are loaded |
| list_targets | Get overview of Prometheus target discovery |
| metric_metadata | Returns metadata about metrics currently scraped by the metric name |
| query | Execute an instant query against the Prometheus datasource, returning one value per series at a single point in time |
| quit | Management API endpoint that can be used to trigger a graceful shutdown of Prometheus |
| range_query | Execute a range query against the Prometheus datasource, returning values over a time window |
| ready | Management API endpoint that can be used to check Prometheus is ready to serve traffic (i.e. respond to queries |
| reload | Management API endpoint that can be used to trigger a reload of the Prometheus configuration and rule files |
| runbooks_list | List the runbooks embedded in this server: guided workflows (Agent Skills) for common Prometheus tasks |