New Relic MCP Tools

May 20, 2025 ยท View on GitHub

This document describes the tools available in the New Relic MCP server.

run-nrql-query

Execute a NRQL query and return the results as datapoints.

Parameters

ParameterTypeRequiredDefaultDescription
querystringYes-NRQL query to execute
timeoutnumberNo30000Query timeout in milliseconds
visualizebooleanNofalseWhether to visualize the results as a Mermaid chart
valueKeystringNo-The key to extract values from for visualization (required if visualize is true)
chartTitlestringNo"NRQL Query Results"The title for the chart
yAxisLabelstringNo"Value"The label for the y-axis

Example

{
  "query": "SELECT count(*) FROM Transaction FACET name LIMIT 10",
  "timeout": 30000,
  "visualize": true,
  "valueKey": "count",
  "chartTitle": "Transaction Counts",
  "yAxisLabel": "Count"
}

query-logs

Query New Relic logs by field and value with customizable parameters.

Parameters

ParameterTypeRequiredDefaultDescription
queryValuestringYes-Value to search for in the specified field
queryFieldstringNo"trace.id"Field name to query on
startTimeRangenumberNo60Start time range in minutes to look back from now
endTimeRangenumberNo0End time range in minutes to look back from now (0 means now)
startTimestampnumberNo-Start timestamp in milliseconds since epoch
endTimestampnumberNonullEnd timestamp in milliseconds since epoch (null means now)
limitnumberNo100Maximum number of logs to return
selectFieldsstring[]No["timestamp", "message", "tag", "userAgent"]Fields to select in the query
additionalConditionsstring[]No[]Additional NRQL where clause conditions

Note: Time range parameters (startTimeRange/endTimeRange) and timestamp parameters (startTimestamp/endTimestamp) cannot be used together. Use either one approach or the other.

Examples

Using Time Range Parameters

{
  "queryValue": "abc123",
  "queryField": "trace.id",
  "startTimeRange": 60,
  "endTimeRange": 0,
  "limit": 100,
  "selectFields": ["timestamp", "message", "tag", "userAgent"],
  "additionalConditions": ["level = 'ERROR'"]
}

Using Timestamp Parameters

{
  "queryValue": "abc123",
  "queryField": "trace.id",
  "startTimestamp": 1715644800000,
  "endTimestamp": null,
  "limit": 100,
  "selectFields": ["timestamp", "message", "tag", "userAgent"]
}

Common Use Cases

  1. Query logs by trace ID (default time range of 60 minutes):

    {
      "queryValue": "abc123"
    }
    
  2. Query logs by request ID:

    {
      "queryValue": "xyz789",
      "queryField": "request_id"
    }
    
  3. Query error logs for a specific service:

    {
      "queryValue": "abc123",
      "additionalConditions": ["service_name = 'api-gateway'", "level = 'ERROR'"]
    }
    
  4. Query logs with a custom time range (last 2 hours):

    {
      "queryValue": "abc123",
      "startTimeRange": 120,
      "endTimeRange": 0
    }
    
  5. Query logs for a specific time window (30-15 minutes ago):

    {
      "queryValue": "abc123",
      "startTimeRange": 30,
      "endTimeRange": 15
    }
    
  6. Query logs using specific timestamps:

    {
      "queryValue": "abc123",
      "startTimestamp": 1715644800000,
      "endTimestamp": 1715648400000
    }