Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

nerdgraph_query

Execute custom GraphQL queries to retrieve and manage New Relic monitoring data, including APM metrics, alert policies, dashboards, and infrastructure information.

Instructions

Execute a custom NerdGraph GraphQL query

Input Schema

NameRequiredDescriptionDefault
queryYes
variablesNo

Input Schema (JSON Schema)

{ "properties": { "query": { "title": "Query", "type": "string" }, "variables": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Variables" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • The MCP tool handler function for 'nerdgraph_query'. It checks if the client is initialized, executes the client's nerdgraph_query method with the provided query and variables, and returns the JSON-formatted result or error.
    @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)
  • The NewRelicClient helper method that constructs the GraphQL payload and sends a POST request to the NerdGraph API endpoint using the client's _make_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)
  • The @mcp.tool() decorator registers the nerdgraph_query function as an MCP tool.
    @mcp.tool()

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/piekstra/newrelic-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server