run_nerdgraph_query
Execute custom GraphQL queries to interact with New Relic's NerdGraph API for data retrieval and management tasks.
Instructions
Execute a custom NerdGraph GraphQL query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The GraphQL query to execute | |
| variables | No | Optional GraphQL variables to supply to the query |
Implementation Reference
- src/tools/nerdgraph.ts:33-43 (handler)The primary handler for the 'run_nerdgraph_query' tool. Validates the GraphQL query and variables input using Zod, then delegates execution to the NewRelicClient.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); }
- src/tools/nerdgraph.ts:12-30 (schema)Defines the tool's metadata, including name, description, and input schema specifying a required 'query' string and 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-80 (registration)Registers the 'run_nerdgraph_query' tool by including NerdGraphTool.getQueryTool() in the server's list of available tools.nerdGraphTool.getQueryTool(), // REST v2 tools
- src/server.ts:283-284 (handler)Server-side dispatch handler that instantiates NerdGraphTool and calls its execute method for 'run_nerdgraph_query' tool invocations.case 'run_nerdgraph_query': return await new NerdGraphTool(this.client).execute(args);