普罗米修斯Mcp服务器
概览
什么是 Prometheus MCP 服务器?
Prometheus MCP 服务器是一个模型上下文协议(MCP)服务器,旨在通过标准化接口帮助 AI 助手查询和分析 Prometheus 指标。该服务器充当桥梁,允许 AI 系统与 Prometheus 提供的丰富数据无缝互动,Prometheus 是一种广泛用于云原生环境的强大监控和警报工具包。
Prometheus MCP 服务器的特点
- 标准化接口:该服务器提供一组标准化的 API,使 AI 助手能够轻松访问和操作 Prometheus 指标。
- 实时数据访问:用户可以实时查询指标,从而实现即时洞察和决策。
- 友好的集成:旨在与现有 AI 系统和 Prometheus 设置顺利集成,增强整体功能而无需进行大量更改。
- 开源:作为一个公共存储库,它鼓励社区贡献和改进,促进协作开发环境。
- 可扩展性:该架构支持扩展,适合小型和大型部署。
如何使用 Prometheus MCP 服务器
- 安装:从 GitHub 克隆存储库,并按照文档中提供的安装说明进行操作。
- 配置:通过配置必要的参数来设置服务器,以连接到您的 Prometheus 实例。
- API 访问:利用提供的 API 从您的 AI 助手向 Prometheus MCP 服务器发送查询。
- 数据分析:分析返回的指标,并将其集成到您的 AI 工作流程中,以增强决策能力。
- 社区支持:与社区互动以获得支持、功能请求和对项目的贡献。
常见问题解答
Prometheus MCP 服务器的目的是什么?
Prometheus MCP 服务器的主要目的是使 AI 助手能够通过标准化接口查询和分析 Prometheus 指标,从而增强 AI 在数据驱动环境中的能力。
Prometheus MCP 服务器是开源的吗?
是的,Prometheus MCP 服务器是一个开源项目,允许用户为其开发和改进做出贡献。
我该如何为 Prometheus MCP 服务器贡献?
您可以通过分叉存储库、进行改进并提交拉取请求来贡献。此外,您还可以通过 GitHub 问题页面报告问题或建议功能。
运行 Prometheus MCP 服务器的系统要求是什么?
该服务器需要一个与 Prometheus 实例兼容的环境。具体要求可以在存储库中的文档中找到。
我可以将 Prometheus MCP 服务器与其他监控工具一起使用吗?
虽然它主要设计用于 Prometheus,但该架构允许根据具体用例和要求与其他监控工具进行潜在集成。
详情
Prometheus MCP Server
A Model Context Protocol (MCP) server for Prometheus.
This provides access to your Prometheus metrics and queries through standardized MCP interfaces, allowing AI assistants to execute PromQL queries and analyze your metrics data.
<a href="https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@pab1it0/prometheus-mcp-server/badge" alt="Prometheus Server MCP server" /> </a>Features
-
Execute PromQL queries against Prometheus
-
Discover and explore metrics
- List available metrics
- Get metadata for specific metrics
- View instant query results
- View range query results with different step intervals
-
Authentication support
- Basic auth from environment variables
- Bearer token auth from environment variables
-
Docker containerization support
-
Provide interactive tools for AI assistants
The list of tools is configurable, so you can choose which tools you want to make available to the MCP client. This is useful if you don't use certain functionality or if you don't want to take up too much of the context window.
Usage
-
Ensure your Prometheus server is accessible from the environment where you'll run this MCP server.
-
Configure the environment variables for your Prometheus server, either through a
.env
file or system environment variables:
### 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
### Optional: For multi-tenant setups like Cortex, Mimir or Thanos
ORG_ID=your_organization_id
- Add the server configuration to your client configuration file. For example, for Claude Desktop:
{
"mcpServers": {
"prometheus": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"PROMETHEUS_URL",
"ghcr.io/pab1it0/prometheus-mcp-server:latest"
],
"env": {
"PROMETHEUS_URL": "<url>"
}
}
}
}
Development
Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.
This project uses uv
to manage dependencies. Install uv
following the instructions for your platform:
curl -LsSf https://astral.sh/uv/install.sh | sh
You can then create a virtual environment and install the dependencies with:
uv venv
source .venv/bin/activate # On Unix/macOS
.venv\Scripts\activate # On Windows
uv pip install -e .
Project Structure
The project has been organized with a src
directory structure:
prometheus-mcp-server/
├── src/
│ └── prometheus_mcp_server/
│ ├── __init__.py # Package initialization
│ ├── server.py # MCP server implementation
│ ├── main.py # Main application logic
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── .dockerignore # Docker ignore file
├── pyproject.toml # Project configuration
└── README.md # This file
Testing
The project includes a comprehensive test suite that ensures functionality and helps prevent regressions.
Run the tests with pytest:
### Install development dependencies
uv pip install -e ".[dev]"
### Run the tests
pytest
### Run with coverage report
pytest --cov=src --cov-report=term-missing
Tests are organized into:
- Configuration validation tests
- Server functionality tests
- Error handling tests
- Main application tests
When adding new features, please also add corresponding tests.
Tools
| Tool | Category | Description |
| | | |
| execute_query
| Query | Execute a PromQL instant query against Prometheus |
| execute_range_query
| Query | Execute a PromQL range query with start time, end time, and step interval |
| list_metrics
| Discovery | List all available metrics in Prometheus |
| get_metric_metadata
| Discovery | Get metadata for a specific metric |
| get_targets
| Discovery | Get information about all scrape targets |
License
MIT
Server配置
{
"mcpServers": {
"prometheus-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--pab1it0--prometheus-mcp-server--prometheus-mcp-server",
"prometheus-mcp-server"
],
"env": {
"PROMETHEUS_URL": "prometheus-url",
"PROMETHEUS_USERNAME": "prometheus-username",
"PROMETHEUS_PASSWORD": "prometheus-password"
}
}
}
}