mohdhaji87

New Relic MCP Server

Community mohdhaji87
Updated

New Relic MCP Server

This MCP server exposes New Relic NerdGraph and REST API endpoints as tools, allowing you to interact with your New Relic account programmatically.

Requirements

  • Python 3.12+
  • uv (for running the server)
  • A valid New Relic API key and account ID

Running the Server

  1. Install dependencies (if any):

    uv pip install -r requirements.txt
    

    (or use your preferred method for dependency management)

  2. Set your environment variables:

    export NEW_RELIC_API_KEY=your_api_key
    export NEW_RELIC_ACCOUNT_ID=your_account_id
    
  3. Start the server:

    uv --directory /Users/mohaji/mcp-servers/newrelic-mcp run server.py
    

Configuration for Claude Desktop and MCP Clients

uv.mcpserver.json Example

{
  "mcpServers": {
    "NewRelicMCP": {
      "command": "uv",
      "args": [
        "--directory", "/Users/mohaji/mcp-servers/newrelic-mcp", "run", "server.py"
      ],
      "env": {
        "NEW_RELIC_API_KEY": "<YOUR_NEW_RELIC_API_KEY>",
        "NEW_RELIC_ACCOUNT_ID": "<YOUR_NEW_RELIC_ACCOUNT_ID>"
      }
    }
  }
}

mcp.json Example

{
  "mcp": {
    "NewRelicMCP": {
      "command": "uv",
      "args": [
        "--directory", "/Users/mohaji/mcp-servers/newrelic-mcp", "run", "server.py"
      ],
      "env": {
        "NEW_RELIC_API_KEY": "<YOUR_NEW_RELIC_API_KEY>",
        "NEW_RELIC_ACCOUNT_ID": "<YOUR_NEW_RELIC_ACCOUNT_ID>"
      }
    }
  }
}

Replace the placeholder values with your actual New Relic credentials.

Available Tools

  • query_logs (NerdGraph/GraphQL)
  • query_logs_rest (REST API v2)
  • get_account_info
  • get_user_info
  • get_alerts
  • get_dashboards
  • get_entities

Each tool is available as an MCP tool and can be called from compatible clients.

Tool: query_logs_rest

Query New Relic metrics/logs using the REST API v2.

Arguments:

  • app_id: Application ID to query.
  • names: Comma-separated metric names (e.g., 'HttpDispatcher,CPU/User Time').
  • from_timestamp: Start time in ISO8601 format (e.g., '2024-07-01T00:00:00+00:00').
  • to_timestamp: End time in ISO8601 format (e.g., '2024-07-02T00:00:00+00:00').

Example call:

query_logs_rest(
  app_id="12345678",
  names="HttpDispatcher,CPU/User Time",
  from_timestamp="2024-07-01T00:00:00+00:00",
  to_timestamp="2024-07-02T00:00:00+00:00"
)

Returns the raw JSON response from the New Relic REST API v2 for the specified metrics and time range.

MCP Server · Populars

MCP Server · New