get-incidents
Retrieve and filter incidents from Datadog's incident management system to review current or past issues with status-based and query filtering capabilities.
Instructions
List incidents from Datadog's incident management system. Can filter by active/archived status and use query strings to find specific incidents. Helpful for reviewing current or past incidents.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get-incidents"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeArchived | No | ||
| pageSize | No | ||
| pageOffset | No | ||
| query | No | ||
| limit | No |
Implementation Reference
- src/tools/getIncidents.ts:34-80 (handler)The execute function implements the core logic for fetching incidents from Datadog's API using the IncidentsApi, handling parameters, making the API call, applying limits, and error handling.
execute: async (params: GetIncidentsParams) => { try { const { includeArchived, pageSize, pageOffset, query, limit } = params; const apiInstance = new v2.IncidentsApi(configuration); const apiParams: any = {}; if (includeArchived !== undefined) { apiParams.include_archived = includeArchived; } if (pageSize !== undefined) { apiParams.page_size = pageSize; } if (pageOffset !== undefined) { apiParams.page_offset = pageOffset; } if (query !== undefined) { apiParams.query = query; } const response = await apiInstance.listIncidents(apiParams); // Apply client-side limit if specified if (limit && response.data && response.data.length > limit) { response.data = response.data.slice(0, limit); } return response; } catch (error: any) { if (error.status === 403) { console.error( "Authorization failed (403 Forbidden): Check that your API key and Application key are valid and have sufficient permissions to access incidents." ); throw new Error( "Datadog API authorization failed. Please verify your API and Application keys have the correct permissions." ); } else { console.error("Error fetching incidents:", error); throw error; } } } }; - src/index.ts:197-213 (registration)Registers the 'get-incidents' tool with the MCP server, defining its name, description, input schema using Zod, and a wrapper handler that calls the actual execute function.
server.tool( "get-incidents", "List incidents from Datadog's incident management system. Can filter by active/archived status and use query strings to find specific incidents. Helpful for reviewing current or past incidents.", { includeArchived: z.boolean().optional(), pageSize: z.number().optional(), pageOffset: z.number().optional(), query: z.string().optional(), limit: z.number().default(100) }, async (args) => { const result = await getIncidents.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } ); - src/tools/getIncidents.ts:3-9 (schema)TypeScript type definition for the input parameters of the getIncidents tool, matching the Zod schema used in registration.
type GetIncidentsParams = { includeArchived?: boolean; pageSize?: number; pageOffset?: number; query?: string; limit?: number; }; - src/tools/getIncidents.ts:14-32 (helper)Initialization function that sets up the Datadog API client configuration with auth keys, site, and enables the unstable listIncidents operation.
initialize: () => { const configOpts = { authMethods: { apiKeyAuth: process.env.DD_API_KEY, appKeyAuth: process.env.DD_APP_KEY } }; configuration = client.createConfiguration(configOpts); if (process.env.DD_SITE) { configuration.setServerVariables({ site: process.env.DD_SITE }); } // Enable the unstable operation configuration.unstableOperations["v2.listIncidents"] = true; },