get_entity_details
Fetch complete details for a New Relic entity using its GUID to analyze its configuration and metrics.
Instructions
Get detailed information about a specific entity
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_guid | Yes | The GUID of the entity |
Implementation Reference
- src/tools/entity.ts:103-163 (handler)The getEntityDetails method on EntityTool class that executes the tool logic. It sends a NerdGraph GraphQL query to fetch detailed entity info by GUID, including fields like guid, name, type, domain, entityType, reporting, tags, alert violations (for AlertableEntity), APM settings (for ApmApplicationEntity), relationships, and golden metrics. Returns the entity data or throws if not found.
async getEntityDetails(input: { entity_guid: string }): Promise<Record<string, unknown>> { const graphqlQuery = `{ actor { entity(guid: "${input.entity_guid}") { guid name type domain entityType reporting tags { key values } ... on AlertableEntity { alertSeverity recentAlertViolations { alertSeverity violationId openedAt closedAt violationUrl } } ... on ApmApplicationEntity { language settings { apdexTarget } } relationships { type target { entities { guid name } } } goldenMetrics { metrics { name value unit } } } } }`; const response = (await this.client.executeNerdGraphQuery(graphqlQuery)) as { data?: { actor?: { entity?: Record<string, unknown> } }; }; const entity = response.data?.actor?.entity; if (!entity) { throw new Error('Entity not found'); } return entity; } - src/tools/entity.ts:37-52 (schema)The getDetailsTool() method defines the tool's name ('get_entity_details'), description, and inputSchema — requiring a single string parameter 'entity_guid'.
getDetailsTool(): Tool { return { name: 'get_entity_details', description: 'Get detailed information about a specific entity', inputSchema: { type: 'object', properties: { entity_guid: { type: 'string', description: 'The GUID of the entity', }, }, required: ['entity_guid'], }, }; } - src/server.ts:72-74 (registration)Tool registration in server.ts: entityTool.getDetailsTool() is called and the returned Tool object is added to the tools map in the registerTools() method.
entityTool.getSearchTool(), entityTool.getDetailsTool(), alertTool.getPoliciesTool(), - src/server.ts:246-252 (handler)The switch-case handler in executeTool() method of NewRelicMCPServer. It extracts entity_guid from args, validates it's a non-empty string, and delegates to new EntityTool(this.client).getEntityDetails({ entity_guid }).
case 'get_entity_details': { const { entity_guid } = args as Record<string, unknown>; if (typeof entity_guid !== 'string' || entity_guid.trim() === '') { throw new Error('get_entity_details: "entity_guid" (non-empty string) is required'); } return await new EntityTool(this.client).getEntityDetails({ entity_guid }); } - The executeNerdGraphQuery method used by getEntityDetails to make the actual GraphQL API call to New Relic's NerdGraph endpoint. Handles auth, POST request, and JSON response parsing.
async executeNerdGraphQuery<T = unknown>( query: string, variables?: Record<string, unknown> ): Promise<GraphQLResponse<T>> { // Check if API key is missing or empty if (!this.apiKey || this.apiKey === '' || this.apiKey.length === 0) { throw new Error('NEW_RELIC_API_KEY environment variable is not set'); } const response = await fetch(NERDGRAPH_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', 'API-Key': this.apiKey, }, body: JSON.stringify({ query, variables }), }); if (!response.ok) { if (response.status === 401) { throw new Error('Unauthorized: Invalid API key'); } throw new Error(`NerdGraph API error: ${response.status} ${response.statusText}`); } return (await response.json()) as GraphQLResponse<T>; }