Skip to main content
Glama
comqx

Prometheus Alertmanager MCP Server

by comqx

get-alert-details

Retrieve detailed information about a specific alert from Prometheus Alertmanager using its fingerprint to investigate and respond to monitoring issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fingerprintYesAlert fingerprint

Implementation Reference

  • The handler function fetches all alerts from Alertmanager, finds the one matching the provided fingerprint, formats its details, and returns them as JSON. Handles errors appropriately.
    async ({ fingerprint }) => {
      try {
        // Fetch alert list
        const alerts = await fetchFromAlertmanager('alerts') as Alert[];
        
        // Find the alert matching the fingerprint
        const alert = alerts.find((a: Alert) => a.fingerprint === fingerprint);
        
        if (!alert) {
          return {
            content: [{
              type: "text",
              text: `Alert with fingerprint ${fingerprint} not found`
            }],
            isError: true
          };
        }
        
        // Format the detailed alert information
        const details = {
          fingerprint: alert.fingerprint,
          alertname: alert.labels.alertname,
          labels: alert.labels,
          annotations: alert.annotations,
          startsAt: alert.startsAt,
          endsAt: alert.endsAt,
          generatorURL: alert.generatorURL,
          status: alert.status,
        };
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(details, null, 2)
          }]
        };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [{
            type: "text",
            text: `Error fetching alert details: ${errorMessage}`
          }],
          isError: true
        };
      }
    }
  • Zod input schema defining the required 'fingerprint' parameter for the tool.
    {
      fingerprint: z.string().describe("Alert fingerprint"),
    },
  • src/index.ts:158-210 (registration)
    Registration of the 'get-alert-details' tool using server.tool(), including input schema and handler function.
    server.tool(
      "get-alert-details",
      {
        fingerprint: z.string().describe("Alert fingerprint"),
      },
      async ({ fingerprint }) => {
        try {
          // Fetch alert list
          const alerts = await fetchFromAlertmanager('alerts') as Alert[];
          
          // Find the alert matching the fingerprint
          const alert = alerts.find((a: Alert) => a.fingerprint === fingerprint);
          
          if (!alert) {
            return {
              content: [{
                type: "text",
                text: `Alert with fingerprint ${fingerprint} not found`
              }],
              isError: true
            };
          }
          
          // Format the detailed alert information
          const details = {
            fingerprint: alert.fingerprint,
            alertname: alert.labels.alertname,
            labels: alert.labels,
            annotations: alert.annotations,
            startsAt: alert.startsAt,
            endsAt: alert.endsAt,
            generatorURL: alert.generatorURL,
            status: alert.status,
          };
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(details, null, 2)
            }]
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [{
              type: "text",
              text: `Error fetching alert details: ${errorMessage}`
            }],
            isError: true
          };
        }
      }
    );

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