Skip to main content
Glama
xelber

New Relic MCP Server

by xelber

get-transaction-traces

Retrieve transaction traces from APM with optional filtering for slow transactions to identify performance bottlenecks and slow database queries.

Instructions

Get transaction traces from APM, optionally filtering for slow transactions. Useful for identifying performance bottlenecks and slow database queries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameNoApplication name to filter transactions
minDurationNoMinimum transaction duration in seconds to filter slow transactions
limitNoMaximum number of transaction traces to return
timeRangeNoTime range to search within1 HOUR AGO

Implementation Reference

  • The getTransactionTraces method executes NRQL queries to fetch Transaction traces from New Relic, optionally filtered by appName, minDuration, limit, and timeRange. It builds a SELECT query for name, appName, duration, timestamp, error, ordered by duration DESC.
    /**
     * Get transaction traces (slow or all transactions)
     */
    async getTransactionTraces(
      appName?: string,
      minDuration?: number,
      limit: number = 10,
      timeRange: string = '1 HOUR AGO'
    ): Promise<any[]> {
      const conditions: string[] = [];
    
      if (appName) {
        conditions.push(`appName = '${this.escapeLike(appName)}'`);
      }
    
      if (minDuration !== undefined) {
        conditions.push(`duration > ${minDuration}`);
      }
    
      const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')} ` : '';
      const query = `SELECT name, appName, duration, timestamp, error FROM Transaction ${whereClause}SINCE ${timeRange} ORDER BY duration DESC LIMIT ${limit}`;
    
      return this.executeNRQL(query);
    }
  • The case handler for 'get-transaction-traces' in the CallToolRequestSchema handler. It parses input args using GetTransactionTracesInputSchema, calls newRelicClient.getTransactionTraces(), and returns results as JSON text.
    case 'get-transaction-traces': {
      const { appName, minDuration, limit, timeRange } = GetTransactionTracesInputSchema.parse(args);
      const results = await newRelicClient.getTransactionTraces(appName, minDuration, limit, timeRange);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(results, null, 2),
          },
        ],
      };
    }
  • Zod schema defining input validation for get-transaction-traces: appName (optional string), minDuration (optional number), limit (number, default 10), timeRange (string, default '1 HOUR AGO').
    export const GetTransactionTracesInputSchema = z.object({
      appName: z.string().optional().describe('Application name to filter transactions'),
      minDuration: z.number().optional().describe('Minimum transaction duration in seconds to filter slow transactions'),
      limit: z.number().default(10).describe('Maximum number of transaction traces to return'),
      timeRange: z.string().default('1 HOUR AGO').describe('Time range to search within'),
    });
  • src/index.ts:173-201 (registration)
    Registration of the 'get-transaction-traces' tool in ListToolsRequestSchema handler, including name, description, and inputSchema definition.
    {
      name: 'get-transaction-traces',
      description:
        'Get transaction traces from APM, optionally filtering for slow transactions. ' +
        'Useful for identifying performance bottlenecks and slow database queries.',
      inputSchema: {
        type: 'object',
        properties: {
          appName: {
            type: 'string',
            description: 'Application name to filter transactions',
          },
          minDuration: {
            type: 'number',
            description: 'Minimum transaction duration in seconds to filter slow transactions',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of transaction traces to return',
            default: 10,
          },
          timeRange: {
            type: 'string',
            description: 'Time range to search within',
            default: '1 HOUR AGO',
          },
        },
      },
    },
  • The escapeLike helper method used to escape single quotes and percent signs in appName values for NRQL queries.
    private escapeLike(value: string): string {
      return value.replace(/'/g, "\\'").replace(/%/g, '\\%');
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It describes filtering behavior but omits details like authorization requirements, rate limits, or response format. Since it's a read operation, the lack of side effects disclosure is acceptable but not complete.

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?

Two sentences, front-loaded with the core action, no redundant words. Every sentence adds value.

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

Completeness4/5

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

Given 4 parameters and no output schema, the description covers the use case and filtering capability. However, it does not mention pagination or the return structure, leaving some gaps for a complete understanding.

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

Parameters3/5

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

Input schema has 100% description coverage for all 4 parameters, so baseline is 3. The description adds 'optionally filtering for slow transactions', which maps to minDuration, but does not provide additional semantics beyond the schema.

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

Purpose4/5

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

The description clearly states the tool retrieves transaction traces from APM and optionally filters for slow ones. It distinguishes from siblings like get-apm-metrics (metrics vs traces) and query-apm (general query), though indirectly.

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

Usage Guidelines3/5

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

The description mentions usefulness for performance bottleneck identification, but lacks explicit when-to-use vs alternatives or when-not-to-use guidance. Sibling tools are not compared.

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

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