Skip to main content

MCP server to execute New Relic NRQL queries via NerdGraph

Project description

New Relic MCP Server

MCP server that executes NRQL queries against New Relic via the NerdGraph GraphQL API.

Tools

  • execute_nrql — Run an NRQL query against a single New Relic account. Parameters: query (required), account_id (optional if NEW_RELIC_ACCOUNT_ID is set), timeout_seconds (optional, 1–70).

Requirements

  • Python 3.10+
  • uv (recommended) or pip
  • A New Relic user API key with NerdGraph access

Environment variables

Variable Required Description
NEW_RELIC_API_KEY Yes New Relic user API key for NerdGraph. Create at one.newrelic.com.
NEW_RELIC_REGION No us (default) or eu for NerdGraph endpoint.
NEW_RELIC_ACCOUNT_ID No Default account ID when not passed to execute_nrql.

Copy .env.example to .env and set NEW_RELIC_API_KEY (and optionally the others).

Install and run

From the project root:

# Install dependencies (with uv)
uv sync

# Run the MCP server (stdio; for Cursor/IDE)
uv run main.py

Or via the script entry point: uv run newrelic-mcp.

For local debugging with HTTP transport:

MCP_TRANSPORT=http uv run main.py

Then connect to http://localhost:8000/mcp (or the printed URL) with the MCP Inspector or another MCP client.

Cursor setup

  1. Open Cursor SettingsFeaturesMCP.
  2. Add a new MCP server; choose stdio.
  3. Set the command to run the server, for example:
    • Command: uv
    • Args: run, main.py (or --directory, /path/to/newrelic-mcp, run, main.py if needed)
    • Cwd: path to this repo (e.g. /Users/you/newrelic-mcp).
  4. Add environment variables (or use a shell that loads .env):
    • NEW_RELIC_API_KEY = your API key
    • Optionally: NEW_RELIC_REGION, NEW_RELIC_ACCOUNT_ID

Example config (in Cursor MCP JSON, if supported):

{
  "mcpServers": {
    "newrelic": {
      "command": "uv",
      "args": ["--directory", "/path/to/newrelic-mcp", "run", "main.py"],
      "env": {
        "NEW_RELIC_API_KEY": "YOUR_API_KEY",
        "NEW_RELIC_REGION": "us"
      }
    }
  }
}

Do not commit .env or any file containing your API key.

Example prompts

Use these in Cursor (or any MCP client) to run NRQL via the New Relic MCP server:

  • Run a simple query:
    "Run this NRQL: SELECT count(*) FROM Transaction SINCE 1 HOUR AGO"

  • Query by account:
    "Execute SELECT average(duration) FROM Transaction FACET name SINCE 1 day ago for account ID 1234567"

  • By Adobe Commerce project:
    "Query New Relic for project abc123: show me transaction errors in the last 24 hours"
    "Get the last 100 logs for project xyz789"
    "List Redis samples for project my-project in the last hour"

  • Explore an entity:
    "What attributes are available on the Log entity? Run a discovery query."
    "Show me one Transaction row so I can see the fields"

  • Aggregations and facets:
    "Count transactions per app name in the last 6 hours"
    "Average response time by transaction name for the last day"

  • Time range:
    "Run: SELECT * FROM Log WHERE message IS NOT NULL SINCE 2 days ago LIMIT 50"

Set NEW_RELIC_ACCOUNT_ID in the MCP config (or pass it in the prompt) when you are not using an Adobe Commerce project ID; the agent can resolve project ID → account ID when needed.

NRQL and rate limits

  • Queries must be valid NRQL (e.g. SELECT count(*) FROM Transaction SINCE 1 HOUR AGO).
  • New Relic enforces NRQL rate limits. This server does not retry; failed requests surface as tool errors.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newrelic_mcp-0.1.0.tar.gz (51.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

newrelic_mcp-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file newrelic_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: newrelic_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 51.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for newrelic_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58abf54a7bebb15f7574b3b68133fb6c150f77c59b23e3df70cc806b6fbc5722
MD5 1036081c6c2b81659aef90b9f2fb6e36
BLAKE2b-256 3a08484f6ca8aa735d0cbc57292b5716bd3306320cc8d5d58a5ea57612113944

See more details on using hashes here.

File details

Details for the file newrelic_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: newrelic_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for newrelic_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cc2106250d822f9abf8075ff1a29990146bbd5bab707cf828a0a801a164bac9
MD5 1cdbbdfbdbdd98a6a74e0b08b647e57e
BLAKE2b-256 c417f5fb3f4493229c8dd4add8f7f9de6b339622184431d10d60bd6a4c387a03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page