Skip to main content
Glama
comqx

Prometheus Alertmanager MCP Server

by comqx

create-silence

Create alert silences in Prometheus Alertmanager by specifying matchers, duration, and reason to temporarily suppress notifications for specific alerts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
matchersYesList of matchers for alerts
startsAtNoSilence start time (ISO8601 format, default is current time)
endsAtYesSilence end time (ISO8601 format)
createdByYesUsername who created the silence
commentYesReason or explanation for the silence

Implementation Reference

  • Handler function for the 'create-silence' tool. It prepares the silence data with matchers, timestamps, creator, and comment, then POSTs it to the Alertmanager /api/v2/silences endpoint using the shared fetchFromAlertmanager helper, and returns success or error response.
    async ({ matchers, startsAt, endsAt, createdBy, comment }) => { try { // Prepare silence data const now = new Date().toISOString(); const silenceData = { matchers: matchers.map(m => ({ name: m.name, value: m.value, isRegex: m.isRegex || false, })), startsAt: startsAt || now, endsAt, createdBy, comment, }; // Create the silence const response = await fetchFromAlertmanager('silences', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(silenceData), }); return { content: [{ type: "text", text: `Successfully created silence with ID: ${response.silenceID}` }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error creating silence: ${errorMessage}` }], isError: true }; } }
  • Zod input schema defining the parameters for the create-silence tool: matchers (array of name/value/isRegex), optional startsAt, required endsAt, createdBy, and comment.
    { matchers: z.array(z.object({ name: z.string().describe("Matcher name (e.g. alertname)"), value: z.string().describe("Matcher value (e.g. HighCPULoad)"), isRegex: z.boolean().optional().describe("Use regex matching"), })).describe("List of matchers for alerts"), startsAt: z.string().optional().describe("Silence start time (ISO8601 format, default is current time)"), endsAt: z.string().describe("Silence end time (ISO8601 format)"), createdBy: z.string().describe("Username who created the silence"), comment: z.string().describe("Reason or explanation for the silence"), },
  • src/index.ts:213-268 (registration)
    Registration of the 'create-silence' tool on the MCP server using server.tool(name, inputSchema, handlerFunction).
    server.tool( "create-silence", { matchers: z.array(z.object({ name: z.string().describe("Matcher name (e.g. alertname)"), value: z.string().describe("Matcher value (e.g. HighCPULoad)"), isRegex: z.boolean().optional().describe("Use regex matching"), })).describe("List of matchers for alerts"), startsAt: z.string().optional().describe("Silence start time (ISO8601 format, default is current time)"), endsAt: z.string().describe("Silence end time (ISO8601 format)"), createdBy: z.string().describe("Username who created the silence"), comment: z.string().describe("Reason or explanation for the silence"), }, async ({ matchers, startsAt, endsAt, createdBy, comment }) => { try { // Prepare silence data const now = new Date().toISOString(); const silenceData = { matchers: matchers.map(m => ({ name: m.name, value: m.value, isRegex: m.isRegex || false, })), startsAt: startsAt || now, endsAt, createdBy, comment, }; // Create the silence const response = await fetchFromAlertmanager('silences', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(silenceData), }); return { content: [{ type: "text", text: `Successfully created silence with ID: ${response.silenceID}` }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error creating silence: ${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