nerdgraph_query
Execute custom GraphQL queries to interact with New Relic monitoring and observability data through the NerdGraph API.
Instructions
Execute a custom NerdGraph GraphQL query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| variables | No |
Implementation Reference
- newrelic_mcp/server.py:534-547 (handler)MCP tool handler for 'nerdgraph_query'. This is the main entrypoint decorated with @mcp.tool() that handles the tool execution by calling the client's method and formatting the JSON response.@mcp.tool() async def nerdgraph_query( query: str, variables: Optional[Dict[str, Any]] = None ) -> str: """Execute a custom NerdGraph GraphQL query""" if not client: return json.dumps({"error": "New Relic client not initialized"}) try: result = await client.nerdgraph_query(query, variables) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
- newrelic_mcp/server.py:158-166 (helper)Helper method in NewRelicClient class that performs the actual NerdGraph GraphQL query by constructing the request payload and calling the generic HTTP request method.async def nerdgraph_query( self, query: str, variables: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """Execute a NerdGraph GraphQL query""" data = {"query": query} if variables: data["variables"] = variables return await self._make_request("POST", self.nerdgraph_url, json=data)