Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

run_nerdgraph_query

Execute custom GraphQL queries on New Relic's NerdGraph API to fetch or manage telemetry data and configurations.

Instructions

Execute a custom NerdGraph GraphQL query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe GraphQL query to execute
variablesNoOptional GraphQL variables to supply to the query

Implementation Reference

  • Execution handler for 'run_nerdgraph_query' in executeTool() - delegates to NerdGraphTool.execute()
        case 'run_nerdgraph_query':
          return await new NerdGraphTool(this.client).execute(args);
        default: {
          const tool = this.tools.get(name);
          if (!tool) {
            throw new Error(`Tool ${name} not found`);
          }
          throw new Error(`Tool handler for ${name} not implemented`);
        }
      }
    }
  • NerdGraphTool.execute() - validates input with Zod schema and calls client.executeNerdGraphQuery()
      async execute(input: unknown): Promise<unknown> {
        // Validate input with Zod for consistency
        const schema = z.object({
          query: z.string().min(1, 'Invalid or empty GraphQL query provided'),
          variables: z.record(z.any()).optional(),
        });
    
        const { query, variables } = schema.parse(input);
    
        return await this.client.executeNerdGraphQuery(query, variables);
      }
    }
  • Tool definition with inputSchema for 'run_nerdgraph_query' (name, description, required 'query' string, optional 'variables' object)
    getQueryTool(): Tool {
      return {
        name: 'run_nerdgraph_query',
        description: 'Execute a custom NerdGraph GraphQL query',
        inputSchema: {
          type: 'object',
          properties: {
            query: {
              type: 'string',
              description: 'The GraphQL query to execute',
            },
            variables: {
              type: 'object',
              description: 'Optional GraphQL variables to supply to the query',
            },
          },
          required: ['query'],
        },
      };
    }
  • src/server.ts:79-79 (registration)
    Registration of the tool in registerTools() - nerdGraphTool.getQueryTool() is added to the tools map
    nerdGraphTool.getQueryTool(),
  • executeNerdGraphQuery() - the underlying HTTP helper that sends the GraphQL query to New Relic's NerdGraph API
    async executeNerdGraphQuery<T = unknown>(
      query: string,
      variables?: Record<string, unknown>
    ): Promise<GraphQLResponse<T>> {
      // Check if API key is missing or empty
      if (!this.apiKey || this.apiKey === '' || this.apiKey.length === 0) {
        throw new Error('NEW_RELIC_API_KEY environment variable is not set');
      }
    
      const response = await fetch(NERDGRAPH_URL, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'API-Key': this.apiKey,
        },
        body: JSON.stringify({ query, variables }),
      });
    
      if (!response.ok) {
        if (response.status === 401) {
          throw new Error('Unauthorized: Invalid API key');
        }
        throw new Error(`NerdGraph API error: ${response.status} ${response.statusText}`);
      }
    
      return (await response.json()) as GraphQLResponse<T>;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations are absent, so description must cover behavior. It only states 'execute' without noting that it supports both queries and mutations, requires authentication, or may have rate limits. Does not disclose potential destructive actions if mutations are allowed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence with no redundant words. Immediately conveys the core action and target.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite high schema coverage and no output schema, the description lacks critical context: it does not explain that the response is a GraphQL result, mention any error handling, or note that queries/mutations target New Relic data. For a flexible custom query tool, this is insufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with 'query' and 'variables' fields clearly described. The tool description adds no additional meaning beyond what the schema provides, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Execute a custom NerdGraph GraphQL query', providing a specific verb and resource. It distinguishes from siblings like 'run_nrql_query' by naming the query language (NerdGraph vs NRQL).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives such as 'run_nrql_query' for NRQL queries or other tools. Does not state prerequisites, limitations, or when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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