Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

search_entities

Search for New Relic entities by name, type, or tags to identify and locate monitoring resources within your account.

Instructions

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

Input Schema

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

Implementation Reference

  • Primary handler implementing the search_entities tool logic: constructs a GraphQL query for New Relic entity search based on input parameters and executes it via the client.
    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: [] };
    }
  • Defines the input schema and metadata (name, description) for the search_entities tool.
    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:69-106 (registration)
    Registers the search_entities tool (via entityTool.getSearchTool()) into the server's tools Map for MCP listTools and callTool handling.
      const tools = [
        nrqlTool.getToolDefinition(),
        apmTool.getListApplicationsTool(),
        entityTool.getSearchTool(),
        entityTool.getDetailsTool(),
        alertTool.getPoliciesTool(),
        alertTool.getIncidentsTool(),
        alertTool.getAcknowledgeTool(),
        syntheticsTool.getListMonitorsTool(),
        syntheticsTool.getCreateMonitorTool(),
        nerdGraphTool.getQueryTool(),
        // REST v2 tools
        restDeployments.getCreateTool(),
        restDeployments.getListTool(),
        restDeployments.getDeleteTool(),
        restApm.getListApplicationsTool(),
        restMetrics.getListMetricNamesTool(),
        restMetrics.getMetricDataTool(),
        restMetrics.getListApplicationHostsTool(),
        {
          name: 'get_account_details',
          description: 'Get New Relic account details',
          inputSchema: {
            type: 'object' as const,
            properties: {
              target_account_id: {
                type: 'string' as const,
                description: 'Optional account ID to get details for',
              },
            },
          },
        },
      ];
    
      tools.forEach((tool) => {
        this.tools.set(tool.name, tool);
      });
    }
  • Server-side wrapper handler for search_entities: performs input validation and delegates execution to EntityTool.searchEntities.
    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,
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool searches but doesn't describe what 'entities' encompass, how results are returned (e.g., pagination, format), authentication needs, rate limits, or error conditions. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It front-loads the core purpose ('Search for entities in New Relic') and adds specific search criteria without redundancy. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a search tool with 3 parameters. It doesn't explain what 'entities' are, how results are structured, or any behavioral aspects like pagination or errors. While schema coverage is high, the lack of output details and behavioral context makes it inadequate for full understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters ('query', 'entity_types', 'target_account_id') with descriptions. The description adds minimal value by mentioning search criteria ('name, type, or tags'), which loosely maps to 'query' and 'entity_types', but doesn't provide additional syntax, format, or examples beyond what the schema offers. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search for entities') and resource ('in New Relic'), with specific search criteria ('by name, type, or tags'). It distinguishes from siblings like 'get_entity_details' (which retrieves details for a specific entity) by focusing on search functionality. However, it doesn't explicitly differentiate from 'list_*' tools that might also retrieve entities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer 'search_entities' over sibling tools like 'get_entity_details' (for specific entity details), 'list_apm_applications' (for a specific entity type), or 'run_nrql_query' (for more complex queries). No exclusions or prerequisites are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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