Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

list_metric_names_for_host

Retrieve metric names and values for a specific application host in New Relic to monitor performance and analyze system behavior.

Instructions

List metric names and values for a specific application host (REST v2).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
application_idYes
host_idYes
nameNo
pageNo
auto_paginateNo
regionNo

Implementation Reference

  • The core handler function `listMetricNames` in `RestMetricsTool` class that performs the API call to list metric names for a given application host using New Relic REST API v2, with optional pagination support.
    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 };
    }
  • The `getListMetricNamesTool` method defining the tool's metadata, description, and input schema for validation.
    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/server.ts:65-87 (registration)
    Registration of RestMetricsTool instance and addition of its tool definitions, including 'list_metric_names_for_host', to the server's tools registry for discovery.
    const restApm = new RestApmTool();
    const restMetrics = new RestMetricsTool();
    
    // Register all tools
    const 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(),
  • src/server.ts:191-194 (registration)
    Switch case in server's `executeTool` method that dispatches tool calls to the handler by instantiating RestMetricsTool and calling `listMetricNames`.
    case 'list_metric_names_for_host':
      return await new RestMetricsTool().listMetricNames(
        args as Parameters<RestMetricsTool['listMetricNames']>[0]
      );

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