Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

search_entities

Find New Relic entities by name, type, or tags. Filter by account ID and entity types to locate specific monitored resources.

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

  • The actual handler logic for search_entities. Builds a GraphQL query with filters for account ID and entity types, then calls executeNerdGraphQuery and returns the entities.
    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: [] };
    }
  • Schema definition for the search_entities tool, defining input parameters: query (required string), entity_types (optional array of strings), and target_account_id (optional string).
    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:57-73 (registration)
    Tool registration in the server constructor. entityTool.getSearchTool() is called and added to the tools map at line 72.
    private registerTools(): void {
      const nrqlTool = new NrqlTool(this.client);
      const apmTool = new ApmTool(this.client);
      const entityTool = new EntityTool(this.client);
      const alertTool = new AlertTool(this.client);
      const syntheticsTool = new SyntheticsTool(this.client);
      const nerdGraphTool = new NerdGraphTool(this.client);
      const restDeployments = new RestDeploymentsTool();
      const restApm = new RestApmTool();
      const restMetrics = new RestMetricsTool();
    
      // Register all tools
      const tools = [
        nrqlTool.getToolDefinition(),
        apmTool.getListApplicationsTool(),
        entityTool.getSearchTool(),
        entityTool.getDetailsTool(),
  • src/server.ts:228-245 (registration)
    The case handler in executeTool that dispatches to EntityTool.searchEntities after validating inputs (query must be non-empty string, entity_types must be array of strings).
    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 must fully disclose behavior. It does not mention pagination, rate limits, result limits, or any side effects. The description is too brief to inform the agent about important behavioral traits.

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 that front-loads the action and resource. Every word adds value with no redundancy.

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?

With no output schema, the description should hint at return format or result structure. It does not. The tool is a search operation with three parameters, but the description lacks details like default behavior, result limits, or error conditions.

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?

The input schema has 100% description coverage for all parameters. The description adds modest value by summarizing the filtering dimensions ('by name, type, or tags'), but does not provide additional meaning beyond what the schema already offers.

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

Purpose5/5

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

The description clearly states the action 'Search' and the resource 'entities', with specific filters 'by name, type, or tags'. It distinguishes from sibling tools like 'get_entity_details' which retrieves a single entity.

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?

No guidance on when to use this tool versus alternatives like 'list_apm_applications' or 'get_entity_details'. The description does not provide context or exclusions for its usage.

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