newrelic-mcp-server

newrelic-mcp-server

Provides New Relic observability tools for AI assistants, enabling discovery, data access, alerting, incident response, and performance analytics via natural language queries.

Category
访问服务器

README

New Relic MCP Server

A Model Context Protocol (MCP) server that provides New Relic observability tools for integration with Cursor and other MCP-compatible AI assistants.

Features

This MCP server provides comprehensive New Relic tools organized into the following categories:

Discovery (Entity and Account Management)

  • convert_time_period_to_epoch_ms - Convert time periods to epoch milliseconds
  • get_entity - Fetch entities by GUID or search by name
  • list_related_entities - List related entities (1 hop away)
  • list_available_new_relic_accounts - List all available accounts
  • list_dashboards - List dashboards for an account
  • get_dashboard - Get dashboard details
  • list_entity_types - List all entity types
  • search_entity_with_tag - Search entities by tag

Data Access

  • execute_nrql_query - Execute NRQL queries against NRDB
  • natural_language_to_nrql_query - Convert natural language to NRQL and execute

Alerting

  • list_alert_conditions - List alert conditions for a policy
  • search_incident - Search alert incidents
  • list_alert_policies - List alert policies
  • list_recent_issues - List open issues
  • list_synthetic_monitors - List synthetic monitors

Incident Response

  • analyze_deployment_impact - Analyze deployment performance impact
  • generate_alert_insights_report - Generate alert analysis report
  • generate_user_impact_report - Generate user impact report
  • get_entity_error_groups - Get error groups from Errors Inbox
  • list_change_events - List deployment and config changes

Performance Analytics

  • analyze_entity_logs - Analyze logs for patterns and anomalies
  • analyze_golden_metrics - Analyze throughput, response time, error rate
  • analyze_kafka_metrics - Analyze Kafka consumer lag, throughput
  • analyze_threads - Analyze JVM thread metrics
  • analyze_transactions - Identify slow and error-prone transactions
  • list_garbage_collection_metrics - Get GC and memory metrics
  • list_recent_logs - List recent log entries

Advanced Analysis

  • comprehensive_entity_analysis - Full entity health analysis
  • correlate_metrics_and_events - Correlate metrics with events
  • analyze_service_dependencies - Analyze service dependencies
  • generate_slo_report - Generate SLO compliance report

Prerequisites

  • Python 3.10+ (required by MCP SDK)
  • New Relic account with API access
  • New Relic User API Key

Installation

  1. Clone the repository:

    cd /Users/vickykumar/projects/newrelic-mcp
    
  2. Create and activate a virtual environment (Python 3.10+ required):

    python3.11 -m venv venv  # or python3.10, python3.12, etc.
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Configure environment variables:

    cp env.example .env
    

    Edit .env and set your New Relic credentials:

    NEW_RELIC_API_KEY=NRAK-your-api-key-here
    NEW_RELIC_ACCOUNT_ID=your-account-id
    

Getting Your New Relic API Key

  1. Go to New Relic API Keys
  2. Click "Create a key"
  3. Select "User" as the key type
  4. Give it a name (e.g., "MCP Server")
  5. Copy the key (starts with NRAK-)

Usage with Cursor

Option 1: Add to Cursor MCP Settings (Recommended)

  1. Open Cursor Settings (⌘/Ctrl + ,)
  2. Search for "MCP" or navigate to Features → MCP Servers
  3. Click "Add MCP Server" or edit your ~/.cursor/mcp.json
  4. Add the following configuration:
{
  "mcpServers": {
    "newrelic": {
      "command": "/Users/vickykumar/projects/newrelic-mcp/venv/bin/python",
      "args": ["/Users/vickykumar/projects/newrelic-mcp/server.py"],
      "env": {
        "NEW_RELIC_API_KEY": "NRAK-your-api-key",
        "NEW_RELIC_ACCOUNT_ID": "your-account-id",
        "NEW_RELIC_REGION": "US"
      }
    }
  }
}

