list_open_incidents
Retrieve and filter currently active incidents in New Relic to monitor system issues by priority and account.
Instructions
List all open incidents in your New Relic account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_account_id | No | Optional New Relic account ID | |
| priority | No | Filter by incident priority |
Implementation Reference
- src/tools/alert.ts:105-164 (handler)Executes the core logic for listing open incidents in New Relic using a NerdGraph query on AI issues entities, with optional priority filtering and account ID validation.async listOpenIncidents(input: { target_account_id?: string; priority?: 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW'; }): Promise<Record<string, unknown>[]> { const accountId = input.target_account_id; if (!accountId) { throw new Error('Account ID must be provided'); } if (!/^\d+$/.test(accountId)) { throw new Error('Invalid account ID format'); } let filter = `accountId = '${accountId}' AND state = 'OPEN'`; if (input.priority) { filter += ` AND priority = '${input.priority}'`; } const query = `{ actor { entitySearch(query: "${filter}") { results { entities { ... on AiIssuesEntity { issues { issues { issueId title priority state createdAt sources } } } } } } } }`; const response = await this.client.executeNerdGraphQuery<{ actor?: { entitySearch?: { results?: { entities?: Array<{ issues?: { issues?: Record<string, unknown>[] } }> }; }; }; }>(query); const entities = (response.data?.actor?.entitySearch?.results?.entities || []) as Array<{ issues?: { issues?: Record<string, unknown>[] }; }>; const incidents: Record<string, unknown>[] = []; entities.forEach((entity) => { if (entity.issues?.issues) { incidents.push(...entity.issues.issues); } }); return incidents; }
- src/tools/alert.ts:27-46 (schema)Defines the tool schema: name, description, and inputSchema for parameters target_account_id (optional string) and priority (optional enum: CRITICAL|HIGH|MEDIUM|LOW).getIncidentsTool(): Tool { return { name: 'list_open_incidents', description: 'List all open incidents in your New Relic account', inputSchema: { type: 'object', properties: { target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, priority: { type: 'string', enum: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'], description: 'Filter by incident priority', }, }, }, }; }
- src/server.ts:68-106 (registration)Registers the tool by adding alertTool.getIncidentsTool() to the MCP server's tools Map.// Register all tools const tools = [ nrqlTool.getToolDefinition(), apmTool.getListApplicationsTool(), entityTool.getSearchTool(), entityTool.getDetailsTool(), alertTool.getPoliciesTool(), alertTool.getIncidentsTool(), alertTool.getAcknowledgeTool(), syntheticsTool.getListMonitorsTool(), syntheticsTool.getCreateMonitorTool(), nerdGraphTool.getQueryTool(), // REST v2 tools restDeployments.getCreateTool(), restDeployments.getListTool(), restDeployments.getDeleteTool(), restApm.getListApplicationsTool(), restMetrics.getListMetricNamesTool(), restMetrics.getMetricDataTool(), restMetrics.getListApplicationHostsTool(), { name: 'get_account_details', description: 'Get New Relic account details', inputSchema: { type: 'object' as const, properties: { target_account_id: { type: 'string' as const, description: 'Optional account ID to get details for', }, }, }, }, ]; tools.forEach((tool) => { this.tools.set(tool.name, tool); }); }
- src/server.ts:210-214 (handler)MCP server dispatch case that invokes the AlertTool's listOpenIncidents handler with resolved account ID.case 'list_open_incidents': return await new AlertTool(this.client).listOpenIncidents({ ...args, target_account_id: accountId, });