Prometheus MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Enables data retrieval and analysis from Prometheus databases, including fetching specific metrics, performing statistical analysis, searching metric usage patterns, and executing complex PromQL queries for in-depth data exploration.

Prometheus 的 MCP 服务器

一个模型上下文协议 (MCP) 服务器,用于从 Prometheus 数据库检索数据。该 MCP 服务器支持大型语言模型 (LLM) 调用工具函数,这些函数可以通过预定义的路由检索和分析海量指标数据、搜索指标使用情况、执行复杂查询以及执行其他相关任务,并增强对使用情况的控制。

  • 数据检索:从 Prometheus 获取特定指标或数据范围。
  • 指标分析:对检索到的指标执行统计分析。
  • 使用情况搜索:查找并探索指标使用模式。
  • 复杂查询:执行高级 PromQL 查询以进行深入数据探索。

能力

✅ 从 Prometheus 检索全面的指标信息,包括名称和描述

✅ 使用指标名称获取并分析特定指标数据

✅ 分析自定义时间范围内的指标数据

🚧 使用特定标签过滤和匹配数据(正在开发中)

⏳ 计划中的附加功能...

入门

MCP 运行需要一个 python 虚拟环境(venv),所有包都应安装到此 venv 中,以便 MCP 服务器可以自动启动。

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Prometheus MCP 服务器:

npx -y @smithery/cli install @CaesarYangs/prometheus_mcp_server --client claude

手动安装

准备python环境

cd ./src/prometheus_mcp_server python3 -m venv .venv
# linux/macos: source .venv/bin/activate # windows: .venv\Scripts\activate

然后它就可以用作专用的 python 环境了。

安装所需的软件包

确保 pip 已正确安装。如果您的 venv 没有安装 pip,请使用以下命令手动安装:

wget https://bootstrap.pypa.io/get-pip.py python3 get-pip.py

然后安装所有必需的软件包:

pip install -r requirements.txt

用法

使用光标环境

准备更新依赖于更易于使用的Cursor环境。

在“光标设置”的 MCP 部分中进行设置:

uv --directory /path/to/prometheus_mcp_server run server.py

配合MCP客户端(含Claude Desktop)

~/Library/Application Support/Claude/claude_desktop_config.json (macos) 配置您的 Claude Desktop 应用程序的配置

{ "mcpServers": { "prometheus": { "command": "uv", "args": [ "--directory", "/path/to/prometheus_mcp_server", "run", "server.py" ], "env": { "PROMETHEUS_HOST": "http://localhost:9090" } } } }

独立 MCP 服务器

单独启动此 MCP 服务器:

紫外线法

uv --directory /path/to/prometheus_mcp_server run server.py

这也是一种确保此 MCP 服务器可以自动启动的方法,因为 Claude Desktop 使用这种 ux 脚本方式在应用程序启动时启动。

常规 Python 方法

python3 server.py

贡献

欢迎贡献!以下是快速指南:

  1. 复制仓库
  2. 创建你的功能分支( git checkout -b feature/AmazingFeature
  3. 提交您的更改( git commit -m 'Add some AmazingFeature'
  4. 推送到分支( git push origin feature/AmazingFeature
  5. 打开拉取请求

对于重大更改,请先打开一个问题来讨论您想要更改的内容。

感谢您的贡献!

执照

MIT 许可证

参考文献与致谢

该项目受到以下开源项目的启发或使用了以下开源项目的代码:

-
security - not tested
A
license - permissive license
-
quality - not tested

MCP 服务器使大型语言模型能够通过预定义的路由从 Prometheus 数据库检索、分析和查询指标数据。

  1. Capibilites
    1. Getting Started
      1. Installing via Smithery
      2. Manual Installation
    2. Usage
      1. With Cursor Env
      2. With MCP Client(include Claude Desktop)
      3. Standalone MCP Server
    3. Contributing
      1. License
        1. References & Acknowledgments
          ID: nswv189shn