You need two main credentials:
- NEW_RELIC_API_KEY - User API Key for NerdGraph/API access
- NEW_RELIC_ACCOUNT_ID - Your New Relic account ID
- (Optional) NEW_RELIC_REGION - Set to
EUto use European endpoints. Defaults toUS.
- Log into New Relic: https://one.newrelic.com
- Look at the URL - it will be something like:
https://one.newrelic.com/nr1-core?account=XXXXXXX - The number after
account=is your Account ID - Alternative: Click on your user avatar (top right) → "Administration" → You'll see your account ID
-
Go to: https://one.newrelic.com/api-keys OR
- Click your user avatar (top right)
- Select "API keys"
-
Click "Create a key" button
-
Configure the key:
- Key type: Select "User"
- Name: Give it a descriptive name like "MCP Server" or "newrelic-mcp"
- Notes: (Optional) Add a description
-
Click "Create a key"
-
IMPORTANT: Copy the key immediately! You won't be able to see it again.
Replace the placeholder values in your .env file:
# New Relic API Configuration
NEW_RELIC_API_KEY=NRAK-XXXXXXXXXXXXXXXXXXXXXXXXXX # Your User API Key
NEW_RELIC_ACCOUNT_ID=1234567 # Your Account IDRun the integration tests to verify everything works:
npm test test/integrationOr test manually with a simple NRQL query:
npm run dev
# Then in another terminal:
curl -X POST http://localhost:3000/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "run_nrql_query",
"params": {
"nrql": "SELECT count(*) FROM Transaction SINCE 1 hour ago",
"target_account_id": "YOUR_ACCOUNT_ID"
},
"id": 1
}'- Make sure you created a User key, not an Ingest key
- Check that you copied the entire key including the "NRAK-" prefix
- Verify the key hasn't been revoked
- Double-check your account ID
- Make sure you have access to the account
- Try without the account ID (some endpoints use the default from the API key)
- New Relic has rate limits on API calls
- If you hit limits, wait a few minutes before retrying
The server auto-selects the correct New Relic API endpoints based on the NEW_RELIC_REGION environment variable.
Supported values:
US(default if unset or any other value)EU
Endpoints affected:
- NerdGraph GraphQL (
https://api.newrelic.com/graphqlvshttps://api.eu.newrelic.com/graphql) - REST v2 (
https://api.newrelic.com/v2vshttps://api.eu.newrelic.com/v2) - Logs API (already region-aware in logging utilities)
Example .env snippet:
NEW_RELIC_API_KEY=YOUR_USER_KEY
NEW_RELIC_ACCOUNT_ID=1234567
NEW_RELIC_REGION=EU
If you omit NEW_RELIC_REGION, the US endpoints are used. Invalid values also fall back to US.
- NEVER commit your
.envfile to git - Store credentials securely (use 1Password, as noted in your .env)
- Rotate API keys periodically
- Use separate keys for development/production