create_browser_monitor
Set up browser-based Synthetics monitors to track website performance by specifying URLs, check frequency, and monitoring locations via the New Relic MCP Server.
Instructions
Create a new browser-based Synthetics monitor
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| frequency | Yes | Check frequency in minutes | |
| locations | Yes | Location codes for monitoring | |
| name | Yes | Name of the monitor | |
| target_account_id | No | Optional New Relic account ID | |
| url | Yes | URL to monitor |
Implementation Reference
- src/tools/synthetics.ts:115-171 (handler)Core handler function that executes the creation of a new browser Synthetics monitor using a NerdGraph mutation to New Relic's API.async createBrowserMonitor(input: { target_account_id?: string; name: string; url: string; frequency: number; locations: string[]; }): Promise<Record<string, unknown> | null> { const accountId = input.target_account_id; if (!accountId) { throw new Error('Account ID must be provided'); } const mutation = ` mutation { syntheticsCreateSimpleBrowserMonitor( accountId: ${accountId} monitor: { name: "${input.name}" uri: "${input.url}" period: ${this.frequencyToPeriod(input.frequency)} status: ENABLED locations: { public: ${JSON.stringify(input.locations)} } } ) { monitor { id name uri period status } errors { type description } } } `; const response = await this.client.executeNerdGraphQuery<{ syntheticsCreateSimpleBrowserMonitor?: { monitor?: Record<string, unknown>; errors?: Array<{ description?: string }>; }; }>(mutation); const result = response.data?.syntheticsCreateSimpleBrowserMonitor; if (Array.isArray(result?.errors) && result!.errors!.length > 0) { throw new Error( `Failed to create monitor: ${result!.errors![0]?.description || 'Unknown error'}` ); } return (result?.monitor as Record<string, unknown>) || null; }
- src/tools/synthetics.ts:36-63 (schema)Input schema definition for the create_browser_monitor tool, specifying parameters, types, enums, and required fields.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the monitor', }, url: { type: 'string', description: 'URL to monitor', }, frequency: { type: 'number', enum: [1, 5, 10, 15, 30, 60], description: 'Check frequency in minutes', }, locations: { type: 'array', items: { type: 'string' }, description: 'Location codes for monitoring', }, target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, }, required: ['name', 'url', 'frequency', 'locations'], },
- src/tools/synthetics.ts:32-65 (registration)Tool registration method that returns the Tool object definition for 'create_browser_monitor', including name, description, and schema. This is called during server setup.getCreateMonitorTool(): Tool { return { name: 'create_browser_monitor', description: 'Create a new browser-based Synthetics monitor', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the monitor', }, url: { type: 'string', description: 'URL to monitor', }, frequency: { type: 'number', enum: [1, 5, 10, 15, 30, 60], description: 'Check frequency in minutes', }, locations: { type: 'array', items: { type: 'string' }, description: 'Location codes for monitoring', }, target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, }, required: ['name', 'url', 'frequency', 'locations'], }, }; }
- src/server.ts:77-78 (registration)Registration of the create_browser_monitor tool by including syntheticsTool.getCreateMonitorTool() in the server's tools list.syntheticsTool.getListMonitorsTool(), syntheticsTool.getCreateMonitorTool(),
- src/tools/synthetics.ts:173-183 (helper)Helper function to map frequency minutes to New Relic period strings used in the monitor creation mutation.private frequencyToPeriod(frequency: number): string { const periodMap: { [key: number]: string } = { 1: 'EVERY_MINUTE', 5: 'EVERY_5_MINUTES', 10: 'EVERY_10_MINUTES', 15: 'EVERY_15_MINUTES', 30: 'EVERY_30_MINUTES', 60: 'EVERY_HOUR', }; return periodMap[frequency] || 'EVERY_5_MINUTES'; }