Skip to main content
Glama

New Relic MCP Server

by Ivlad003

New Relic MCP 服务器

一个简单的模型上下文协议 (MCP) 服务器,用于使用 NRQL 查询 New Relic 日志。此服务器支持 Claude 等大型语言模型 (LLM) 与您的 New Relic 数据进行交互。

特征

  • 使用 NRQL 查询 New Relic 日志和指标
  • 详细的错误日志记录
  • 轻松与 Claude Desktop 集成
  • 人类可读的输出格式
  • 可配置的 New Relic 帐户 ID

设置说明

先决条件

  • Python 3.10 或更高版本
  • New Relic 帐户和 API 密钥
  • Claude桌面应用程序

安装步骤

  1. 安装uv包管理器:
# On macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh # On Windows (PowerShell) powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. 创建并设置项目:
# Create directory mkdir newrelic-mcp cd newrelic-mcp # Create virtual environment uv venv # Activate virtual environment source .venv/bin/activate # On Unix/macOS .venv\Scripts\activate # On Windows # Install dependencies uv pip install "mcp[cli]" httpx
  1. 使用提供的代码创建服务器文件newrelic_logs_server.py
  2. 配置环境变量:
# On Unix/macOS export NEW_RELIC_API_KEY="your-api-key-here" export NEW_RELIC_ACCOUNT_ID="your-account-id-here" # On Windows (CMD) set NEW_RELIC_API_KEY=your-api-key-here set NEW_RELIC_ACCOUNT_ID=your-account-id-here # On Windows (PowerShell) $env:NEW_RELIC_API_KEY = "your-api-key-here" $env:NEW_RELIC_ACCOUNT_ID = "your-account-id-here"

Claude 桌面集成

通过编辑配置文件来配置 Claude Desktop:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

添加以下配置:

{ "mcpServers": { "newrelic": { "command": "uv", "args": [ "--directory", "/absolute/path/to/newrelic-mcp", "run", "newrelic_logs_server.py" ], "env": { "NEW_RELIC_API_KEY": "your-api-key-here", "NEW_RELIC_ACCOUNT_ID": "your-account-id-here" } } } }

用法

NRQL 查询示例

  1. 基本交易查询:
SELECT * FROM Transaction SINCE 1 hour ago
  1. 错误分析:
SELECT * FROM Transaction WHERE error IS TRUE SINCE 1 hour ago LIMIT 10
  1. 性能分析:
SELECT average(duration) FROM Transaction FACET name ORDER BY average(duration) DESC LIMIT 5

克劳德提示示例

您可以向 Claude 询问以下问题:

  • “显示过去一小时的所有交易”
  • “我们的申请中有什么错误吗?”
  • “我们最慢的端点是什么?”

调试

查看日志

# On macOS/Linux tail -f ~/Library/Logs/Claude/mcp-server-newrelic.log # On Windows type %APPDATA%\Claude\logs\mcp-server-newrelic.log

使用 MCP Inspector 进行测试

使用以下方法测试您的服务器功能:

npx @modelcontextprotocol/inspector uv run newrelic_logs_server.py

常见问题

  1. 身份验证错误:
  • 检查 NEW_RELIC_API_KEY 是否设置正确
  • 验证 API 密钥具有正确的权限
  • 确保 API 密钥有效
  1. 查询错误:
  • 验证 NRQL 语法
  • 检查代码中的帐户ID是否与您的帐户相符
  • 确保查询的数据存在于该时间范围内
  1. 连接问题:
  • 检查网络连接
  • 验证 GraphQL 端点是否可访问
  • 确保没有防火墙阻止连接

安全说明

  • 切勿将 API 密钥提交到版本控制
  • 使用环境变量来存储敏感数据
  • 保持依赖项更新
  • 监控查询模式和访问日志

发展

本地测试

  1. 设置环境变量:
export NEW_RELIC_API_KEY="your-api-key-here" export NEW_RELIC_ACCOUNT_ID="your-account-id-here"
  1. 运行服务器:
uv run newrelic_logs_server.py

代码结构

服务器实现:

  • 单一 NRQL 查询工具
  • 可配置的 New Relic 帐户 ID
  • 全面的错误处理
  • 详细日志记录
  • 响应格式

测试变更

  1. 根据需要修改代码
  2. 使用 MCP Inspector 进行测试
  3. 重新启动 Claude Desktop 以应用更改

故障排除指南

  1. 服务器未启动:
  • 检查 Python 版本
  • 验证所有依赖项均已安装
  • 确保虚拟环境已激活
  1. 查询不起作用:
  • 检查日志以获取详细的错误消息
  • 验证 NRQL 语法
  • 确保查询的时间范围内存在数据
  1. 克劳德未连接:
  • 验证配置文件语法
  • 检查路径是否绝对
  • 重启Claude桌面

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 提交拉取请求

执照

该项目已获得 MIT 许可。

支持

如果您遇到问题:

  1. 检查日志
  2. 查看常见问题部分
  3. 使用 MCP Inspector 进行测试
  4. 在 GitHub 上提交问题
-
security - not tested
-
license - not tested
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

模型上下文协议服务器使 Claude 等大型语言模型能够使用 NRQL 查询来查询 New Relic 日志和指标。

  1. 特征
    1. 设置说明
      1. 先决条件
      2. 安装步骤
      3. Claude 桌面集成
    2. 用法
      1. NRQL 查询示例
      2. 克劳德提示示例
    3. 调试
      1. 查看日志
      2. 使用 MCP Inspector 进行测试
      3. 常见问题
    4. 安全说明
      1. 发展
        1. 本地测试
        2. 代码结构
        3. 测试变更
      2. 故障排除指南
        1. 贡献
          1. 执照
            1. 支持

              Related MCP Servers

              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server that enables Large Language Models to seamlessly interact with ClickHouse databases, supporting resource listing, schema retrieval, and query execution.
                Last updated -
                1
                Python
                MIT License
                • Linux
                • Apple
              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that allows Large Language Models to interact with Astra DB databases, providing tools for managing collections and records through natural language commands.
                Last updated -
                10
                115
                12
                TypeScript
                Apache 2.0
                • Apple
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol (MCP) server that helps large language models index, search, and analyze code repositories with minimal setup
                Last updated -
                9
                Python
                MIT License
                • Apple
                • Linux
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.
                Last updated -
                • Apple

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ivlad003/mcp_newrelic'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server