- Explore MCP Servers
- prometheus-mcp-server
Prometheus Mcp Server
What is Prometheus Mcp Server
The prometheus-mcp-server is a simplified version of the Prometheus MCP server designed for collecting and exposing metrics for AI analysis.
Use cases
Use cases include monitoring application performance, analyzing system resource usage, generating visualizations for metrics over time, and facilitating AI model training with relevant metrics.
How to use
To use prometheus-mcp-server, set the Prometheus endpoint environment variable with ‘export PROMETHEUS_URL=your_Prometheus_endpoint’, then start the server using ‘go run cmd/server/main.go sse’. Access the server at ‘http://localhost:8081/sse’. Optionally, set a log file path with ‘export APP_LOG_FILE=/path/to/logfile.log’.
Key features
Key features include JSON output for all queries, AI-friendly metric analysis, and various MCP tools such as searching metrics by regex, retrieving metric labels and values, executing PromQL queries, and generating charts from query results.
Where to use
prometheus-mcp-server can be used in fields that require monitoring and analyzing metrics, particularly in AI and machine learning applications where data insights are crucial.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Prometheus Mcp Server
The prometheus-mcp-server is a simplified version of the Prometheus MCP server designed for collecting and exposing metrics for AI analysis.
Use cases
Use cases include monitoring application performance, analyzing system resource usage, generating visualizations for metrics over time, and facilitating AI model training with relevant metrics.
How to use
To use prometheus-mcp-server, set the Prometheus endpoint environment variable with ‘export PROMETHEUS_URL=your_Prometheus_endpoint’, then start the server using ‘go run cmd/server/main.go sse’. Access the server at ‘http://localhost:8081/sse’. Optionally, set a log file path with ‘export APP_LOG_FILE=/path/to/logfile.log’.
Key features
Key features include JSON output for all queries, AI-friendly metric analysis, and various MCP tools such as searching metrics by regex, retrieving metric labels and values, executing PromQL queries, and generating charts from query results.
Where to use
prometheus-mcp-server can be used in fields that require monitoring and analyzing metrics, particularly in AI and machine learning applications where data insights are crucial.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Prometheus MCP 服务器
这是一个简化版的Prometheus MCP服务器,用于查询指标提供 ai 分析。
快速开始
启动
- 设置Prometheus地址环境变量:
export PROMETHEUS_URL=your_Prometheus_endpoint
- 启动服务器:
go run cmd/server/main.go sse
服务器将在:8081端口启动,可以通过以下URL访问:
- (可选) 设置日志文件路径:
export APP_LOG_FILE=/path/to/logfile.log
测试
npx @modelcontextprotocol/inspector node build/index.js
功能特性
AI友好化分析指标
- JSON格式输出:所有查询结果均以JSON格式返回,便于AI系统解析处理
MCP工具
-
search_metrics - 按正则表达式搜索指标
- 参数:
pattern(指标名称模式,支持正则表达式) - 示例:
http_.*匹配所有以http_开头的指标 - 返回: 匹配的指标名称列表(JSON格式)
- 参数:
-
get_metric_labels - 获取指标的所有标签
- 参数:
name(指标名称) - 示例:
http_requests_total - 返回: 该指标的所有标签列表(JSON格式,不包括
__name__标签)
- 参数:
-
get_metric_label_values - 获取指标标签的所有值
- 参数:
name(指标名称)label(标签名称)
- 示例: 获取
http_requests_total指标的method标签的所有值 - 返回: 指定标签的所有值列表(JSON格式)
- 参数:
-
query - 执行PromQL即时查询
- 参数:
query(PromQL查询语句)time(查询时间戳,格式为RFC3339或Unix时间戳,可选)
- 示例: 查询当前CPU使用率
- 返回: 查询结果(JSON格式)
- 参数:
-
query_range - 执行PromQL范围查询
- 参数:
query(PromQL查询语句)start(开始时间,格式为RFC3339或Unix时间戳(毫秒))end(结束时间,格式为RFC3339或Unix时间戳(毫秒))step(查询步长,例如’15s’、‘1m’)
- 示例: 查询过去1小时CPU使用率变化,每15秒一个数据点
- 返回: 范围查询结果(JSON格式)
- 参数:
-
query_chart - 执行PromQL范围查询并生成图表
- 参数:
query(PromQL查询语句)start(开始时间,格式为RFC3339或Unix时间戳(毫秒))end(结束时间,格式为RFC3339或Unix时间戳(毫秒))step(查询步长,例如’15s’、‘1m’)title(图表标题,可选)
- 示例: 查询过去1小时CPU使用率变化并生成图表
- 返回: 图表图片(base64编码的PNG格式)
- 参数:
服务器端
- 设置Prometheus地址:
export PROMETHEUS_URL=your_Prometheus_endpoint
- 启动服务器:
go run cmd/server/main.go sse
服务器默认将在:8081端口暴露Prometheus指标。
mcp 客户端配置
配置示例:
{
"mcpServers": {
"products-sse": {
"url": "http://localhost:8081/sse"
}
}
}
项目结构
. ├── cmd/ # 命令行程序入口 │ └── server/ # 服务器代码 ├── internal/ # 内部实现 ├── pkg/ # 可复用包 │ └── prometheus # Prometheus相关实现 └── go.mod # Go模块定义
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










