list_apm_applications
Retrieve a list of all APM applications in your New Relic account using a specified account ID with this tool on the MCP server.
Instructions
List all APM applications in your New Relic account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_account_id | No | Optional New Relic account ID |
Implementation Reference
- src/tools/apm.ts:11-25 (schema)Defines the tool metadata, name, description, and input schema for 'list_apm_applications'getListApplicationsTool(): Tool { return { name: 'list_apm_applications', description: 'List all APM applications in your New Relic account', inputSchema: { type: 'object', properties: { target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, }, }, }; }
- src/tools/apm.ts:27-34 (handler)The main handler function for the 'list_apm_applications' tool, which validates input and delegates to NewRelicClientasync execute(input: { target_account_id?: string }): Promise<ApmApplication[]> { if (!input.target_account_id) { throw new Error('Account ID must be provided'); } const applications = await this.client.listApmApplications(input.target_account_id); return applications; }
- Core helper method that performs the NerdGraph GraphQL query to list APM applications and parses the responseasync listApmApplications(accountId?: string): Promise<ApmApplication[]> { const id = accountId || this.defaultAccountId; if (!id) { throw new Error('Account ID must be provided'); } const query = `{ actor { entitySearch(query: "domain = 'APM' AND type = 'APPLICATION' AND accountId = '${id}'") { results { entities { guid name ... on ApmApplicationEntityOutline { language reporting alertSeverity tags { key values } } } } } } }`; type EntitySearchResponse = { actor?: { entitySearch?: { results?: { entities?: Array<{ guid: string; name: string; language?: string; reporting?: boolean; alertSeverity?: string; tags?: Array<{ key?: string; values?: string[] }>; }>; }; }; }; }; const response = (await this.executeNerdGraphQuery<EntitySearchResponse>( query )) as GraphQLResponse<EntitySearchResponse>; const entities = (response.data?.actor?.entitySearch?.results?.entities || []) as Array<{ guid: string; name: string; language?: string; reporting?: boolean; alertSeverity?: string; tags?: Array<{ key?: string; values?: string[] }>; }>; return entities.map((entity) => ({ guid: entity.guid, name: entity.name, language: entity.language || 'unknown', reporting: entity.reporting || false, alertSeverity: entity.alertSeverity, tags: this.parseTags(entity.tags), })); }
- src/server.ts:69-105 (registration)Registers the 'list_apm_applications' tool by including it in the tools Map used for ListToolsRequestconst tools = [ nrqlTool.getToolDefinition(), apmTool.getListApplicationsTool(), entityTool.getSearchTool(), entityTool.getDetailsTool(), alertTool.getPoliciesTool(), alertTool.getIncidentsTool(), alertTool.getAcknowledgeTool(), syntheticsTool.getListMonitorsTool(), syntheticsTool.getCreateMonitorTool(), nerdGraphTool.getQueryTool(), // REST v2 tools restDeployments.getCreateTool(), restDeployments.getListTool(), restDeployments.getDeleteTool(), restApm.getListApplicationsTool(), restMetrics.getListMetricNamesTool(), restMetrics.getMetricDataTool(), restMetrics.getListApplicationHostsTool(), { name: 'get_account_details', description: 'Get New Relic account details', inputSchema: { type: 'object' as const, properties: { target_account_id: { type: 'string' as const, description: 'Optional account ID to get details for', }, }, }, }, ]; tools.forEach((tool) => { this.tools.set(tool.name, tool); });
- src/server.ts:170-174 (handler)Server-side dispatch handler that invokes the ApmTool execute method for tool callscase 'list_apm_applications': return await new ApmTool(this.client).execute({ ...args, target_account_id: accountId, });