关于 New Relic MCP
New Relic MCP 是面向 New Relic 可观测性平台的 Go MCP 服务,提供 55 个工具,覆盖 APM、日志、告警、仪表板等。写入操作默认关闭,并为工具附带安全策略元数据。
主要功能
- 0155 个工具覆盖多类可观测性数据
- 02通过 NRQL 查询指标、日志和追踪
- 03管理告警、仪表板、工作流与通知
- 04支持美国和欧盟数据中心
- 05写入操作默认关闭并附带风险元数据
适用场景
- 01查询应用性能和分布式追踪
- 02检查告警违规并管理告警策略
- 03检索日志及基础设施指标
- 04创建仪表板、工作流或服务级别目标
MCP 相关
该 MCP 服务通过单一 NerdGraph GraphQL 端点向 MCP 客户端提供 New Relic 数据查询和管理工具。写入工具需通过 `-write-enabled` 显式启用。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
New Relic MCP 服务
这是一个基于 Go 构建的 New Relic 可观测性平台 MCP(Model Context Protocol)服务,可全面访问 APM、基础设施、日志、追踪、告警、仪表板、合成监控、工作流、通知、服务级别、标签、实体和工作负载,所有操作均通过单一 GraphQL 端点完成。
概览
- 55 个已注册的 MCP 工具,覆盖完整的 NerdGraph API
- 安全优先设计:每个工具都带有
EnforcerProfile元数据(风险、影响、资源成本、PII 标志、幂等性),可通过 MCP Bridge 自动执行策略 - 写入保护:所有变更工具均由
-write-enabled标志控制;默认禁用 - 多区域支持:支持美国和欧盟数据中心(
NEWRELIC_REGION=us|eu) - 采用 TDD 构建:所有工具的测试覆盖率均超过 80%
注册目录
此服务已发布到以下 MCP 注册目录:
- Smithery:
karldane/newrelic-mcp - MCP Registry:
io.github.karldane/newrelic-mcp
API 架构
所有工具都通过单一 NerdGraph 端点通信:
| 区域 | 端点 |
|---|---|
| 美国(默认) | https://api.newrelic.com/graphql |
| 欧盟 | https://api.eu.newrelic.com/graphql |
内部查询辅助函数用于确定响应范围:
| 辅助函数 | 返回内容 | 用途 |
|---|---|---|
actorGraphQuery | data.actor.* | 实体查询、跨账户 NRQL |
nerdGraphQuery | data.actor.account.* | 账户范围的查询(告警、工作流等) |
rawGraphQuery | data.<mutationName> | 所有变更操作 |
executeNRQL | 已解析的 NRQL 结果 | 基于 NRQL 的工具 |
工具
NRQL 查询
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
nrql_query | 执行任意 NRQL 查询 | actor.account.nrql | 中 | 读取 |
APM 与应用
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_applications | 列出所有受 APM 监控的应用 | actor.entitySearch(domain:APM, type:APPLICATION) | 低 | 读取 |
get_apm_metrics | 获取 APM 性能指标 | actor.account.nrql(FROM APMApplication) | 低 | 读取 |
get_application_metrics | 获取特定应用的详细指标 | actor.account.nrql(FROM APMApplication) | 低 | 读取 |
query_traces | 查询分布式追踪 | actor.account.nrql(FROM Transaction) | 低 | 读取 |
get_transaction_traces | 获取事务追踪详情 | 通过 executeNRQL 执行 NRQL | 低 | 读取 |
get_trace_details | 获取特定追踪的详情 | 通过 executeNRQL 执行 NRQL | 低 | 读取 |
告警策略与条件
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_alerts | 列出所有告警策略 | actor.account.alerts.policiesSearch | 低 | 读取 |
get_alert_policy | 根据 ID 获取单个告警策略 | actor.account.alerts.policy | 低 | 读取 |
get_alert_conditions | 获取策略的条件 | actor.account.alerts.alertConditionsSearch | 低 | 读取 |
get_alert_violations | 获取活动告警违规项 | actor.account.nrql(NRQL 告警查询) | 低 | 读取 |
list_nrql_alert_conditions | 列出策略的 NRQL 条件 | actor.account.alerts.nrqlConditionsSearch | 低 | 读取 |
create_alert_policy | 创建新的告警策略 | alertsPolicyCreate | 低 | 写入 |
update_alert_policy | 更新告警策略 | alertsPolicyUpdate | 低 | 写入 |
delete_alert_policy | 删除告警策略 | alertsPolicyDelete | 高 | 写入 |
create_alert_condition | 创建 NRQL 告警条件 | alertsNrqlConditionCreate | 中 | 写入 |
acknowledge_alert_violation | 确认告警违规项 | alertsViolationAcknowledge | 中 | 写入 |
合成监控
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_synthetic_monitors | 列出所有合成监控器 | actor.entitySearch (domain:SYNTH, type:MONITOR) | Low | 读取 |
get_synthetic_monitor | 根据 GUID 获取合成监控器 | actor.entity (SyntheticMonitorEntityOutline) | Low | 读取 |
list_private_locations | 列出私有位置 | actor.entitySearch (domain:SYNTH, type:PRIVATE_LOCATION) | Low | 读取 |
create_ping_monitor | 创建简单的 Ping 监控器 | syntheticsCreateSimpleMonitor | Low | 写入 |
delete_synthetic_monitor | 删除合成监控器 | syntheticsDeleteMonitor | Med | 写入 |
仪表板
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_dashboards | 列出所有仪表板 | actor.entitySearch (domain:DASH, type:DASHBOARD) | Low | 读取 |
get_dashboard | 根据 GUID 获取完整的仪表板配置 | actor.entity (DashboardEntity) | Low | 读取 |
get_dashboard_data | 获取仪表板小组件数据 | actor.entity (DashboardEntity) | Low | 读取 |
create_dashboard | 创建新仪表板 | dashboardCreate | Low | 写入 |
update_dashboard | 更新现有仪表板 | dashboardUpdate | Low | 写入 |
delete_dashboard | 删除仪表板 | dashboardDelete | Med | 写入 |
add_dashboard_widget | 向仪表板添加小组件 | dashboardUpdate | Med | 写入 |
日志
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
search_logs | 使用 Lucene 语法搜索日志 | actor.account.nrql (FROM Log) | Med | 读取 |
tail_logs | 流式传输最近的日志条目 | actor.account.nrql (FROM Log) | Med | 读取 |
基础设施
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
get_infrastructure_metrics | 获取主机/容器指标 | actor.account.nrql (FROM SystemSample) | Low | 读取 |
告警工作流 (aiWorkflows)
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_workflows | 列出告警通知工作流 | actor.account.aiWorkflows.workflows | Low | 读取 |
get_workflow | 根据 ID 获取工作流 | actor.account.aiWorkflows.workflows (filter) | Low | 读取 |
create_workflow | 创建新的告警工作流 | aiWorkflowsCreateWorkflow | Low | 写入 |
update_workflow | 更新工作流 | aiWorkflowsUpdateWorkflow | Low | 写入 |
delete_workflow | 删除工作流 | aiWorkflowsDeleteWorkflow | High | 写入 |
通知渠道与目标 (aiNotifications)
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_notification_channels | 列出所有通知渠道 | actor.account.aiNotifications.channels | Low | 读取 |
list_destinations | 列出通知目标 | actor.account.aiNotifications.destinations | Low | 读取 |
create_slack_channel | 创建 Slack 通知渠道 | aiNotificationsCreateChannel (type:SLACK) | Low | 写入 |
create_email_channel | 创建电子邮件通知渠道 | aiNotificationsCreateChannel (type:EMAIL) | Low | 写入 |
delete_notification_channel | 删除通知渠道 | aiNotificationsDeleteChannel | High | 写入 |
服务等级
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_service_levels | 列出实体的 SLI | actor.entity (... EntityInterfaceWithServiceLevel) | Low | 读取 |
create_service_level | 创建包含 SLO 的 SLI | serviceLevelCreate | Med | 写入 |
update_service_level | 更新 SLI 的 SLO 目标 | serviceLevelUpdate | Low | 写入 |
标签管理(tagging)
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
get_entity_tags | 获取实体的所有标签 | actor.entity.tags | 低 | 读取 |
add_entity_tags | 为实体添加标签 | taggingAddTagsToEntity | 低 | 写入 |
remove_entity_tags | 从实体移除标签 | taggingDeleteTagFromEntity | 中 | 写入 |
replace_entity_tags | 替换实体的所有标签 | taggingReplaceTagsOnEntity | 中 | 写入 |
实体操作
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
search_entities | 高级实体搜索 | actor.entitySearch (queryBuilder) | 低 | 读取 |
delete_entity | 按 GUID 删除实体 | entityDelete | 高 | 写入 |
跨账户 NRQL
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
cross_account_nrql | 在多个账户中运行 NRQL | actor.nrql (multi-account) | 中 | 读取 |
工作负载
| 工具 | 描述 | GraphQL 操作 | 风险 | 影响 |
|---|---|---|---|---|
list_workloads | 列出账户的所有工作负载 | actor.account.workload.workloads | 低 | 读取 |
get_workload | 按 GUID 获取工作负载 | actor.entity (WorkloadEntity) | 低 | 读取 |
NerdGraph 参考
所有工具均可访问 New Relic NerdGraph API。使用了以下 NerdGraph 查询/变更名称:
| GraphQL 操作 | 文档 |
|---|---|
actor.entity | 实体 |
actor.entitySearch | 实体搜索 |
actor.account.nrql | NRQL |
alertsPolicyCreate / Update / Delete | 告警策略 |
alertsNrqlConditionCreate | NRQL 告警条件 |
syntheticsCreateSimpleMonitor | 合成监控 |
dashboardCreate / Update / Delete | 仪表盘 |
aiWorkflowsCreate / Update / DeleteWorkflow | 工作流 |
aiNotificationsCreateChannel / DeleteChannel | 通知渠道 |
serviceLevelCreate / Update | 服务级别 |
taggingAddTagsToEntity / DeleteTagFromEntity / ReplaceTagsOnEntity | 标签 |
entityDelete | 实体删除 |
安装
前提条件
- Go 1.22 或更高版本
- 可访问 API 的 New Relic 账户
从源代码构建
git clone https://github.com/karldane/newrelic-mcp.git
cd newrelic-mcp
make
构建选项
make # Download deps and build (default)
make deps # Download dependencies only
make build # Build binary only (assumes deps exist)
make build-all # Build for Linux, macOS, and Windows
make test # Run tests
make clean # Remove build artifacts
make install # Install to GOPATH/bin
make help # Show all options
配置
环境变量
| 变量 | 描述 | 必需 | 默认值 |
|---|---|---|---|
NEWRELIC_API_KEY | New Relic API 密钥(用户或管理员) | 是 | - |
NEWRELIC_REGION | 数据中心区域(us 或 eu) | 否 | us |
获取 API 密钥
- 登录 New Relic 账户
- 前往账户设置中的 API Keys
- 创建 User Key(用于只读操作)或 Admin Key(用于写入操作)
- 复制密钥并将其设置为
NEWRELIC_API_KEY
使用方法
基本用法(只读)
export NEWRELIC_API_KEY="your-api-key"
./newrelic-mcp
启用写入操作
写入操作需要 -write-enabled 标志:
export NEWRELIC_API_KEY="your-api-key"
./newrelic-mcp -write-enabled
默认情况下,写入工具处于禁用状态。设置 -write-enabled 后,所有变更操作(创建、更新、删除、确认)均可用。每个写入工具都带有 ImpactWrite 的 EnforcerProfile,因此 MCP Bridge 运营者可以独立执行策略。
工具列表
通过 MCP 查询完整的工具列表:
{
"tool": "tools/list"
}
安全功能
EnforcerProfile 元数据
每个工具都会声明其安全配置:
| 字段 | 描述 | 值 |
|---|---|---|
RiskLevel | 滥用可能造成的影响 | low、med、high、critical |
ImpactScope | 工具影响的范围 | read、write |
ResourceCost | API 调用权重(1-10) | 整数 |
PIIExposure | 工具是否会返回敏感数据 | true / false |
Idempotent | 重试是否安全 | true / false |
此元数据支持 MCP Bridge 自动执行策略,无需对工具列表进行硬编码。
风险分类
- 低风险:只读查询、日志搜索、指标检索、列表操作
- 中风险:创建非破坏性资源(警报条件、服务级别、仪表板、频道)、确认警报
- 高风险:删除资源(策略、实体、仪表板、工作流、频道)
写入保护
默认情况下,写入工具处于禁用状态,启用这些工具需要:
- 具有适当权限的有效 New Relic API 密钥
-write-enabled命令行标志
示例
查询应用性能
{
"tool": "nrql_query",
"arguments": {
"query": "SELECT average(duration) FROM Transaction WHERE appName = 'MyApp' TIMESERIES SINCE 1 hour ago"
}
}
列出活动警报
{
"tool": "get_alert_violations",
"arguments": {}
}
创建 Ping 监控器
{
"tool": "create_ping_monitor",
"arguments": {
"name": "My Monitor",
"uri": "https://example.com/health",
"locations": "US_EAST_1,US_WEST_1",
"period": "EVERY_5_MINUTES"
}
}
跨账户 NRQL 查询
{
"tool": "cross_account_nrql",
"arguments": {
"query": "SELECT count(*) FROM Transaction",
"account_ids": "1234567,7654321"
}
}
架构
该服务封装了 New Relic GraphQL 客户端,并通过 MCP Framework 注册每个工具。工具与 NerdGraph 操作一一对应,不会调用 REST API。
Client (MCP Host)
│
▼
newrelic-mcp (MCP Server)
│
├── actorGraphQuery → actor.* (entities, entitySearch, cross-account NRQL)
├── nerdGraphQuery → actor.account.* (alerts, workflows, notifications, workloads)
├── rawGraphQuery → mutation results
└── executeNRQL → actor.account.nrql (NRQL query tools)
│
▼
New Relic NerdGraph (api.newrelic.com/graphql)
测试
go test ./newrelic -v
测试涵盖:
- 正常路径(模拟 NerdGraph 响应)
- 空响应/无结果响应
- 缺少必需参数
- 写入启用/禁用控制
- API 错误响应
- 意外的响应格式
许可证
本项目根据 Functional Source License,Version 1.1,ALv2 Future License 授权。
版权所有 2026 Karl Dane
完整条款请参阅 LICENSE 文件。
参考资料
- MCP Framework — 支持 EnforcerProfile 的基础框架
- New Relic NerdGraph API
- NRQL 参考
- New Relic API Explorer — 交互式 GraphQL 操场
Tool Inventory
The server registers 55 tools total:
- 6 NRQL / APM / Trace tools: nrql_query, list_applications, get_apm_metrics, get_application_metrics, query_traces, get_transaction_traces, get_trace_details
- 10 Alert tools: list_alerts, get_alert_policy, get_alert_conditions, get_alert_violations, list_nrql_alert_conditions, create_alert_policy, update_alert_policy, delete_alert_policy, create_alert_condition, acknowledge_alert_violation
- 5 Synthetic Monitoring tools: list_synthetic_monitors, get_synthetic_monitor, list_private_locations, create_ping_monitor, delete_synthetic_monitor
- 7 Dashboard tools: list_dashboards, get_dashboard, get_dashboard_data, create_dashboard, update_dashboard, delete_dashboard, add_dashboard_widget
- 2 Log tools: search_logs, tail_logs
- 1 Infrastructure tool: get_infrastructure_metrics
- 5 Workflow tools: list_workflows, get_workflow, create_workflow, update_workflow, delete_workflow
- 5 Notification tools: list_notification_channels, list_destinations, create_slack_channel, create_email_channel, delete_notification_channel
- 3 Service Level tools: list_service_levels, create_service_level, update_service_level
- 4 Tag tools: get_entity_tags, add_entity_tags, remove_entity_tags, replace_entity_tags
- 2 Entity tools: search_entities, delete_entity
- 1 Cross-account NRQL tool: cross_account_nrql
- 2 Workload tools: list_workloads, get_workload
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。