get_incident
Retrieve detailed information about a specific Grafana incident using its unique ID to access full incident data for monitoring and analysis.
Instructions
Get a single incident by ID. Returns the full incident details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the incident to retrieve |
Implementation Reference
- src/tools/incident.ts:93-109 (handler)The main handler for the 'get_incident' tool, which creates an API client and fetches the incident details by ID using Grafana IncidentService.export const getIncident: ToolDefinition = { name: 'get_incident', description: 'Get a single incident by ID. Returns the full incident details', inputSchema: GetIncidentSchema, handler: async (params, context: ToolContext) => { try { const client = createIncidentClient(context.config.grafanaConfig); const response = await client.get(`/IncidentService.GetIncident`, { params: { incidentID: params.id }, }); return createToolResult(response.data.incident); } catch (error: any) { return createErrorResult(error.response?.data?.message || error.message); } }, };
- src/tools/incident.ts:12-14 (schema)Zod input schema for 'get_incident' tool, defining the required 'id' parameter.const GetIncidentSchema = z.object({ id: z.string().describe('The ID of the incident to retrieve'), });
- src/tools/incident.ts:187-192 (registration)Registration function that registers the 'getIncident' tool (and others) with the MCP server.export function registerIncidentTools(server: any) { server.registerTool(listIncidents); server.registerTool(getIncident); server.registerTool(createIncident); server.registerTool(addActivityToIncident); }
- src/tools/incident.ts:39-55 (helper)Helper function to create the Axios client for Grafana Incident API, used by the get_incident handler.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, }); }