The New Relic MCP server provides a way to interact with New Relic's monitoring platform programmatically through the Model Context Protocol. It exposes various New Relic NerdGraph and REST API endpoints as tools that can be used with MCP-compatible clients.
First, install the required dependencies using uv:
uv pip install -r requirements.txt
Before running the server, you need to configure your New Relic credentials:
export NEW_RELIC_API_KEY=your_api_key
export NEW_RELIC_ACCOUNT_ID=your_account_id
Start the MCP server using the following command:
uv --directory /path/to/newrelic-mcp run server.py
Replace /path/to/newrelic-mcp
with the actual path to your newrelic-mcp directory.
Create a uv.mcpserver.json
file with the following content:
{
"mcpServers": {
"NewRelicMCP": {
"command": "uv",
"args": [
"--directory", "/path/to/newrelic-mcp", "run", "server.py"
],
"env": {
"NEW_RELIC_API_KEY": "<YOUR_NEW_RELIC_API_KEY>",
"NEW_RELIC_ACCOUNT_ID": "<YOUR_NEW_RELIC_ACCOUNT_ID>"
}
}
}
}
Create a mcp.json
file with the following content:
{
"mcp": {
"NewRelicMCP": {
"command": "uv",
"args": [
"--directory", "/path/to/newrelic-mcp", "run", "server.py"
],
"env": {
"NEW_RELIC_API_KEY": "<YOUR_NEW_RELIC_API_KEY>",
"NEW_RELIC_ACCOUNT_ID": "<YOUR_NEW_RELIC_ACCOUNT_ID>"
}
}
}
}
Make sure to replace the placeholder values with your actual New Relic credentials.
The server provides several tools for interacting with New Relic:
The query_logs_rest
tool allows you to query New Relic metrics using the REST API v2.
app_id
: Application ID to querynames
: 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')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"
)
This will return the raw JSON response from the New Relic REST API v2 containing the specified metrics for the given time range.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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>"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"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>"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"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>"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect