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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Execute an NRQL query' implies a read-only operation that might fetch data, but it doesn't specify whether this requires authentication, has rate limits, returns paginated results, or handles errors. For a query tool with zero annotation coverage, this leaves critical behavioral traits undisclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence 'Execute an NRQL query', which is front-loaded and wastes no words. Every part of the sentence contributes to the core purpose, making it efficient and well-structured for its brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a query execution tool with 2 parameters), no annotations, and an output schema (which helps by defining return values), the description is minimally adequate but incomplete. It states the basic action but misses context like authentication needs, query limitations, or error handling. The output schema reduces the burden, but more behavioral and parametric details would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter details. The description adds no information about parameters beyond what's implied by the tool name. It doesn't explain what 'account_id' or 'nrql' represent, their formats, or examples (e.g., NRQL syntax like 'SELECT * FROM Transaction'). With 2 undocumented parameters, the description fails to compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Execute an NRQL query' states a clear verb ('Execute') and resource ('NRQL query'), providing basic purpose. However, it lacks specificity about what NRQL is (New Relic Query Language) or what kind of data it queries (e.g., metrics, logs, events), and doesn't distinguish from siblings like 'nerdgraph_query' or 'search_entities' that might also query data. This makes it vague but not tautological.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an account ID), compare to siblings like 'nerdgraph_query' for different query types, or specify use cases (e.g., for real-time analytics vs. configuration queries). Without any context, users must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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