Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

create_incident

Create a new incident in Grafana with specified title, severity, and room prefix to manage and track operational issues within monitoring systems.

Instructions

Create a new Grafana incident. Requires title, severity, and room prefix

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachCaptionNoCaption of the attachment
attachUrlNoURL of the attachment
isDrillNoWhether the incident is a drill
labelsNoLabels to add to the incident
roomPrefixYesThe prefix of the room to create the incident in
severityYesThe severity of the incident
statusNoThe status of the incident
titleYesThe title of the incident

Implementation Reference

  • The core handler implementation for the 'create_incident' tool. It constructs incident data from input params, optionally adds attachments, and posts to the Grafana Incident API using an axios client.
    export const createIncident: ToolDefinition = { name: 'create_incident', description: 'Create a new Grafana incident. Requires title, severity, and room prefix', inputSchema: CreateIncidentSchema, handler: async (params, context: ToolContext) => { try { const client = createIncidentClient(context.config.grafanaConfig); const incidentData: any = { title: params.title, severity: params.severity, roomPrefix: params.roomPrefix, }; if (params.status) incidentData.status = params.status; if (params.isDrill !== undefined) incidentData.isDrill = params.isDrill; if (params.labels) incidentData.labels = params.labels; const attachments = []; if (params.attachUrl) { attachments.push({ attachmentID: 'attach-1', url: params.attachUrl, useToSummarize: true, caption: params.attachCaption, }); } const response = await client.post('/IncidentService.CreateIncident', { incident: incidentData, attachments, }); return createToolResult({ incidentID: response.data.incident.incidentID, title: response.data.incident.title, status: response.data.incident.status, message: 'Incident created successfully', }); } catch (error: any) { return createErrorResult(error.response?.data?.message || error.message); } }, };
  • Zod input schema defining parameters for creating an incident, including title, severity, roomPrefix, and optional fields like status, labels, and attachments.
    const CreateIncidentSchema = z.object({ title: z.string().describe('The title of the incident'), severity: z.string().describe('The severity of the incident'), status: z.string().optional().describe('The status of the incident'), roomPrefix: z.string().describe('The prefix of the room to create the incident in'), isDrill: z.boolean().optional().describe('Whether the incident is a drill'), labels: z.array(z.object({ key: z.string(), label: z.string(), description: z.string().optional(), colorHex: z.string().optional(), })).optional().describe('Labels to add to the incident'), attachUrl: z.string().optional().describe('URL of the attachment'), attachCaption: z.string().optional().describe('Caption of the attachment'), });
  • Registration function for all incident-related tools, including 'create_incident'.
    export function registerIncidentTools(server: any) { server.registerTool(listIncidents); server.registerTool(getIncident); server.registerTool(createIncident); server.registerTool(addActivityToIncident); }
  • src/cli.ts:114-114 (registration)
    Invocation of the incident tools registration in the main CLI entrypoint, conditional on the 'incident' tool category being enabled.
    registerIncidentTools(server);
  • Helper function that creates an authenticated axios client for the Grafana Incident API, used by all incident tools including create_incident.
    function createIncidentClient(config: any) { const headers: any = { 'User-Agent': 'mcp-grafana/1.0.0', }; if (config.serviceAccountToken) { headers['Authorization'] = `Bearer ${config.serviceAccountToken}`; } else if (config.apiKey) { headers['Authorization'] = `Bearer ${config.apiKey}`; } return axios.create({ baseURL: `${config.url}/api/plugins/grafana-incident-app/resources/api/v1`, headers, timeout: 30000, }); }

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/0xteamhq/mcp-grafana'

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