Skip to main content
Glama
New Relic MCP Server

New Relic MCP Server

New Relic MCP Server

CI Python 3.11+ License: MIT Ruff mypy

A comprehensive Model Context Protocol (MCP) server for New Relic monitoring, observability, and management operations.

Features

Core Monitoring & Observability

  • NRQL Query Execution: Run custom New Relic Query Language queries

  • Application Performance: Real-time performance metrics (response time, throughput, Apdex)

  • Error Monitoring: Error rates, counts, and detailed error analysis

  • Infrastructure Monitoring: Host metrics, CPU, memory, disk usage

  • Incident Management: Recent incidents, violations, and alert status

Dashboard Management

  • Dashboard Operations: Create, read, update, and delete dashboards

  • Widget Management: Add, update, and remove dashboard widgets with rawConfiguration support for dual y-axis, fixed y-axis ranges, legend control, and chart styles

  • Search & Discovery: Find dashboards by name or GUID

  • Visualization Support: Line charts, bar charts, pie charts, tables, billboards

Entity Management

  • Entity Search: Find any New Relic entity (APM apps, hosts, synthetic monitors, browsers) by name, type, domain, or tags

  • Entity Tagging: Add, update, and delete tags on any entity

  • Service Levels: List all SLIs/SLOs with compliance data and objectives

  • Synthetic Monitors: List monitors with status, success rate, and location health; query recent check results

Alert & Notification System

  • Alert Policies: Create and manage alert policies with configurable incident preferences

  • NRQL Conditions: Set up custom alert conditions with thresholds and triggers

  • Notification Destinations: Configure email, Slack, webhook, PagerDuty integrations

  • Notification Channels: Link destinations to specific notification preferences

  • Workflows: Connect alert policies to notification channels with filtering

Deployment Tracking

  • Deployment Markers: Track deployment events and their impact

  • Release Correlation: Correlate performance changes with deployments

Related MCP server: OpsLevel MCP

Installation

Prerequisites

  • Python 3.11+ (recommended: use uv for fast dependency management)

  • New Relic User API Key (not Ingest key)

  • New Relic Account ID

Quick Start

# Clone the repository
git clone <repository-url>
cd mcp-newrelic

# Install dependencies (using uv - recommended)
uv sync

# Or using pip
pip install -e .

# Configure your credentials (see Configuration section below)

Setup

Getting Your Credentials

  1. API Key: Go to New Relic API Keys → Create User API Key

  2. Account ID: Found in your New Relic URL: https://one.newrelic.com/accounts/{ACCOUNT_ID}/...

  3. Region: Use "EU" if your account is on one.eu.newrelic.com, otherwise "US"

MCP Client Integration

Add the server to your MCP client config. You do not need to start the server manually — your MCP client launches it automatically.

{
  "mcpServers": {
    "newrelic": {
      "command": "uv",
      "args": ["run", "python", "/path/to/mcp-newrelic/server.py"],
      "env": {
        "NEW_RELIC_API_KEY": "your-api-key",
        "NEW_RELIC_ACCOUNT_ID": "your-account-id"
      }
    }
  }
}

Where this config lives depends on your client (e.g., ~/.claude.json for Claude Code, claude_desktop_config.json for Claude Desktop, .cursor/mcp.json for Cursor, etc.). Replace /path/to/mcp-newrelic/server.py with the actual path to your clone.

Advanced Configuration

If you need to run the server manually (e.g., for development or debugging), it supports flexible configuration with clear precedence (highest to lowest):

1. Command Line Arguments (Highest Priority)

uv run python server.py \
  --api-key "NRAK-your-api-key" \
  --account-id "your-account-id" \
  --region "US"

2. JSON Configuration File

# Copy and edit the example config
cp newrelic-config.json.example config/newrelic-config.json

# Run with config file
uv run python server.py --config config/newrelic-config.json

Example newrelic-config.json:

{
  "api_key": "NRAK-your-api-key",
  "account_id": "your-account-id",
  "region": "US",
  "timeout": 30
}

