A comprehensive Model Context Protocol (MCP) server for New Relic monitoring, observability, and management operations.
- 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 Operations: Create, read, update, and delete dashboards
- Widget Management: Add, update, and remove dashboard widgets
- Search & Discovery: Find dashboards by name or GUID
- Visualization Support: Line charts, bar charts, pie charts, tables, billboards
- 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 Markers: Track deployment events and their impact
- Release Correlation: Correlate performance changes with deployments
- Python 3.11+ (recommended: use
uv
for fast dependency management) - New Relic User API Key (not Ingest key)
- New Relic Account ID
# 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)
The server supports flexible configuration with clear precedence (highest to lowest):
uv run python server.py \
--api-key "NRAK-your-api-key" \
--account-id "your-account-id" \
--region "US"
# 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,
"rate_limit": 100,
"retry_attempts": 3
}
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"
export NEW_RELIC_RATE_LIMIT="100"
export NEW_RELIC_RETRY_ATTEMPTS="3"
- API Key: Go to New Relic API Keys → Create User API Key
- Account ID: Found in your New Relic URL:
https://one.newrelic.com/accounts/{ACCOUNT_ID}/...
- Region: Use "EU" if your account is on
one.eu.newrelic.com
, otherwise "US"
# Method 1: Environment variables
export NEW_RELIC_API_KEY="your-key"
export NEW_RELIC_ACCOUNT_ID="your-id"
uv run python server.py
# Method 2: Configuration file
uv run python server.py --config config/newrelic-config.json
# Method 3: Command line arguments
uv run python server.py --api-key YOUR_KEY --account-id YOUR_ID
# View all options
uv run python server.py --help
Configure your MCP client to connect to the server. Example for Claude Desktop:
{
"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"
}
}
}
}
query_nrql
: Execute custom NRQL queries with full flexibilityget_app_performance
: Application performance metrics (avg/p95 response time, throughput, Apdex)get_app_errors
: Error metrics, counts, and error analysisget_incidents
: Recent incidents with time filteringget_infrastructure_hosts
: Infrastructure host metrics (CPU, memory, disk)get_alert_violations
: Recent alert violations and statusget_deployments
: Deployment markers and impact analysis
get_dashboards
: List and search dashboards with filteringsearch_all_dashboards
: Advanced dashboard search with local filteringget_dashboard_widgets
: Retrieve all widgets from a dashboardcreate_dashboard
: Create new dashboards for monitoringadd_widget_to_dashboard
: Add custom NRQL-based widgetsupdate_widget
: Update existing dashboard widgetsdelete_widget
: Remove widgets from dashboards
create_alert_policy
: Create alert policies with incident preferencescreate_nrql_condition
: Create NRQL-based alert conditionscreate_notification_destination
: Set up notification endpoints (email, Slack, webhook, PagerDuty)create_notification_channel
: Create notification channelscreate_workflow
: Connect alerts to notifications with filteringlist_alert_policies
: List all alert policieslist_alert_conditions
: List alert conditions by policylist_notification_destinations
: List all notification destinationslist_notification_channels
: List all notification channelslist_workflows
: List all alert workflows
Access structured data through these MCP resources:
newrelic://applications
: Complete list of monitored applicationsnewrelic://incidents/recent
: Recent incidents and alert summarynewrelic://dashboards
: Dashboard metadata and widgetsnewrelic://alerts/policies
: Alert policies and configurationsnewrelic://alerts/conditions
: Alert conditions across all policiesnewrelic://alerts/workflows
: Workflow configurations and notifications
- Strategy Pattern: Tool handlers using pluggable strategy implementations
- Client Layer: Specialized clients for monitoring, alerts, and dashboards
- Configuration Management: Hierarchical config with validation and security
- Utility Modules: Shared code for error handling, GraphQL operations, and formatting
NewRelicClient
: Unified client interface combining all specialized clientsAlertsClient
: Alert policies, conditions, and notification managementDashboardsClient
: Dashboard and widget operationsMonitoringClient
: NRQL queries and performance monitoringToolHandlers
: Strategy-based dispatcher for MCP tool callsResourceHandlers
: MCP resource operations and data formatting
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
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
# 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
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
# Run basic functionality test
uv run python test_server.py
# Test with your credentials
NEW_RELIC_API_KEY=your-key NEW_RELIC_ACCOUNT_ID=your-id uv run python test_server.py
For detailed development information, see DEVELOPMENT.md.
# 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"]
)
- Python: 3.11 or higher
- New Relic API Key: User API key (starts with
NRAK-
orNRAA-
) - New Relic Account: Valid account with appropriate permissions
- Dependencies: Managed automatically with
uv
orpip
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please:
- Read DEVELOPMENT.md for setup instructions
- Follow the established code style and quality standards
- Add tests for new functionality
- Update documentation as needed
- Documentation: Check DEVELOPMENT.md for detailed guides
- Issues: Report bugs and feature requests via GitHub Issues
- New Relic API: Official New Relic API Documentation
- MCP Protocol: Model Context Protocol Specification