Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

search_entities

Find specific entities in New Relic by name, type, or tags using a search query. Filter results by entity types and account ID for precise data retrieval.

Instructions

Search for entities in New Relic by name, type, or tags

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_typesNoFilter by entity types (e.g., APPLICATION, HOST)
queryYesSearch query for entities
target_account_idNoOptional New Relic account ID

Implementation Reference

  • The main execution logic for the 'search_entities' tool. Constructs a GraphQL query using the provided search query, optional entity types and account ID, executes it via the NewRelicClient, and returns the entities and nextCursor.
    async searchEntities(input: { query: string; entity_types?: string[]; target_account_id?: string; }): Promise<{ entities: Array<Record<string, unknown>>; nextCursor?: string }> { const accountId = input.target_account_id; let query = input.query; if (accountId) { query += ` AND accountId = '${accountId}'`; } if (input.entity_types && input.entity_types.length > 0) { const types = input.entity_types.map((t: string) => `'${t}'`).join(','); query += ` AND type IN (${types})`; } const graphqlQuery = `{ actor { entitySearch(query: "${query}") { results { entities { guid name type domain tags { key values } } nextCursor } } } }`; const response = (await this.client.executeNerdGraphQuery(graphqlQuery)) as { data?: { actor?: { entitySearch?: { results?: { entities: Array<Record<string, unknown>>; nextCursor?: string }; }; }; }; }; return response.data?.actor?.entitySearch?.results || { entities: [] }; }
  • Tool definition including name, description, and input schema for 'search_entities', specifying required 'query' and optional 'entity_types' and 'target_account_id'.
    getSearchTool(): Tool { return { name: 'search_entities', description: 'Search for entities in New Relic by name, type, or tags', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for entities', }, entity_types: { type: 'array', items: { type: 'string' }, description: 'Filter by entity types (e.g., APPLICATION, HOST)', }, target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, }, required: ['query'], }, }; }
  • src/server.ts:228-245 (registration)
    Dispatch handler in the server's executeTool switch statement that validates inputs for 'search_entities' and calls the EntityTool's searchEntities method.
    case 'search_entities': { const { query, entity_types } = args as Record<string, unknown>; if (typeof query !== 'string' || query.trim() === '') { throw new Error('search_entities: "query" (non-empty string) is required'); } let types: string[] | undefined; if (entity_types !== undefined) { if (!Array.isArray(entity_types)) { throw new Error('search_entities: "entity_types" must be an array of strings'); } types = (entity_types as unknown[]).filter((t): t is string => typeof t === 'string'); } return await new EntityTool(this.client).searchEntities({ query, entity_types: types, target_account_id: accountId, }); }
  • src/server.ts:71-72 (registration)
    Registration of the search_entities tool by calling entityTool.getSearchTool() and adding it to the list of available tools.
    apmTool.getListApplicationsTool(), entityTool.getSearchTool(),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cloudbring/newrelic-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server