Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

query_nrql

Execute NRQL queries to retrieve and analyze New Relic monitoring data for application performance, infrastructure metrics, and business insights.

Instructions

Execute an NRQL query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
nrqlYes

Implementation Reference

  • MCP tool handler function for 'query_nrql'. This is the entry point for the tool, decorated with @mcp.tool(), which registers it in the FastMCP server. It calls the underlying client method and formats the response as JSON.
    @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 class that executes the NRQL query using a NerdGraph GraphQL query. This contains the actual API call logic.
    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