NewRelic MCP服务器

一个用于NewRelic集成的模型上下文协议(MCP)服务器,使AI代理(如Claude Code)能够查询和分析NewRelic的可观测性数据。

  • by buallen
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 buallen/newrelic-mcp-server

使用说明

NewRelic MCP服务器

A. 模型上下文协议(MCP) 用于NewRelic集成的服务器,使AI代理(Claude Code等)能够查询和分析您的NewRelic可观察性数据。

特性

  • NRQL查询 --使用可配置的LIMIT(1-10000+)执行NRQL,解决其他MCP服务器中硬编码的LIMIT 10限制
  • 警报管理 --列出并检查警报策略
  • APM集成 --访问应用程序性能数据
  • 事件分析 --人工智能驱动的根本原因分析
  • 日志查询 --搜索和分析日志数据
  • MCP协议 --支持版本 2024-11-05 和 2025-06-18
  • 缓存 --内置结果缓存以提高性能

安装

git clone https://github.com/buallen/newrelic-mcp-server.git
cd newrelic-mcp-server
npm install
npm run build

配置

环境变量

NEWRELIC_API_KEY=your_api_key_here
NEWRELIC_ACCOUNT_ID=your_account_id

创建一个 .env 直接归档或传递它们。

克劳德码(stdio模式)

添加到您的 ~/.claude/settings.json:

"newrelic": {
  "command": "node",
  "args": ["/path/to/newrelic-mcp-server/working-mcp-main.js"],
  "env": {
    "NEWRELIC_API_KEY": "your_api_key_here",
    "NEWRELIC_ACCOUNT_ID": "your_account_id"
  }
}

Docker(stdio模式)

# Build and start
docker compose -f docker-compose.mcp.yml up -d

# Or use the helper script
./start-mcp-docker.sh

看 DOCKER_SETUP.md 完整的Docker配置。

使用示例

NRQL查询

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "nrql_query",
    "arguments": {
      "query": "SELECT average(duration) FROM Transaction WHERE appName = 'MyApp' SINCE 1 hour ago LIMIT 100"
    }
  }
}

分析事件

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "analyze_incident",
    "arguments": {
      "incidentId": "12345"
    }
  }
}

建筑

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   AI Agent      │    │  MCP Server     │    │   NewRelic      │
│  (Claude Code)  │    │                 │    │                 │
│ ┌─────────────┐ │    │ ┌─────────────┐ │    │ ┌─────────────┐ │
│ │ MCP Client  │◄┼────┼►│ Protocol    │ │    │ │ REST API    │ │
│ └─────────────┘ │    │ │ Handler     │ │    │ └─────────────┘ │
│                 │    │ └─────────────┘ │    │                 │
│                 │    │ ┌─────────────┐ │    │ ┌─────────────┐ │
│                 │    │ │ Service     │◄┼────┼►│ NerdGraph   │ │
│                 │    │ │ Layer       │ │    │ │ (GraphQL)   │ │
│                 │    │ └─────────────┘ │    │ └─────────────┘ │
└─────────────────┘    └─────────────────┘    └─────────────────┘

发展

先决条件

  • Node.js 18+
  • NewRelic帐户和API密钥

设置

git clone https://github.com/buallen/newrelic-mcp-server.git
cd newrelic-mcp-server
npm install
cp .env.example .env   # then edit with your credentials
npm run dev

测试

npm test                        # run all tests
npm run test:coverage           # with coverage report
npm run test -- tests/unit/     # unit tests only

建筑

npm run build   # compile TypeScript to dist/
npm start       # run production build

贡献

  1. 分叉存储库
  2. 创建要素分支: git checkout -b feature/my-feature
  3. 提交您的更改
  4. 推送并打开拉取请求

许可证

麻省理工学院——见 许可证 了解详情。

链接