Note: Update the paths if your project is located elsewhere.

Option 2: Using the startup script

Create a wrapper script for easier configuration:

#!/bin/bash
# save as: run-newrelic-mcp.sh

export NEW_RELIC_API_KEY="NRAK-your-api-key"
export NEW_RELIC_ACCOUNT_ID="your-account-id"

cd /Users/vickykumar/projects/newrelic-mcp
./venv/bin/python server.py

Then configure Cursor to use this script:

{
  "mcpServers": {
    "newrelic": {
      "command": "/Users/vickykumar/projects/newrelic-mcp/run-newrelic-mcp.sh",
      "args": []
    }
  }
}

Example Queries in Cursor

Once configured, you can ask the AI assistant to:

Discovery

  • "List all my New Relic accounts"
  • "Find all APM applications with the tag environment=production"
  • "Show me the entities related to my payment service"

Data Access

  • "Execute this NRQL query: SELECT count(*) FROM Transaction SINCE 1 hour ago"
  • "Show me errors from the last 30 minutes"
  • "What's the throughput trend for my API?"

Alerting

  • "List all open incidents"
  • "Show me alert policies for my account"
  • "What synthetic monitors are failing?"

Incident Response

  • "Analyze the impact of the last deployment on my checkout service"
  • "Generate an alert insights report for issue ID xyz123"
  • "What error groups are affecting my service?"

Performance Analytics

  • "Analyze the golden metrics for entity ABC123"
  • "Show me slow transactions in my payment service"
  • "What are the error patterns in my application logs?"

Advanced Analysis

  • "Run a comprehensive health analysis on my API service"
  • "Generate an SLO report for my checkout service with 99.9% target"
  • "Correlate metrics with recent deployments"

Testing the Server

You can test the server manually:

# Activate virtual environment
source venv/bin/activate

# Set environment variables
export NEW_RELIC_API_KEY="NRAK-your-key"
export NEW_RELIC_ACCOUNT_ID="your-account-id"

# Run the server (it will wait for MCP protocol messages on stdin)
python server.py

Troubleshooting

Server not starting

  • Check that Python 3.9+ is installed
  • Verify the virtual environment is activated
  • Ensure all dependencies are installed

Authentication errors

  • Verify your API key is correct and starts with NRAK-
  • Check that the account ID is correct
  • Ensure the API key has the necessary permissions

No data returned

  • Verify the entity GUID is correct
  • Check the time window (some queries default to 60 minutes)
  • Ensure your account has data for the requested time period

Cursor not finding the server

  • Check the path in your MCP configuration
  • Ensure the server script is executable
  • Look at Cursor logs for MCP-related errors

Environment Variables

Variable Required Default Description
NEW_RELIC_API_KEY Yes - Your New Relic User API Key
NEW_RELIC_ACCOUNT_ID Yes - Default New Relic Account ID
NEW_RELIC_REGION No US Region: US or EU
MAX_LOOKBACK_MINUTES No 10080 Max lookback period (7 days)
MAX_RESULT_LIMIT No 2000 Max results per query
DEFAULT_LIMIT No 100 Default result limit

Architecture

newrelic-mcp/
├── server.py              # Main MCP server entry point
├── requirements.txt       # Python dependencies
├── .env                   # Environment configuration
├── .env.example          # Example configuration
└── app/
    ├── __init__.py
    ├── config.py          # Configuration management
    ├── nr_client.py       # New Relic GraphQL client
    └── tools/
        ├── __init__.py
        ├── discovery.py       # Entity/account tools
        ├── data_access.py     # NRQL query tools
        ├── alerting.py        # Alert/incident tools
        ├── incident_response.py   # Incident analysis
        ├── performance_analytics.py  # Performance tools
        └── advanced_analysis.py   # Advanced analysis

License

MIT License - See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选