New Relic MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/xelber/newrelic-mcp.git
cd newrelic-mcp
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "NEW_RELIC_API_KEY=${NEW_RELIC_API_KEY}" -e "NEW_RELIC_ACCOUNT_ID=${NEW_RELIC_ACCOUNT_ID}" newrelic-mcp -- node "<FULL_PATH_TO_NEWRELIC_MCP>/dist/index.js"

Replace <FULL_PATH_TO_NEWRELIC_MCP>/dist/index.js with the actual folder you prepared in step 1.

Required:NEW_RELIC_API_KEYNEW_RELIC_ACCOUNT_ID
README.md

Access New Relic logs and APM data through the NerdGraph API

New Relic MCP Server

A Model Context Protocol (MCP) server that provides AI agents like Claude Code with access to New Relic logs and APM data through the NerdGraph API.

Features

Log Tools

  • query-logs: Execute custom NRQL queries against New Relic logs
  • search-logs: Search logs with keyword filtering and optional attributes
  • get-recent-logs: Retrieve the most recent log entries

APM Tools

  • query-apm: Execute custom NRQL queries against APM data (transactions, metrics, etc.)
  • get-apm-metrics: Get application performance metrics (response time, throughput, error rate, Apdex)
  • get-transaction-traces: Retrieve transaction traces with optional filtering for slow transactions

Prerequisites

Installation

  1. Clone this repository:
git clone https://github.com/xelber/newrelic-mcp.git
cd newrelic-mcp
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Configuration

Set the following environment variables:

export NEW_RELIC_API_KEY="your-user-api-key"
export NEW_RELIC_ACCOUNT_ID="your-account-id"

Or create a .env file in the project root (not committed to git):

NEW_RELIC_API_KEY=your-user-api-key
NEW_RELIC_ACCOUNT_ID=your-account-id

Usage with Claude Desktop and Claude Code

Step 1: Configure in Claude Desktop

First, add this server to your Claude Desktop configuration file:

Configuration file location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Add the following configuration:

{
  "mcpServers": {
    "newrelic": {
      "command": "node",
      "args": ["/absolute/path/to/newrelic-mcp/dist/index.js"],
      "env": {
        "NEW_RELIC_API_KEY": "your-user-api-key",
        "NEW_RELIC_ACCOUNT_ID": "your-account-id"
      }
    }
  }
}

Important:

  • Replace /absolute/path/to/newrelic-mcp with the actual path to this project
  • Replace your-user-api-key with your New Relic User API Key
  • Replace your-account-id with your New Relic Account ID

Example (macOS):

{
  "mcpServers": {
    "newrelic": {
      "command": "node",
      "args": ["/Users/yourusername/newrelic-mcp/dist/index.js"],
      "env": {
        "NEW_RELIC_API_KEY": "NRAK-XXXXXXXXXXXXXXXXXXXXX",
        "NEW_RELIC_ACCOUNT_ID": "1234567"
      }
    }
  }
}

After updating the configuration:

  1. Save the file
  2. Restart Claude Desktop completely (Quit and reopen)
  3. Look for the 🔌 icon in Claude Desktop to verify the MCP server is connected

Step 2: Import into Claude Code

Once configured in Claude Desktop, you can import the server into Claude Code:

  1. Open Claude Code in your terminal or IDE
  2. The MCP server will be automatically available if you have Claude Desktop configured
  3. Alternatively, you can add it directly to Claude Code's MCP settings

For Claude Code direct configuration, create/edit the file at:

  • macOS/Linux: ~/.config/claude-code/mcp_settings.json

With the same configuration format as above.

Available Tools

1. query-logs

Execute custom NRQL queries for complex filtering and aggregations.

Example queries:

query-logs with query: "SELECT * FROM Log WHERE message LIKE '%error%' SINCE 1 HOUR AGO LIMIT 100"

query-logs with query: "SELECT count(*) FROM Log WHERE level = 'ERROR' FACET host SINCE 1 DAY AGO"

query-logs with query: "SELECT * FROM Log WHERE service.name = 'api-server' AND response.status >= 500 SINCE 30 MINUTES AGO"

2. search-logs

Simplified search with keyword and attribute filtering.

Parameters:

  • keywords (optional): Text to search for in log messages
  • timeRange (default: "1 HOUR AGO"): Time range for the search
  • limit (default: 100): Maximum number of results
  • attributes (optional): Key-value pairs for filtering

Example:

search-logs with keywords: "database timeout", timeRange: "2 HOURS AGO", limit: 50

search-logs with keywords: "authentication failed", attributes: { "service.name": "auth-service" }

3. get-recent-logs

Quick access to the most recent log entries.

Parameters:

  • limit (default: 50): Number of recent entries
  • timeRange (default: "1 HOUR AGO"): Time window to search

Example:

get-recent-logs with limit: 100

get-recent-logs with limit: 25, timeRange: "30 MINUTES AGO"

4. query-apm

Execute custom NRQL queries against APM data for advanced analysis.

Example queries:

query-apm with query: "SELECT average(duration) FROM Transaction WHERE appName = 'MyApp' SINCE 1 HOUR AGO"

query-apm with query: "SELECT count(*) FROM Transaction WHERE error

Tools (6)

query-logsExecute custom NRQL queries against New Relic logs.
search-logsSearch logs with keyword filtering and optional attributes.
get-recent-logsRetrieve the most recent log entries.
query-apmExecute custom NRQL queries against APM data.
get-apm-metricsGet application performance metrics like response time, throughput, and error rate.
get-transaction-tracesRetrieve transaction traces with optional filtering for slow transactions.

Environment Variables

NEW_RELIC_API_KEYrequiredYour New Relic User API Key
NEW_RELIC_ACCOUNT_IDrequiredYour New Relic Account ID

Configuration

claude_desktop_config.json
{"mcpServers": {"newrelic": {"command": "node", "args": ["/absolute/path/to/newrelic-mcp/dist/index.js"], "env": {"NEW_RELIC_API_KEY": "your-user-api-key", "NEW_RELIC_ACCOUNT_ID": "your-account-id"}}}}

Try it

Show me the most recent error logs from the last 30 minutes.
Run a NRQL query to find the average response time for my application over the last hour.
Search for logs containing 'database timeout' from the last 2 hours.
Get the latest transaction traces for my service to identify slow requests.

Frequently Asked Questions

What are the key features of New Relic MCP Server?

Execute custom NRQL queries for logs and APM data. Search logs with keyword and attribute filtering. Retrieve recent log entries with configurable time ranges. Fetch application performance metrics including response time and error rates. Access transaction traces for performance debugging.

What can I use New Relic MCP Server for?

Troubleshooting production errors by querying specific log patterns. Analyzing application performance trends using APM metrics. Identifying slow transaction traces to optimize code performance. Automating log analysis during incident response.

How do I install New Relic MCP Server?

Install New Relic MCP Server by running: git clone https://github.com/xelber/newrelic-mcp.git && cd newrelic-mcp && npm install && npm run build

What MCP clients work with New Relic MCP Server?

New Relic MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep New Relic MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare