list_metric_names_for_host
Retrieve metric names and values for a specific application host using REST v2. Input application ID and host ID to query data efficiently via New Relic MCP Server.
Instructions
List metric names and values for a specific application host (REST v2).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application_id | Yes | ||
| auto_paginate | No | ||
| host_id | Yes | ||
| name | No | ||
| page | No | ||
| region | No |
Implementation Reference
- src/tools/rest/metrics.ts:61-84 (handler)The handler function that executes the tool: queries New Relic REST API for metric names on a host, supports filtering by name, pagination, and auto-pagination.async listMetricNames(args: ListMetricNamesArgs): Promise<unknown> { const client = this.restFor(args.region); const path = `/applications/${args.application_id}/hosts/${args.host_id}/metrics`; const query: Record<string, unknown> = {}; if (args.name) query.name = args.name; if (args.page) query.page = args.page; const results: unknown[] = []; let nextUrl: string | undefined; let page = args.page; do { const res = await client.get<unknown>(path, page ? { ...query, page } : query); results.push(res.data); const next = res.links?.next; if (args.auto_paginate && next) { const u = new URL(next); const p = u.searchParams.get('page'); page = p ? Number(p) : undefined; nextUrl = next; } else { nextUrl = undefined; } } while (args.auto_paginate && nextUrl); return { items: args.auto_paginate ? results : results[0], page }; }
- src/tools/rest/metrics.ts:42-59 (schema)Defines the tool schema: name, description, and inputSchema for validation including required application_id and host_id.getListMetricNamesTool(): Tool { return { name: 'list_metric_names_for_host', description: 'List metric names and values for a specific application host (REST v2).', inputSchema: { type: 'object', properties: { application_id: { type: 'number' }, host_id: { type: 'number' }, name: { type: 'string' }, page: { type: 'number' }, auto_paginate: { type: 'boolean' }, region: { type: 'string', enum: ['US', 'EU'] }, }, required: ['application_id', 'host_id'], }, }; }
- src/tools/rest/metrics.ts:4-11 (schema)TypeScript type definition for the input arguments used by the handler and schema.type ListMetricNamesArgs = { application_id: number; host_id: number; name?: string; page?: number; auto_paginate?: boolean; region?: Region; };
- src/server.ts:191-194 (registration)Tool handler registration in the central executeTool switch statement, dispatching to RestMetricsTool.listMetricNames.case 'list_metric_names_for_host': return await new RestMetricsTool().listMetricNames( args as Parameters<RestMetricsTool['listMetricNames']>[0] );
- src/server.ts:64-66 (registration)Instantiation of RestMetricsTool used for both tool registration and execution.const restDeployments = new RestDeploymentsTool(); const restApm = new RestApmTool(); const restMetrics = new RestMetricsTool();
- src/server.ts:85-86 (registration)Registration of the tool definition (from getListMetricNamesTool()) into the server's tools list.restMetrics.getListMetricNamesTool(), restMetrics.getMetricDataTool(),