A Model Context Protocol server that enables Large Language Models like Claude to query New Relic logs and metrics using NRQL queries.
A simple Model Context Protocol (MCP) server for querying New Relic logs using NRQL queries. This server enables Large Language Models (LLMs) like Claude to interact with your New Relic data.
uv
package manager:# 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"
# 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
Create server file newrelic_logs_server.py
with the provided code.
Configure your environment variables:
# 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"
Configure Claude Desktop by editing your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
Add the following configuration:
{ "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" } } } }
SELECT * FROM Transaction SINCE 1 hour ago
SELECT * FROM Transaction WHERE error IS TRUE SINCE 1 hour ago LIMIT 10
SELECT average(duration) FROM Transaction FACET name ORDER BY average(duration) DESC LIMIT 5
You can ask Claude questions like:
# On macOS/Linux tail -f ~/Library/Logs/Claude/mcp-server-newrelic.log # On Windows type %APPDATA%\Claude\logs\mcp-server-newrelic.log
Test your server functionality using:
npx @modelcontextprotocol/inspector uv run newrelic_logs_server.py
export NEW_RELIC_API_KEY="your-api-key-here" export NEW_RELIC_ACCOUNT_ID="your-account-id-here"
uv run newrelic_logs_server.py
The server implements:
This project is licensed under the MIT License.
If you encounter issues:
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!