Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

query_nrql

Execute NRQL queries to retrieve monitoring and observability data from New Relic for analysis and insights.

Instructions

Execute an NRQL query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
nrqlYes

Implementation Reference

  • The main MCP tool handler function for 'query_nrql'. It validates client initialization, executes the NRQL query via the NewRelicClient, formats the result as JSON, and handles errors.
    @mcp.tool() async def query_nrql(account_id: str, nrql: str) -> str: """Execute an NRQL query""" if not client: return json.dumps({"error": "New Relic client not initialized"}) try: result = await client.query_nrql(account_id, nrql) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
  • Core helper method in NewRelicClient that executes the NRQL query using NerdGraph GraphQL API. Constructs the GraphQL query and variables, then calls nerdgraph_query.
    async def query_nrql(self, account_id: str, nrql: str) -> Dict[str, Any]: """Execute an NRQL query""" query = """ query($accountId: Int!, $nrql: Nrql!) { actor { account(id: $accountId) { nrql(query: $nrql) { results } } } } """ variables = {"accountId": int(account_id), "nrql": nrql} return await self.nerdgraph_query(query, variables)

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