npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@savvagent/mcp-newrelic

v1.0.1

Published

Savvagent New Relic MCP integration - Connect feature flags with New Relic APM and monitoring

Readme

@savvagent/mcp-newrelic

New Relic MCP integration for Savvagent - Connect feature flags with New Relic APM and monitoring.

Installation

npm install @savvagent/mcp-newrelic
# or
pnpm add @savvagent/mcp-newrelic

Quick Start

import express from 'express';
import { NewRelicMCPServer } from '@savvagent/mcp-newrelic';
import { createHttpHandler } from '@savvagent/mcp-sdk';

const app = express();
app.use(express.json());

const mcpServer = new NewRelicMCPServer(
  {
    name: 'my-newrelic-server',
    version: '1.0.0',
  },
  {
    apiKey: process.env.NEW_RELIC_API_KEY!,
    accountId: process.env.NEW_RELIC_ACCOUNT_ID!,
    region: 'US', // or 'EU'
  }
);

// Create handler with Bearer token authentication
const handler = createHttpHandler(mcpServer, {
  auth: { token: process.env.MCP_AUTH_TOKEN! },
});

// Mount on /mcp endpoint (StreamableHTTP transport)
app.post('/mcp', handler);

await mcpServer.initialize();
app.listen(3006);

Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | apiKey | string | Yes | New Relic User API key | | accountId | string | Yes | New Relic Account ID | | region | 'US' | 'EU' | No | New Relic region (default: 'US') |

Getting Your Credentials

  1. API Key: Go to New Relic API Keys and create a User key
  2. Account ID: Found in the URL when logged into New Relic (e.g., https://one.newrelic.com/nr1-core?account=12345)

Available Tools

get_errors

Get APM error events from New Relic.

{
  "method": "tools/call",
  "params": {
    "name": "get_errors",
    "arguments": {
      "app_name": "my-app",
      "time_range": "1h",
      "limit": 100
    }
  }
}

run_nrql

Execute a NRQL query against New Relic data.

{
  "method": "tools/call",
  "params": {
    "name": "run_nrql",
    "arguments": {
      "query": "SELECT count(*) FROM Transaction SINCE 1 hour ago FACET appName"
    }
  }
}

get_apm_metrics

Get APM metrics for an application (throughput, response time, error rate).

{
  "method": "tools/call",
  "params": {
    "name": "get_apm_metrics",
    "arguments": {
      "app_name": "my-app",
      "time_range": "1h"
    }
  }
}

get_applications

List APM applications with health status.

{
  "method": "tools/call",
  "params": {
    "name": "get_applications",
    "arguments": {
      "filter": "production"
    }
  }
}

get_alerts

Get alert incidents and violations.

{
  "method": "tools/call",
  "params": {
    "name": "get_alerts",
    "arguments": {
      "status": "open",
      "priority": "critical",
      "time_range": "24h"
    }
  }
}

get_transactions

Get transaction performance data.

{
  "method": "tools/call",
  "params": {
    "name": "get_transactions",
    "arguments": {
      "app_name": "my-app",
      "time_range": "1h",
      "limit": 20
    }
  }
}

get_infrastructure

Get infrastructure host metrics.

{
  "method": "tools/call",
  "params": {
    "name": "get_infrastructure",
    "arguments": {
      "host_filter": "prod",
      "time_range": "1h"
    }
  }
}

get_synthetics

Get synthetic monitoring results.

{
  "method": "tools/call",
  "params": {
    "name": "get_synthetics",
    "arguments": {
      "monitor_name": "Homepage",
      "status": "FAILED",
      "time_range": "24h"
    }
  }
}

get_service_health

Get health overview of APM applications.

{
  "method": "tools/call",
  "params": {
    "name": "get_service_health",
    "arguments": {
      "app_name": "my-app",
      "time_range": "1h"
    }
  }
}

Authentication

This server uses Bearer token authentication. Include the token in requests:

curl -X POST http://localhost:3006/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

MCP Protocol

This server implements the Model Context Protocol using StreamableHTTP transport:

  • Endpoint: POST /mcp
  • Protocol: JSON-RPC 2.0
  • Authentication: Bearer token

Standard MCP Methods

| Method | Description | |--------|-------------| | initialize | Initialize the MCP session | | tools/list | List available tools | | tools/call | Execute a tool |

Example Requests

List Tools

curl -X POST http://localhost:3006/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/list",
    "id": 1
  }'

Get Service Health

curl -X POST http://localhost:3006/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "get_service_health",
      "arguments": {}
    },
    "id": 2
  }'

Run Custom NRQL Query

curl -X POST http://localhost:3006/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-token" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "run_nrql",
      "arguments": {
        "query": "SELECT average(duration) FROM Transaction SINCE 1 hour ago TIMESERIES"
      }
    },
    "id": 3
  }'

Health Check

The server provides a health check endpoint:

curl http://localhost:3006/health

Response:

{
  "status": "ok",
  "version": "1.0.0",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "details": {
    "accountId": "12345",
    "region": "US",
    "connected": true
  }
}

Running the Example

# Set environment variables
export NEW_RELIC_API_KEY="NRAK-XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
export NEW_RELIC_ACCOUNT_ID="12345"
export NEW_RELIC_REGION="US"
export MCP_AUTH_TOKEN="your-secret-token"

# Run the example server
pnpm example

License

MIT