list_synthetics_monitors
Retrieve all Synthetics monitors from your New Relic account, with optional filters for account ID and monitor type.
Instructions
List all Synthetics monitors in your New Relic account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_account_id | No | Optional New Relic account ID | |
| monitor_type | No | Filter by monitor type |
Implementation Reference
- src/tools/synthetics.ts:67-113 (handler)The main handler function for list_synthetics_monitors. It builds a GraphQL query to search for SyntheticMonitorEntityOutline entities filtered by account ID and optionally by monitor type, executes the query via NerdGraph, and returns the results.
async listSyntheticsMonitors(input: { target_account_id?: string; monitor_type?: 'SIMPLE' | 'BROWSER' | 'SCRIPT_API' | 'SCRIPT_BROWSER'; }): Promise<Array<Record<string, unknown>>> { const accountId = input.target_account_id; if (!accountId) { throw new Error('Account ID must be provided'); } let query = `domain = 'SYNTH' AND accountId = '${accountId}'`; if (input.monitor_type) { query += ` AND monitorType = '${input.monitor_type}'`; } const graphqlQuery = `{ actor { entitySearch(query: "${query}") { results { entities { ... on SyntheticMonitorEntityOutline { guid name monitorType period monitoredUrl tags { key values } } } } } } }`; const response = (await this.client.executeNerdGraphQuery(graphqlQuery)) as { data?: { actor?: { entitySearch?: { results?: { entities?: Array<Record<string, unknown>> }; }; }; }; }; return response.data?.actor?.entitySearch?.results?.entities || []; } - src/tools/synthetics.ts:11-30 (schema)Input schema definition for the tool (getListMonitorsTool). Defines the name 'list_synthetics_monitors', description, and inputSchema with optional 'target_account_id' (string) and 'monitor_type' (enum of SIMPLE, BROWSER, SCRIPT_API, SCRIPT_BROWSER).
getListMonitorsTool(): Tool { return { name: 'list_synthetics_monitors', description: 'List all Synthetics monitors in your New Relic account', inputSchema: { type: 'object', properties: { target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, monitor_type: { type: 'string', enum: ['SIMPLE', 'BROWSER', 'SCRIPT_API', 'SCRIPT_BROWSER'], description: 'Filter by monitor type', }, }, }, }; } - src/server.ts:77-78 (registration)Registration of the tool in the server's registerTools method via syntheticsTool.getListMonitorsTool().
syntheticsTool.getListMonitorsTool(), syntheticsTool.getCreateMonitorTool(), - src/server.ts:253-257 (registration)Tool execution dispatch in executeTool(). Routes the 'list_synthetics_monitors' case to SyntheticsTool.listSyntheticsMonitors() with target_account_id injected from the account resolution logic.
case 'list_synthetics_monitors': return await new SyntheticsTool(this.client).listSyntheticsMonitors({ ...args, target_account_id: accountId, }); - src/server.ts:295-307 (registration)Registration of 'list_synthetics_monitors' in the requiresAccountId list, ensuring an account ID is validated before the tool executes.
private requiresAccountId(toolName: string): boolean { const accountRequiredTools = [ 'run_nrql_query', 'list_apm_applications', 'search_entities', 'get_account_details', 'list_alert_policies', 'list_open_incidents', 'list_synthetics_monitors', 'create_browser_monitor', ]; return accountRequiredTools.includes(toolName); }