Skip to main content
Glama
comqx

Prometheus Alertmanager MCP Server

by comqx

create-silence

Suppress specific Prometheus Alertmanager alerts temporarily by creating silences with matchers, duration, and explanatory comments.

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 that implements the logic to create a silence by preparing matcher data and POSTing to Alertmanager's /api/v2/silences endpoint.
    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 parameters for creating a silence: matchers, optional startsAt, 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() with name, input schema, and handler function.
    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