Labsco
ntk148v logo

Alertmanager

โ˜… 23

from ntk148v

A Model Context Protocol (MCP) server that enables AI assistants to integrate with Prometheus Alertmanager

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

Prometheus Alertmanager MCP

Table of Contents

1. Introduction

Prometheus Alertmanager MCP is a Model Context Protocol (MCP) server for Prometheus Alertmanager. It enables AI assistants and tools to query and manage Alertmanager resources programmatically and securely.

2. Features

  • Query Alertmanager status, alerts, silences, receivers, and alert groups
  • Smart pagination support to prevent LLM context window overflow when handling large numbers of alerts
  • Create, update, and delete silences
  • Create new alerts
  • Authentication support (Basic auth via environment variables)
  • Multi-tenant support (via X-Scope-OrgId header for Mimir/Cortex)
  • Docker containerization support

4. Tools

The MCP server exposes tools for querying and managing Alertmanager, following its API v2:

  • Get status: get_status()
  • List alerts: get_alerts(filter, silenced, inhibited, active, count, offset)
    • Pagination support: Returns paginated results to avoid overwhelming LLM context
    • count: Number of alerts per page (default: 10, max: 25)
    • offset: Number of alerts to skip (default: 0)
    • Returns: { "data": [...], "pagination": { "total": N, "offset": M, "count": K, "has_more": bool } }
  • List silences: get_silences(filter, count, offset)
    • Pagination support: Returns paginated results to avoid overwhelming LLM context
    • count: Number of silences per page (default: 10, max: 50)
    • offset: Number of silences to skip (default: 0)
    • Returns: { "data": [...], "pagination": { "total": N, "offset": M, "count": K, "has_more": bool } }
  • Create silence: post_silence(silence_dict)
  • Delete silence: delete_silence(silence_id)
  • List receivers: get_receivers()
  • List alert groups: get_alert_groups(silenced, inhibited, active, count, offset)
    • Pagination support: Returns paginated results to avoid overwhelming LLM context
    • count: Number of alert groups per page (default: 3, max: 5)
    • offset: Number of alert groups to skip (default: 0)
    • Returns: { "data": [...], "pagination": { "total": N, "offset": M, "count": K, "has_more": bool } }
    • Note: Alert groups have lower limits because they contain all alerts within each group

Pagination Benefits

When working with environments that have many alerts, silences, or alert groups, the pagination feature helps:

  • Prevent context overflow: By default, only 10 items are returned per request
  • Efficient browsing: LLMs can iterate through results using offset and count parameters
  • Smart limits: Maximum of 50 items per page prevents excessive context usage
  • Clear navigation: has_more flag indicates when additional pages are available

Example: If you have 100 alerts, the LLM can fetch them in manageable chunks (e.g., 10 at a time) and only load what's needed for analysis.

See src/alertmanager_mcp_server/server.py for full API details.

5. 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.

# Clone the repository
$ git clone https://github.com/ntk148v/alertmanager-mcp-server.git
$ cd alertmanager-mcp-server
$ make setup
# Run test
$ make test
# Run in development mode
$ mcp dev src/alertmanager_mcp_server/server.py

# Install in Claude Desktop
$ make install

6. License

Apache 2.0


Made with โค๏ธ by @ntk148v