Skip to main content
Glama

search_nodes

Find relevant entities in a knowledge graph by searching names, types, and content to support semantic code indexing and retrieval.

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 searchNodesHandler function implements the core logic of the 'search_nodes' tool. It validates the query input, calls knowledgeGraphManager.searchNodes, formats the result as JSON text content, and handles errors.
    export const searchNodesHandler = async (args) => {
        if (!args.query || typeof args.query !== 'string') {
            throw new Error("The 'query' parameter is required and must be a string");
        }
        try {
            const results = await knowledgeGraphManager.searchNodes(args.query);
            return {
                content: [{
                        type: "text",
                        text: JSON.stringify(results, null, 2)
                    }]
            };
        }
        catch (error) {
            console.error("Error in search_nodes tool:", error);
            throw error;
        }
    };
  • The input schema and metadata definition for the 'search_nodes' tool, specifying the required 'query' string parameter.
    export const searchNodesTool = {
        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"],
        },
    };
  • Explicit registration of the 'search_nodes' tool and its handler into the toolRegistry.
    // Enregistrer search_nodes
    try {
        toolRegistry.register(searchNodesTool, searchNodesHandler);
        console.log(`✅ Outil enregistré: ${searchNodesTool.name}`);
    }
    catch (error) {
        console.error(`❌ Erreur lors de l'enregistrement de ${searchNodesTool.name}:`, error);
  • The core searchNodes method in KnowledgeGraphManager that performs the actual node searching by filtering entities and relations based on the query matching names, types, or observations case-insensitively.
    async searchNodes(query) {
        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 = {
            entities: filteredEntities,
            relations: filteredRelations,
        };
        return filteredGraph;
    }
  • The 'search_nodes' tool is listed in the expected tools array for verification in the auto-registry system.
    'search_nodes',
    'open_nodes',
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic search functionality but doesn't describe what 'search' entails - whether it returns partial matches, supports advanced operators, has pagination, returns specific fields, or has any rate limits or authentication requirements. For a search tool with zero annotation coverage, this is insufficient.

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 unnecessary words. It's appropriately sized for a single-parameter search tool and front-loads the 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?

For a search tool with no annotations and no output schema, the description is incomplete. It doesn't explain what constitutes a 'node' in this context, what fields are searched (beyond what's implied in the schema), what the return format looks like, or how results are structured. The agent would need to guess about the tool's behavior and outputs.

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 the single 'query' parameter with its description. The tool description adds no additional parameter information beyond what's in the schema, so it meets the baseline for adequate but unenriched parameter documentation.

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 tool's purpose as 'Search for nodes in the knowledge graph based on a query', specifying the verb (search), resource (nodes), and context (knowledge graph). It distinguishes from obvious non-search siblings like create/delete operations, but doesn't explicitly differentiate from other search tools like search_code.

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 search_nodes is appropriate versus open_nodes, read_graph, or search_code, nor does it specify any prerequisites or contextual constraints for 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/ali-48/rag-mcp-server'

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