list_open_incidents
Retrieve all open incidents in your New Relic account, with optional filtering by priority and account ID.
Instructions
List all open incidents in your New Relic account
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": "list_open_incidents"
}
}Input 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:27-46 (schema)Schema definition for the 'list_open_incidents' tool, defining name, description, and inputSchema with optional target_account_id and priority filter.
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/tools/alert.ts:105-164 (handler)Handler function that executes the tool logic: builds a NerdGraph query filtering by accountId and state=OPEN (optionally by priority), executes it, and collects all incidents.
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/server.ts:68-75 (registration)Registration of 'list_open_incidents' via alertTool.getIncidentsTool() in the tools map during server initialization.
// Register all tools const tools = [ nrqlTool.getToolDefinition(), apmTool.getListApplicationsTool(), entityTool.getSearchTool(), entityTool.getDetailsTool(), alertTool.getPoliciesTool(), alertTool.getIncidentsTool(), - src/server.ts:210-214 (handler)Server-side handler dispatch routing the 'list_open_incidents' tool name to AlertTool.listOpenIncidents() with the resolved account ID.
case 'list_open_incidents': return await new AlertTool(this.client).listOpenIncidents({ ...args, target_account_id: accountId, });