Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

create_browser_monitor

Set up automated browser monitoring for websites by configuring synthetic checks that track performance and availability from multiple global locations.

Instructions

Create a new browser-based Synthetics monitor

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the monitor
urlYesURL to monitor
frequencyYesCheck frequency in minutes
locationsYesLocation codes for monitoring
target_account_idNoOptional New Relic account ID

Implementation Reference

  • Core handler function that executes the GraphQL mutation to create a new browser Synthetics monitor in New Relic.
    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;
    }
  • Tool schema definition including input validation schema for parameters like name, url, frequency, locations.
      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)
    Registers the create_browser_monitor tool by including it in the tools array via getCreateMonitorTool().
    syntheticsTool.getListMonitorsTool(),
    syntheticsTool.getCreateMonitorTool(),
  • Dispatch handler in server that validates inputs and delegates to SyntheticsTool.createBrowserMonitor.
    case 'create_browser_monitor': {
      const { name, url, frequency, locations } = args as Record<string, unknown>;
      if (typeof name !== 'string' || name.trim() === '') {
        throw new Error('create_browser_monitor: "name" (non-empty string) is required');
      }
      if (typeof url !== 'string' || url.trim() === '') {
        throw new Error('create_browser_monitor: "url" (non-empty string) is required');
      }
      if (typeof frequency !== 'number' || !Number.isFinite(frequency) || frequency <= 0) {
        throw new Error('create_browser_monitor: "frequency" (positive number) is required');
      }
      if (
        !Array.isArray(locations) ||
        (locations as unknown[]).some((l) => typeof l !== 'string')
      ) {
        throw new Error('create_browser_monitor: "locations" must be an array of strings');
      }
      return await new SyntheticsTool(this.client).createBrowserMonitor({
        name,
        url,
        frequency,
        locations: locations as string[],
        target_account_id: accountId,
      });
    }
  • Helper function to convert frequency minutes to New Relic period strings used in the 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';
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cloudbring/newrelic-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server