n

ntk148v

@ntk148v/alertmanager-mcp-server
0 Stars 305 次浏览 ntk148v 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "alertmanager": {
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "ALERTMANAGER_URL",
        "-e",
        "ALERTMANAGER_USERNAME",
        "-e",
        "ALERTMANAGER_PASSWORD",
        "ghcr.io/ntk148v/alertmanager-mcp-server:latest"
      ],
      "command": "docker",
      "env": {
        "ALERTMANAGER_PASSWORD": "your_password",
        "ALERTMANAGER_URL": "http://your-alertmanager:9093s",
        "ALERTMANAGER_USERNAME": "your_username"
      }
    }
  }
}

可用工具 (9 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

get_status

Get current status of an Alertmanager instance and its cluster

该工具无需必填参数,直接调用即可

get_receivers

Get list of all receivers (name of notification integrations)

该工具无需必填参数,直接调用即可

get_silences 1 个参数 需填 1 项

Get list of all silences

必填参数:kwargs

post_silence 1 个参数 需填 1 项

Post a new silence or update an existing one

必填参数:silence

get_silence 1 个参数 需填 1 项

Get a silence by its ID

必填参数:silence_id

delete_silence 1 个参数 需填 1 项

Delete a silence by its ID

必填参数:silence_id

get_alerts 1 个参数 需填 1 项

Get a list of alerts

必填参数:kwargs

post_alerts 1 个参数 需填 1 项

Create new alerts

必填参数:alerts

get_alert_groups 1 个参数 需填 1 项

Get a list of alert groups

必填参数:kwargs

服务介绍

目录

1. 介绍

Prometheus Alertmanager MCP 是一个用于 Prometheus Alertmanager 的 Model Context Protocol (MCP) 服务器。它使 AI 助手和工具能够以编程方式安全地查询和管理 Alertmanager 资源。

2. 特性

  • 查询 Alertmanager 状态、警报、静默、接收器和警报组
  • 创建、更新和删除静默
  • 创建新的警报
  • 认证支持(通过环境变量进行基本认证)
  • 支持 Docker 容器化

3. 快速开始

3.1. 前提条件

  • Python 3.12+
  • uv(用于快速依赖管理)。
  • Docker(可选,用于容器化部署)。
  • 确保您的 Prometheus Alertmanager 服务器可以从您将要运行此 MCP 服务器的环境中访问。

3.2. 通过 Smithery 安装

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

bash
npx -y @smithery/cli install @ntk148v/alertmanager-mcp-server --client claude

3.3. 本地运行

  • 克隆仓库:

bash

克隆仓库

$ git clone https://github.com/ntk148v/alertmanager-mcp-server.git

  • 为您的 Prometheus 服务器配置环境变量,可以通过 .env 文件或系统环境变量设置:

shell

设置环境变量(参见 .env.sample)

ALERTMANAGER_URL=http://your-alertmanager:9093
ALERTMANAGER_USERNAME=your_username # 可选
ALERTMANAGER_PASSWORD=your_password # 可选

  • 将服务器配置添加到客户端配置文件中。例如,对于 Claude Desktop:

json
{
"mcpServers": {
"alertmanager": {
"command": "uv",
"args": [
"--directory",
"<alertmanager-mcp-server 目录的完整路径>",
"run",
"src/alertmanager_mcp_server/server.py"
],
"env": {
"ALERTMANAGER_URL": "http://your-alertmanager:9093s",
"ALERTMANAGER_USERNAME": "your_username",
"ALERTMANAGER_PASSWORD": "your_password"
}
}
}
}

  • 或者使用 make 命令安装:

shell
$ make install

  • 重启 Claude Desktop 以加载新配置。
  • 您现在可以使用自然语言让 Claude 与 Alertmanager 交互:
    • "显示当前警报"
    • "过滤与 CPU 问题相关的警报"
    • "获取该警报的详细信息"
    • "为此警报创建一个持续两小时的静默"

3.4. Docker 运行

  • 使用预构建镜像运行(或者您可以自己构建):

bash
$ docker run -e ALERTMANAGER_URL=http://your-alertmanager:9093
-e ALERTMANAGER_USERNAME=your_username
-e ALERTMANAGER_PASSWORD=your_password
-p 8000:8000 ghcr.io/ntk148v/alertmanager-mcp-server

  • 在 Claude Desktop 中使用 Docker 运行:

json
{
"mcpServers": {
"alertmanager": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e", "ALERTMANAGER_URL",
"-e", "ALERTMANAGER_USERNAME",
"-e", "ALERTMANAGER_PASSWORD",
"ghcr.io/ntk148v/alertmanager-mcp-server:latest"
],
"env": {
"ALERTMANAGER_URL": "http://your-alertmanager:9093s",
"ALERTMANAGER_USERNAME": "your_username",
"ALERTMANAGER_PASSWORD": "your_password"
}
}
}
}此配置通过仅使用变量名的 -e 标志将 Claude Desktop 的环境变量传递给 Docker 容器,并在 env 对象中提供实际值。

4. 工具

MCP 服务器提供了用于查询和管理 Alertmanager 的工具,遵循 其 API v2

  • 获取状态:get_status()
  • 列出警报:get_alerts()
  • 列出静默:get_silences()
  • 创建静默:post_silence(silence_dict)
  • 删除静默:delete_silence(silence_id)
  • 列出接收器:get_receivers()
  • 列出警报组:get_alert_groups()

有关完整的 API 细节,请参阅 src/alertmanager_mcp_server/server.py

5. 开发

欢迎贡献!如果您有任何建议或改进,请打开一个 issue 或提交一个 pull request。

该项目使用 uv 来管理依赖项。请按照您平台的说明安装 uv。

bash

克隆仓库

$ git clone https://github.com/ntk148v/alertmanager-mcp-server.git
$ cd alertmanager-mcp-server
$ make setup

运行测试

$ make test

在开发模式下运行

$ mcp dev
$ TRANSPORT_MODE=sse mcp dev

在 Claude Desktop 中安装

$ make install

6. 许可证

Apache 2.0


相关 MCP 服务