Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

list_alert_policies

Retrieve all alert policies in your New Relic account using a target account ID to monitor and manage notification rules effectively.

Instructions

List all alert policies in your New Relic account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_account_idNoOptional New Relic account ID

Implementation Reference

  • The main handler function that executes the NerdGraph query to list alert policies for the given account ID.
    async listAlertPolicies(input: { target_account_id?: string; }): Promise<Array<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'); } const query = `{ actor { account(id: ${accountId}) { alerts { policiesSearch { policies { id name incidentPreference conditions { id name enabled } } } } } } }`; const response = await this.client.executeNerdGraphQuery<{ actor?: { account?: { alerts?: { policiesSearch?: { policies?: Array<Record<string, unknown>> } } }; }; }>(query); return response.data?.actor?.account?.alerts?.policiesSearch?.policies || []; }
  • Defines the tool's name, description, and input schema for validating inputs.
    getPoliciesTool(): Tool { return { name: 'list_alert_policies', description: 'List all alert policies in your New Relic account', inputSchema: { type: 'object', properties: { target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, }, }, }; }
  • src/server.ts:205-209 (registration)
    Dispatches tool calls to the AlertTool's listAlertPolicies handler in the server's executeTool switch statement.
    case 'list_alert_policies': return await new AlertTool(this.client).listAlertPolicies({ ...args, target_account_id: accountId, });
  • src/server.ts:74-74 (registration)
    Registers the tool by including alertTool.getPoliciesTool() in the tools array during server initialization.
    alertTool.getPoliciesTool(),

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