ninja_list_alerts
Retrieve all active alerts from devices. Apply filters by source type or device expression to narrow results.
Instructions
Get all active alerts across all devices. Filter by source type or device filter expression.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sourceType | No | Alert source type filter | |
| df | No | Device filter expression | |
| lang | No | Language tag for localized messages (e.g. en) | |
| tz | No | Time zone for timestamps (e.g. America/Chicago) |
Implementation Reference
- src/tools/alerts.ts:21-22 (handler)The handler for ninja_list_alerts that calls client.get('/alerts', clean(args)) to fetch all active alerts, with optional filtering via sourceType, df, lang, and tz.
handler: async (args, client: NinjaOneClient) => client.get('/alerts', clean(args)), }, - src/tools/alerts.ts:11-19 (schema)The inputSchema for ninja_list_alerts defines optional parameters: sourceType, df (device filter), lang (language tag), and tz (time zone).
inputSchema: { type: 'object', properties: { sourceType: { type: 'string', description: 'Alert source type filter' }, df: { type: 'string', description: 'Device filter expression' }, lang: { type: 'string', description: 'Language tag for localized messages (e.g. en)' }, tz: { type: 'string', description: 'Time zone for timestamps (e.g. America/Chicago)' }, }, }, - src/tools/index.ts:13-24 (registration)ALL_TOOLS bundles all tool definitions from alertTools (and others), which is imported into the main server.
export const ALL_TOOLS = [ ...deviceTools, ...organizationTools, ...alertTools, ...activityTools, ...ticketingTools, ...queryTools, ...policyTools, ...userTools, ...backupTools, ...systemTools, ]; - src/index.ts:24-24 (registration)The main server creates a toolMap from ALL_TOOLS, keyed by tool name ('ninja_list_alerts') to its handler. The handler is invoked in the CallToolRequestSchema handler.
const toolMap = new Map(ALL_TOOLS.map((def) => [def.tool.name, def.handler])); - src/utils.ts:1-6 (helper)The clean() utility function strips null/empty values from the args object before passing them as query parameters to the API call.
// eslint-disable-next-line @typescript-eslint/no-explicit-any export function clean(args: Record<string, any>): Record<string, unknown> { return Object.fromEntries( Object.entries(args).filter(([, v]) => v != null && v !== ''), ); }