3. Environment Variables (Lowest Priority)

export NEW_RELIC_API_KEY="NRAK-your-api-key"
export NEW_RELIC_ACCOUNT_ID="your-account-id"
export NEW_RELIC_REGION="US"  # US or EU
export NEW_RELIC_TIMEOUT="30"

## Available Tools

### NRQL & Monitoring
- **`query_nrql`**: Execute custom NRQL queries with full flexibility
- **`get_app_performance`**: Application performance metrics (avg/p95 response time, throughput, Apdex)
- **`get_app_errors`**: Error metrics, counts, and error analysis
- **`get_incidents`**: Recent incidents with time filtering
- **`get_infrastructure_hosts`**: Infrastructure host metrics (CPU, memory, disk)
- **`get_alert_violations`**: Recent alert violations and status
- **`get_deployments`**: Deployment markers and impact analysis

### Dashboard Management
- **`get_dashboards`**: List and search dashboards with filtering
- **`search_all_dashboards`**: Advanced dashboard search with local filtering
- **`get_dashboard_widgets`**: Retrieve all widgets from a dashboard
- **`create_dashboard`**: Create new dashboards for monitoring
- **`delete_dashboard`**: Delete a dashboard by GUID
- **`add_widget_to_dashboard`**: Add custom NRQL-based widgets
- **`update_widget`**: Update existing dashboard widgets
- **`delete_widget`**: Remove widgets from dashboards

### Entity Management
- **`entity_search`**: Search for any entity by name, type (APPLICATION, HOST, MONITOR, KEY_TRANSACTION), or domain (APM, INFRA, SYNTH, BROWSER, EXT). Supports `limit` (default 25, max 200) and `minimal_output` to reduce response size.
- **`get_entity`**: Look up a single entity by GUID with full details (name, type, account, tags, permalink, type-specific metadata)
- **`decode_entity_guid`**: Decode a base64-encoded entity GUID to reveal account ID, domain, entity type, and domain ID without an API call
- **`get_entity_tags`**: Get all tags for an entity by GUID
- **`add_tags_to_entity`**: Add or update key-value tags on an entity
- **`replace_tags_on_entity`**: Replace all tags on an entity (overwrites existing)
- **`delete_tags_from_entity`**: Remove tag keys from an entity
- **`delete_tag_values`**: Delete specific tag key-value pairs from an entity
- **`list_service_levels`**: List all SLIs/SLOs with compliance data and objectives
- **`list_synthetic_monitors`**: List all synthetic monitors with status, success rate, and location health
- **`get_synthetic_results`**: Get recent pass/fail check results per location for a specific monitor

### Alert & Notification Management
- **`create_alert_policy`**: Create alert policies with incident preferences
- **`update_alert_policy`**: Update an existing alert policy
- **`delete_alert_policy`**: Delete an alert policy by ID
- **`create_nrql_condition`**: Create NRQL-based alert conditions
- **`update_nrql_condition`**: Update an existing NRQL alert condition
- **`delete_nrql_condition`**: Delete a NRQL alert condition by ID
- **`create_notification_destination`**: Set up notification endpoints (email, Slack, webhook, PagerDuty)
- **`delete_notification_destination`**: Delete a notification destination by ID
- **`create_notification_channel`**: Create notification channels
- **`create_workflow`**: Connect alerts to notifications with filtering
- **`delete_workflow`**: Delete a workflow by ID
- **`list_alert_policies`**: List all alert policies
- **`list_alert_conditions`**: List alert conditions with optional filters by policy, name, or NRQL query
- **`list_notification_destinations`**: List all notification destinations
- **`list_notification_channels`**: List all notification channels
- **`list_workflows`**: List all alert workflows

## MCP Resources

Access structured data through these MCP resources:

- **`newrelic://applications`**: Complete list of monitored applications
- **`newrelic://incidents/recent`**: Recent incidents and alert summary
- **`newrelic://dashboards`**: Dashboard metadata and widgets
- **`newrelic://alerts/policies`**: Alert policies and configurations
- **`newrelic://alerts/conditions`**: Alert conditions across all policies
- **`newrelic://alerts/workflows`**: Workflow configurations and notifications

