loading…
Search for a command to run...
loading…
Enables AI agents to access New Relic logs and APM data through the NerdGraph API. It allows users to execute NRQL queries, retrieve application performance met
Enables AI agents to access New Relic logs and APM data through the NerdGraph API. It allows users to execute NRQL queries, retrieve application performance metrics, and analyze transaction traces using natural language.
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.
git clone https://github.com/xelber/newrelic-mcp.git
cd newrelic-mcp
npm install
npm run build
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
First, add this server to your Claude Desktop configuration file:
Configuration file location:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonAdd 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:
/absolute/path/to/newrelic-mcp with the actual path to this projectyour-user-api-key with your New Relic User API Keyyour-account-id with your New Relic Account IDExample (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:
Once configured in Claude Desktop, you can import the server into Claude Code:
For Claude Code direct configuration, create/edit the file at:
~/.config/claude-code/mcp_settings.jsonWith the same configuration format as above.
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"
Simplified search with keyword and attribute filtering.
Parameters:
keywords (optional): Text to search for in log messagestimeRange (default: "1 HOUR AGO"): Time range for the searchlimit (default: 100): Maximum number of resultsattributes (optional): Key-value pairs for filteringExample:
search-logs with keywords: "database timeout", timeRange: "2 HOURS AGO", limit: 50
search-logs with keywords: "authentication failed", attributes: { "service.name": "auth-service" }
Quick access to the most recent log entries.
Parameters:
limit (default: 50): Number of recent entriestimeRange (default: "1 HOUR AGO"): Time window to searchExample:
get-recent-logs with limit: 100
get-recent-logs with limit: 25, timeRange: "30 MINUTES AGO"
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 IS true FACET appName SINCE 1 DAY AGO"
query-apm with query: "SELECT percentile(duration, 95) FROM Transaction WHERE transactionType = 'Web' SINCE 30 MINUTES AGO TIMESERIES"
Get comprehensive application performance metrics including response time, throughput, error rate, and Apdex score.
Parameters:
appName (optional): Filter metrics for a specific application. If not provided, returns aggregated metrics across all applications.timeRange (default: "1 HOUR AGO"): Time range for metricsmetrics (default: ["responseTime", "throughput", "errorRate"]): Array of metrics to retrieveBehavior:
appName: Returns time-series metrics for the specified applicationappName: Returns aggregated metrics across all applications (not broken down by app)Examples:
get-apm-metrics with appName: "MyApp", timeRange: "2 HOURS AGO"
get-apm-metrics with metrics: ["responseTime", "errorRate", "apdex"]
get-apm-metrics with appName: "EcommerceApp", metrics: ["throughput", "responseTime"], timeRange: "1 DAY AGO"
Note: To get metrics for multiple specific applications, call this tool separately for each application name.
Retrieve transaction traces to identify performance bottlenecks and slow operations.
Parameters:
appName (optional): Filter transactions for a specific applicationminDuration (optional): Minimum transaction duration in seconds to filter slow transactionslimit (default: 10): Maximum number of transaction traces to returntimeRange (default: "1 HOUR AGO"): Time range to searchExamples:
get-transaction-traces with appName: "MyApp", minDuration: 2.0, limit: 20
get-transaction-traces with minDuration: 5.0, timeRange: "30 MINUTES AGO"
get-transaction-traces with appName: "APIService", limit: 50
Run tests:
npm test
Run tests with coverage:
npm run test:coverage
Run tests in watch mode:
npm run test:watch
Run in development mode (builds and starts):
npm run dev
Watch mode for auto-rebuilding:
npm run watch
Build the project:
npm run build
Once configured, you can ask Claude (in Claude Desktop or Claude Code):
Server not showing in Claude Desktop:
dist/index.js is absolute, not relativeView > Developer > Show Logs"Cannot find module" errors:
npm install in the project directorynpm run build to compile TypeScriptdist/ folder exists and contains the compiled files"Configuration error" on startup:
NEW_RELIC_API_KEY and NEW_RELIC_ACCOUNT_ID are set correctly"Failed to query New Relic":
No results returned:
MIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"new-relic-mcp-server": {
"command": "npx",
"args": []
}
}
}