Skip to main content
Glama
comqx

Prometheus Alertmanager MCP Server

by comqx

get-alert-groups

Retrieve and filter alert groups from Prometheus Alertmanager based on active, silenced, or inhibited status to monitor system notifications.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activeNoInclude active alerts (default: true)
silencedNoInclude silenced alerts
inhibitedNoInclude inhibited alerts

Implementation Reference

  • The handler function that executes the get-alert-groups tool. It constructs query parameters based on input options (active, silenced, inhibited), fetches alert groups from the Alertmanager API endpoint `/api/v2/alerts/groups`, formats the response as JSON text, and handles errors appropriately.
    async ({ active = true, silenced = false, inhibited = false }) => {
      try {
        // Build query parameters
        const params = new URLSearchParams();
        if (!active) params.append("active", "false");
        if (silenced) params.append("silenced", "true");
        if (inhibited) params.append("inhibited", "true");
        
        // Fetch alert groups
        const queryString = params.toString();
        const path = `alerts/groups${queryString ? '?' + queryString : ''}`;
        const groups = await fetchFromAlertmanager(path);
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(groups, null, 2)
          }]
        };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [{
            type: "text",
            text: `Error fetching alert groups: ${errorMessage}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the get-alert-groups tool: optional booleans for filtering active, silenced, and inhibited alerts.
    {
      active: z.boolean().optional().describe("Include active alerts (default: true)"),
      silenced: z.boolean().optional().describe("Include silenced alerts"),
      inhibited: z.boolean().optional().describe("Include inhibited alerts"),
    },
  • src/index.ts:350-387 (registration)
    The registration of the get-alert-groups tool using McpServer's tool() method, specifying the name, input schema, and handler function.
    server.tool(
      "get-alert-groups",
      {
        active: z.boolean().optional().describe("Include active alerts (default: true)"),
        silenced: z.boolean().optional().describe("Include silenced alerts"),
        inhibited: z.boolean().optional().describe("Include inhibited alerts"),
      },
      async ({ active = true, silenced = false, inhibited = false }) => {
        try {
          // Build query parameters
          const params = new URLSearchParams();
          if (!active) params.append("active", "false");
          if (silenced) params.append("silenced", "true");
          if (inhibited) params.append("inhibited", "true");
          
          // Fetch alert groups
          const queryString = params.toString();
          const path = `alerts/groups${queryString ? '?' + queryString : ''}`;
          const groups = await fetchFromAlertmanager(path);
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(groups, null, 2)
            }]
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [{
              type: "text",
              text: `Error fetching alert groups: ${errorMessage}`
            }],
            isError: true
          };
        }
      }
    );
  • Shared helper function used by get-alert-groups (and other tools) to make HTTP requests to the Alertmanager API with timeout handling, error management, and JSON response parsing.
    async function fetchFromAlertmanager(path: string, options: RequestInit = {}): Promise<any> {
      const baseUrl = process.env.ALERTMANAGER_URL || DEFAULT_ALERTMANAGER_URL;
      const url = `${baseUrl}/api/v2/${path}`;
      
      try {
        const controller = new AbortController();
        const timeoutId = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
        
        const response = await fetch(url, {
          ...options,
          signal: controller.signal
        });
        
        clearTimeout(timeoutId);
        
        if (!response.ok) {
          throw new Error(`Alertmanager API error: ${response.status} ${response.statusText}`);
        }
        
        return await response.json();
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        console.error(`Error fetching from Alertmanager: ${errorMessage}`);
        throw error;
      }
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/comqx/alertmanager-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server