Skip to main content
Glama
itseasy21

Knowledge Graph Memory Server

search_nodes

Find nodes in a knowledge graph by searching entity names, types, and observation content with a query.

Instructions

Search for nodes in the knowledge graph based on a query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to match against entity names, types, and observation content

Implementation Reference

  • The core handler function that executes the search_nodes tool logic: loads the knowledge graph, filters entities matching the query in name, entityType, or observations, filters relations between those entities, and returns the filtered subgraph.
    async searchNodes(query: string): Promise<KnowledgeGraph> {
      const graph = await this.loadGraph();
    
      // Filter entities
      const filteredEntities = graph.entities.filter(e =>
        e.name.toLowerCase().includes(query.toLowerCase()) ||
        e.entityType.toLowerCase().includes(query.toLowerCase()) ||
        e.observations.some(o => o.toLowerCase().includes(query.toLowerCase()))
      );
    
      // Create a Set of filtered entity names for quick lookup
      const filteredEntityNames = new Set(filteredEntities.map(e => e.name));
    
      // Filter relations to only include those between filtered entities
      const filteredRelations = graph.relations.filter(r =>
        filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to)
      );
    
      const filteredGraph: KnowledgeGraph = {
        entities: filteredEntities,
        relations: filteredRelations,
      };
    
      return filteredGraph;
    }
  • index.ts:531-532 (registration)
    Registration and dispatch logic in the CallToolRequest handler switch statement, which calls the searchNodes method with the provided query argument.
    case "search_nodes":
      return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.searchNodes(args.query as string), null, 2) }] };
  • Tool schema definition including name, description, and input schema requiring a 'query' string parameter, registered in the ListTools response.
      name: "search_nodes",
      description: "Search for nodes in the knowledge graph based on a query",
      inputSchema: {
        type: "object",
        properties: {
          query: { type: "string", description: "The search query to match against entity names, types, and observation content" },
        },
        required: ["query"],
      },
    },
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 based on a query but doesn't describe key behaviors: what the search returns (e.g., list of nodes, metadata), how results are formatted, whether it's paginated or limited, or any performance constraints. For a search tool with zero annotation coverage, this is a significant gap.

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 core purpose ('search for nodes in the knowledge graph') and adds necessary detail ('based on a query'). There is no wasted language or redundancy, making it highly concise and well-structured.

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 tool's complexity (search operation with no output schema) and lack of annotations, the description is incomplete. It doesn't explain what the search returns, how results are structured, or any behavioral traits like rate limits. For a search tool, this leaves critical gaps for an AI agent to understand the tool's full context.

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, with the 'query' parameter fully documented in the schema. The description adds minimal value beyond the schema, only reiterating that the search is 'based on a query.' It doesn't provide additional context like query syntax examples or search scope details. Baseline 3 is appropriate when the 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') and target resource ('nodes in the knowledge graph'), with a specific scope ('based on a query'). It distinguishes from siblings like 'read_graph' (which likely reads the entire graph) or 'open_nodes' (which might open specific nodes). However, it doesn't explicitly differentiate from potential sibling search tools (none listed), so it's not a perfect 5.

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 prerequisites (e.g., needing existing nodes), exclusions (e.g., not for creating or updating nodes), or comparisons to siblings like 'read_graph' (which might retrieve all nodes without filtering). Usage is implied by the verb 'search,' but no explicit context is given.

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/itseasy21/mcp-knowledge-graph'

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