Skip to main content
Glama

search_nodes

Locate and retrieve relevant entities in a knowledge graph by executing precise queries to support structured reasoning and problem-solving tasks.

Instructions

Search for nodes in the knowledge graph based on a query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query to find matching entities

Implementation Reference

  • The execute function that implements the core logic of the search_nodes tool. It performs direct matching on entity names, queries the memory store for observation matches, combines results, retrieves full entities, and returns a JSON string with the findings.
    execute: async (args) => {
      // First, check if any entity names directly match or contain the query
      const directMatches = Array.from(graph.entities.keys()).filter(name => 
        name.toLowerCase().includes(args.query.toLowerCase())
      );
      
      // Then use the query interface to search observations
      const queryResults = await memoryStore.query({
        keyword: args.query,
        limit: 100
      });
      
      // Combine direct entity name matches with observation content matches
      const entityNames = new Set<string>([
        ...directMatches,
        ...queryResults.map(result => result.entityName)
      ]);
      
      // Get the full entities
      const results = graph.getEntities(Array.from(entityNames));
      
      // Return as string
      return JSON.stringify({
        entities: results,
        count: results.length,
        message: `Found ${results.length} matching entities.`
      });
    }
  • Registers the search_nodes tool with the FastMCP server inside the registerMemoryTools function, specifying name, description, input schema, and inline handler.
    server.addTool({
      name: 'search_nodes',
      description: 'Search for nodes in the knowledge graph based on a query',
      parameters: Schemas.SearchNodesSchema,
      execute: async (args) => {
        // First, check if any entity names directly match or contain the query
        const directMatches = Array.from(graph.entities.keys()).filter(name => 
          name.toLowerCase().includes(args.query.toLowerCase())
        );
        
        // Then use the query interface to search observations
        const queryResults = await memoryStore.query({
          keyword: args.query,
          limit: 100
        });
        
        // Combine direct entity name matches with observation content matches
        const entityNames = new Set<string>([
          ...directMatches,
          ...queryResults.map(result => result.entityName)
        ]);
        
        // Get the full entities
        const results = graph.getEntities(Array.from(entityNames));
        
        // Return as string
        return JSON.stringify({
          entities: results,
          count: results.length,
          message: `Found ${results.length} matching entities.`
        });
      }
    });
  • Zod schema defining the input parameters for the search_nodes tool: a required 'query' string.
    export const SearchNodesSchema = z.object({
      query: z.string().min(1).describe('Search query to find matching entities')
    });
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 action ('Search') but doesn't describe what 'nodes' entail, how results are returned (e.g., format, pagination), or any constraints like rate limits or authentication needs. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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 directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly. Every word earns its place by conveying essential information.

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 the complexity of a search operation with no annotations and no output schema, the description is incomplete. It doesn't explain what 'nodes' are in this context, how results are structured, or any behavioral traits like error handling. For a tool that likely returns data, the lack of output details 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%, with the single parameter 'query' documented as 'Search query to find matching entities'. The description adds no additional meaning beyond this, such as query syntax examples or what constitutes a 'matching entity'. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 verb ('Search') and resource ('nodes in the knowledge graph'), making the purpose immediately understandable. It distinguishes from some siblings like 'add_observations' or 'delete_entities' by focusing on retrieval rather than modification. However, it doesn't explicitly differentiate from similar search tools like 'exa_search' or 'memory_query', which slightly limits sibling differentiation.

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 choose 'search_nodes' over 'exa_search', 'memory_query', or other search-related siblings, nor does it specify prerequisites or exclusions. This leaves the agent without context for tool selection.

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

Related 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/flight505/mcp-think-tank'

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