New Relic NerdGraph MCP Server

New Relic NerdGraph MCP Server

site icon
2025.04.05 0
PythonNew RelicAPI 交互监控管理开发效率
mcp-server-newrelic 是一个基于 Model Context Protocol (MCP) 的服务器,用于与 New Relic NerdGraph API 进行交互。它允许 MCP 客户端(如 Claude Desktop)使用自然语言或特定命令查询和交互 New Relic 账户数据和功能。该服务器提供了多种 New Relic 功能作为工具和资源,包括账户详情查询、NRQL 查询、实体管理、APM、Synthetics 和 Alerts 等功能。
View on GitHub

Overview

基本能力

产品定位

mcp-server-newrelic 是一个用于与 New Relic NerdGraph API 交互的 MCP 服务器,旨在通过自然语言或特定命令简化 New Relic 账户数据和功能的管理与查询。

核心功能

  • Account Details: 获取配置账户的基本信息。
  • Generic NerdGraph Queries: 执行任意 NerdGraph 查询。
  • NRQL Queries: 针对账户数据运行特定的 NRQL 查询。
  • Entity Management: 搜索实体(应用程序、主机、监视器等)并通过 GUID 检索详细信息。
  • APM: 列出应用程序性能监控(APM)应用程序。
  • Synthetics: 列出 Synthetic 监视器并创建简单的浏览器监视器。
  • Alerts: 列出警报策略、查看开放事件并确认事件。

适用场景

  • 通过自然语言查询 New Relic 账户数据。
  • 自动化管理 New Relic 实体和监视器。
  • 快速获取 APM 应用程序和警报事件的状态。
  • 创建和管理 Synthetic 监视器。

工具列表

  • Common:
  • query_nerdgraph: 执行任意 NerdGraph 查询。
  • run_nrql_query: 执行 NRQL 查询。
  • get_account_details: 获取账户详情。
  • Entities:
  • search_entities: 搜索实体。
  • get_entity_details: 获取实体详情。
  • generate_entity_search_query: 生成实体搜索查询。
  • APM:
  • list_apm_applications: 列出 APM 应用程序。
  • Synthetics:
  • list_synthetics_monitors: 列出 Synthetic 监视器。
  • create_simple_browser_monitor: 创建简单的浏览器监视器。
  • Alerts:
  • list_alert_policies: 列出警报策略。
  • list_open_incidents: 列出开放事件。
  • acknowledge_alert_incident: 确认警报事件。

常见问题解答

  • 如何获取 New Relic API Key? 可以在 New Relic 账户中生成 User API Key。
  • 如何找到 Account ID? 在 New Relic UI 的 URL 或账户设置中可以找到 Account ID。
  • 如何保护 API Key? 建议使用环境变量存储 API Key,避免硬编码在源代码中。

使用教程

使用依赖

  • Python: Python 3.10+ 推荐。
  • pip: Python 包安装工具。
  • New Relic Account: 需要访问 New Relic 账户。
  • New Relic User API Key: 用于认证的 User API Key。
  • New Relic Account ID: 大多数操作需要 Account ID。

安装教程

  1. 克隆仓库: bash git clone <repository_url> cd mcp-server-newrelic

  2. 安装依赖: bash pip install -r requirements.txt

配置

使用环境变量配置 API Key 和 Account ID:

export NEW_RELIC_API_KEY="YOUR_API_KEY"
export NEW_RELIC_ACCOUNT_ID="YOUR_ACCOUNT_ID"

运行服务器

fastmcp run server.py:mcp

调试方式

启动服务器后,检查输出是否包含以下信息:

Using New Relic Account ID: YOUR_ACCOUNT_ID
Registering common features...
Registering entity features...
Registering APM features...
Registering Synthetics features...
Registering Alerts features...
Feature registration complete.
INFO:     Started server process [XXXXX]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

许可证

该项目遵循 MIT 开源许可条款。