## Architecture

### Design
- **Strategy Pattern**: Tool handlers using pluggable strategy implementations
- **Composition**: `NewRelicClient` composes specialized sub-clients (`monitoring`, `alerts`, `dashboards`, `entities`) instead of using multiple inheritance
- **Configuration**: Hierarchical config (CLI > file > env vars) with validation
- **Error Handling**: Typed `ApiError` dataclass for consistent error propagation
- **Pagination**: Cursor-based pagination for NerdGraph queries (entity search, alert policies, conditions, service levels, synthetic monitors)

### Key Components
- **`NewRelicClient`**: Unified client composing all specialized sub-clients
- **`AlertsClient`**: Alert policies, conditions, and notification management
- **`DashboardsClient`**: Dashboard and widget operations
- **`EntitiesClient`**: Entity search, tagging, service levels, and synthetic monitors
- **`MonitoringClient`**: NRQL queries and performance monitoring
- **`ToolHandlers`**: Strategy-based dispatcher for MCP tool calls
- **`ResourceHandlers`**: MCP resource operations and data formatting

## Docker Support

### Quick Docker Run
```bash
docker build -t newrelic-mcp-server .

docker run -e NEW_RELIC_API_KEY=your-key \
           -e NEW_RELIC_ACCOUNT_ID=your-id \
           newrelic-mcp-server
# Setup environment
cp .env.example .env
# Edit .env with your New Relic credentials

# Build and run
docker-compose up --build

# Run in background
docker-compose up -d --build

Production Deployment

The Docker image uses:

  • Multi-stage build for optimized image size

  • Non-root user for security

  • Volume mounts for configuration and logs

  • Health checks for container monitoring

Development

Development Setup

# Install development dependencies
uv sync --dev

# Install pre-commit hooks
uv run pre-commit install

# Run quality checks
uv run ruff check .          # Linting
uv run ruff format .         # Formatting  
uv run mypy newrelic_mcp/    # Type checking
uv run pylint newrelic_mcp/  # Additional analysis

Code Quality

This project maintains high code quality with:

  • Ruff: Fast linting and formatting

  • MyPy: Static type checking

  • Pylint: Additional code analysis

  • Pre-commit hooks: Automated quality checks

  • Comprehensive type annotations: Full type coverage

Testing

# Run all tests
uv run pytest tests/

# Run with verbose output
uv run pytest tests/ -v

For detailed development information, see DEVELOPMENT.md.

Example Usage

Complete Alert Setup Workflow

# 1. Create alert policy
create_alert_policy(name="High CPU Usage Policy")

# 2. Create NRQL condition  
create_nrql_condition(
    policy_id="policy-id-from-step-1",
    name="High CPU Alert",
    nrql_query="SELECT average(cpuPercent) FROM SystemSample",
    threshold=80
)

# 3. Create notification destination
create_notification_destination(
    name="Team Email",
    type="EMAIL", 
    properties={"email": "alerts@company.com"}
)

# 4. Create notification channel
create_notification_channel(
    name="CPU Alert Channel",
    destination_id="destination-id-from-step-3",
    type="EMAIL"
)

# 5. Create workflow
create_workflow(
    name="CPU Alert Workflow",
    channel_ids=["channel-id-from-step-4"]
)

Requirements

  • Python: 3.11 or higher

  • New Relic API Key: User API key (starts with NRAK- or NRAA-)

  • New Relic Account: Valid account with appropriate permissions

  • Dependencies: Managed automatically with uv or pip

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please:

  1. Read DEVELOPMENT.md for setup instructions

  2. Follow the established code style and quality standards

  3. Add tests for new functionality

  4. Update documentation as needed

Support

Available Tools

45 tools
add_tags_to_entityB

Add or update tags on a New Relic entity. Tags are key-value pairs.

Inputs: guid (required), tags (required), account_id.

add_widget_to_dashboardA

Add a widget to an existing dashboard (requires dashboard GUID and widget configuration).

Use the optional raw_configuration parameter to control advanced chart display settings. When provided, it is sent as rawConfiguration to NerdGraph and takes precedence over the typed configuration. The raw_configuration object should include nrqlQueries plus any display options.

IMPORTANT: nrqlQueries uses accountIds (array) not accountId (scalar): "nrqlQueries": [{"accountIds": [123456], "query": "SELECT ..."}] This is auto-populated from widget_query if omitted.

Fixed Y-Axis Range (left axis): {"yAxisLeft": {"min": 0, "max": 500, "zero": false}}

Dual Y-Axis (second axis on right): IMPORTANT: dual y-axis requires the COMPLETE rawConfiguration (not just yAxisRight). NR automatically appends an aggregation suffix to series names: percentile() → " (99%)", average() → no suffix. The alias in the query should NOT include the suffix — NR adds it. Use the rendered name in series[].name. Example — query alias is 'My Series', NR renders it as 'My Series (99%)' for percentile():

{
  "nrqlQueries": [{"accountIds": [123456], "query": "SELECT count(*) AS 'Left', percentile(duration, 99) AS 'My Series' FROM ... TIMESERIES"}],
  "chartStyles": {"lineInterpolation": "linear"},
  "facet": {"showOtherSeries": false},
  "legend": {"enabled": true},
  "markers": {"displayedTypes": {"criticalViolations": false, "deployments": true, "relatedDeployments": true, "warningViolations": false}},
  "platformOptions": {"ignoreTimeRange": false},
  "thresholds": {"isLabelVisible": true},
  "yAxisLeft": {"zero": true},
  "yAxisRight": {"zero": true, "series": [{"name": "My Series (99%)"}]}
}

Hide Legend: {"legend": {"enabled": false}}

Facet - show/hide Other series: {"facet": {"showOtherSeries": true}}

Ignore dashboard time picker: {"platformOptions": {"ignoreTimeRange": true}}

Threshold label visibility (shows/hides threshold labels on chart): {"thresholds": {"isLabelVisible": true}}

Chart line style: {"chartStyles": {"lineInterpolation": "linear"}} (or "step", "smooth")

Deployment markers: {"markers": {"displayedTypes": {"deployments": true, "relatedDeployments": true, "criticalViolations": false, "warningViolations": false}}}

Combined example (fixed range + no legend):

{
  "nrqlQueries": [{"accountIds": [123456], "query": "SELECT count(*) FROM Log TIMESERIES"}],
  "yAxisLeft": {"min": 0, "max": 1000, "zero": true},
  "legend": {"enabled": false}
}

Note: logarithmic scale is not supported by New Relic for line/area charts.

Inputs: widget_query (required), widget_title (required), dashboard_guid (required), widget_type, +1 more.

create_alert_policyC

Create a new alert policy

Inputs: name (required), incident_preference.

create_dashboardA

Create a new New Relic dashboard

Inputs: name (required), description.

create_muting_ruleA

Create a muting rule to suppress alert notifications during scheduled windows. Use conditions to match specific policies, condition names, or entity attributes. Use schedule for recurring windows (DAILY, WEEKLY). Condition attributes: policyId, policyName, conditionId, conditionName, entity.name, entity.type.

Inputs: name (required), conditions (required), enabled, schedule, +2 more.

create_notification_channelB

Create a notification channel linked to a destination

Inputs: name (required), type (required), destination_id (required), product, +1 more.

create_notification_destinationC

Create a notification destination (email, webhook, Slack, etc.)

Inputs: name (required), type (required), properties (required).

create_nrql_conditionB

Create a NRQL alert condition

Inputs: name (required), policy_id (required), threshold (required), nrql_query (required), +5 more.

create_workflowC

Create a workflow to connect alert policies to notification channels

Inputs: name (required), channel_ids (required), enabled, filter_name, +1 more.

decode_entity_guidA

Decode a New Relic entity GUID (base64-encoded) to reveal its components: account ID, domain (APM, EXT, INFRA, etc.), entity type (APPLICATION, KEY_TRANSACTION, HOST, etc.), and domain ID. Useful for understanding what an entity GUID refers to without making an API call.

Inputs: guid (required).

delete_alert_policyB

Delete an alert policy by ID

Inputs: policy_id (required).

delete_dashboardB

Delete a dashboard by GUID

Inputs: dashboard_guid (required).

delete_muting_ruleB

Delete a muting rule by ID

Inputs: rule_id (required).

delete_notification_destinationA

Delete a notification destination by ID

Inputs: destination_id (required).

delete_nrql_conditionA

Delete a NRQL alert condition by ID

Inputs: condition_id (required).

delete_tags_from_entityA

Delete tag keys (and all their values) from a New Relic entity.

Inputs: guid (required), tag_keys (required), account_id.

delete_tag_valuesA

Delete specific tag key-value pairs from an entity (keeps the key if other values remain).

Inputs: guid (required), tag_values (required), account_id.

delete_widgetB

Delete a widget from a dashboard

Inputs: page_guid (required), widget_id (required).

delete_workflowB

Delete a workflow by ID

Inputs: workflow_id (required), delete_channels.

get_alert_violationsC

Get recent alert violations and incidents

Inputs: hours.

get_app_errorsC

Get error metrics for a specific application

Inputs: app_name (required), hours.

get_app_performanceC

Get performance metrics for a specific application

Inputs: app_name (required), hours.

get_dashboardsA

Get New Relic dashboards (max 200 due to API limits). Use search parameter to find specific dashboards efficiently.

Inputs: guid, limit, search.

get_dashboard_widgetsA

Get all widgets from a dashboard with their details and IDs

Inputs: dashboard_guid (required).

get_deploymentsC

Get deployment markers and their impact

Inputs: hours, app_name.

get_entityA

Look up a single New Relic entity by its GUID. Returns full details including name, type, domain, alert severity, account info, tags, permalink, and type-specific metadata (language for APM apps, monitor type for synthetics, host metrics for infra). Use entity_search to find GUIDs, or decode_entity_guid to inspect a GUID without an API call.

Inputs: guid (required).

get_entity_tagsA

Get all tags for a New Relic entity by its GUID. Use entity_search to find GUIDs.

Inputs: guid (required), account_id.

get_incidentsC

Get recent incidents from New Relic

Inputs: hours.

get_infrastructure_hostsC

Get infrastructure hosts and their metrics

Inputs: hours.

get_synthetic_resultsA

Get recent check results for a specific synthetic monitor. Shows pass/fail per location, duration, and error messages. Use list_synthetic_monitors to find monitor GUIDs.

Inputs: monitor_guid (required), hours, account_id.

list_alert_conditionsB

List alert conditions with optional filters by policy, name, or NRQL query

Inputs: name, query, policy_id.

list_alert_policiesA

List all alert policies in the account

Inputs: no named parameters.

list_muting_rulesA

List all muting rules in the account with their conditions and schedules

Inputs: no named parameters.

list_notification_channelsB

List all notification channels

Inputs: no named parameters.

list_notification_destinationsB

List all notification destinations

Inputs: no named parameters.

list_service_levelsA

List all Service Level Indicators (SLIs/SLOs) for the account. Shows objectives, target percentages, time windows, and the NRQL queries used to measure good/valid events.

Inputs: account_id.

list_synthetic_monitorsA

List all synthetic monitors with their current status, success rate, monitor type (simple, scripted browser, API test, etc.), check period, and location health.

Inputs: account_id.

list_workflowsA

List all alert workflows

Inputs: no named parameters.

query_nrqlA

Execute a NRQL query against New Relic. Common event types: Transaction, TransactionError, Span, Log, Metric, KeyTransaction, ExternalCall, SyntheticCheck, PageView, MobileSession. Tips: Use SINCE X hours/days ago for time ranges (e.g. SINCE 3 hours ago). For high-volume apps, use shorter time windows (1-3 hours) to avoid query timeouts. Use TIMESERIES for trend data over time. Use FACET for grouping results. Prefer uniqueCount() over uniques() for high-cardinality attributes. Use LIMIT to cap result rows (default is 10 for FACET queries). Time range formats: SINCE 1 hour ago, SINCE '2024-01-15 00:00:00', SINCE timestamp.

Inputs: query (required), account_id.

replace_tags_on_entityA

Replace ALL tags on a New Relic entity (overwrites existing tags). Use add_tags_to_entity to append instead.

Inputs: guid (required), tags (required), account_id.

search_all_dashboardsA

Search through dashboards with local filtering (retrieves max 200 from API, then searches locally). Better for complex searches.

Inputs: guid, search.

update_alert_policyB

Update an existing alert policy (name and/or incident preference)

Inputs: policy_id (required), name, incident_preference.

update_nrql_conditionA

Update an existing NRQL alert condition

Inputs: condition_id (required), name, enabled, priority, +5 more.

update_widgetA

Update an existing widget on a dashboard.

Use the optional raw_configuration parameter to control advanced chart display settings. When provided, it is sent as rawConfiguration to NerdGraph and takes precedence over the typed configuration. The raw_configuration object should include nrqlQueries plus any display options.

IMPORTANT: nrqlQueries uses accountIds (array) not accountId (scalar): "nrqlQueries": [{"accountIds": [123456], "query": "SELECT ..."}] This is auto-populated from widget_query if omitted.

Fixed Y-Axis Range (left axis): {"yAxisLeft": {"min": 0, "max": 500, "zero": false}}

Dual Y-Axis (second axis on right): IMPORTANT: requires the COMPLETE rawConfiguration. NR appends aggregation suffix to series names automatically (percentile() → " (99%)", average() → no suffix). Query alias should NOT include the suffix. See add_widget_to_dashboard for the full dual y-axis example.

Hide Legend: {"legend": {"enabled": false}}

Facet - show/hide Other series: {"facet": {"showOtherSeries": true}}

Ignore dashboard time picker: {"platformOptions": {"ignoreTimeRange": true}}

Threshold label visibility: {"thresholds": {"isLabelVisible": true}}

Chart line style: {"chartStyles": {"lineInterpolation": "linear"}} (or "step", "smooth")

Note: logarithmic scale is not supported by New Relic for line/area charts.

Inputs: page_guid (required), widget_id (required), widget_type, widget_query, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 45 tools

    Disambiguation3/5

    Most tools target distinct resource-action pairs, but get_incidents and get_alert_violations clearly overlap (the latter explicitly includes incidents), and get_dashboards vs search_all_dashboards have murky boundaries since both retrieve the same 200-dashboard limit and both support searching. The descriptions do not effectively differentiate these pairs.

    Naming Consistency4/5

    The vast majority follow a clean verb_noun convention: get_*, list_*, create_*, update_*, delete_*. Minor deviations exist such as entity_search vs search_all_dashboards (noun-first vs verb-first) and decode_entity_guid, but the overall pattern is predictable and readable.

    Tool Count2/5

    45 tools is well into the overcrowded range, especially for a single platform. The surface includes roughly 13 alerting tools, 9 dashboard tools, and 6 entity-tag tools, indicating sub-domains that could be consolidated without losing capability.

    Completeness3/5

    Dashboards, alert policies, NRQL conditions, and entity tags have solid CRUD coverage, and query_nrql acts as a powerful escape hatch. However, notification destinations/channels, workflows, and muting rules all lack update operations, and synthetics and SLOs are read-only, leaving agents with delete-and-recreate workarounds and asymmetric capabilities.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables Large Language Models like Claude to query New Relic logs and metrics using NRQL queries.
      1
      28
      -
    • A
      license
      A
      quality
      D
      maintenance
      A comprehensive MCP server providing over 26 tools for querying, monitoring, and analyzing NewRelic data through NRQL queries and entity management. It enables interaction with NewRelic's NerdGraph API for managing alerts, logs, and incidents directly within Claude Code sessions.
      24
      2
      MIT