Skip to main content
Glama
AgentWong

Knowledge Graph Memory Server

by AgentWong

Search Nodes

search_nodes

Find nodes in the knowledge graph by matching entity names, types, and observation content against a search 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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
entitiesYes
relationsYes

Implementation Reference

  • The actual implementation of the search_nodes logic, which queries the database for entities matching the query and retrieves their related nodes.
    async def search_nodes(self, query: str) -> Dict[str, List[Dict[str, Any]]]:
        """Search for nodes and their relations."""
        if not query:
            raise ValueError("Search query cannot be empty")
    
        async with self.pool.get_connection() as conn:
            search_pattern = f"%{sanitize_input(query)}%"
            
            # Search entities
            cursor = await conn.execute(
                """
                SELECT * FROM entities 
                WHERE name LIKE ? 
                OR entity_type LIKE ? 
                OR observations LIKE ?
                """,
                (search_pattern, search_pattern, search_pattern)
            )
            rows = await cursor.fetchall()
            
            entities = []
            entity_names = set()
            for row in rows:
                entity = Entity(
                    name=row['name'],
                    entityType=row['entity_type'],
                    observations=row['observations'].split(',') if row['observations'] else []
                )
                entities.append(entity.to_dict())
                entity_names.add(entity.name)
    
            relations = await self._get_relations_for_entities(conn, entity_names)
            return {"entities": entities, "relations": relations}
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. While 'Search' implies a read-only operation, it doesn't specify whether this requires authentication, has rate limits, returns paginated results, or what happens with empty queries. The description lacks critical operational context that would help an agent use it effectively.

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 wasted words. It's appropriately sized for a simple search tool and front-loads the essential information. Every word earns its place in conveying the tool's purpose.

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

Completeness3/5

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

Given the tool has an output schema (which handles return values) and 100% schema coverage for its single parameter, the description is minimally complete. However, as a search tool with no annotations and multiple sibling tools that might overlap in function, it should provide more context about when to use it and its behavioral characteristics to be fully helpful.

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 schema description coverage is 100%, with the single parameter 'query' well-documented in the schema itself. The description adds no additional parameter semantics beyond what the schema already provides ('The search query to match against entity names, types, and observation content'). This meets the baseline for high schema coverage.

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 nodes') and resource ('in the knowledge graph'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from potential sibling alternatives like 'open_nodes' or 'read_graph', which might also retrieve node information but through different mechanisms.

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. With siblings like 'open_nodes' and 'read_graph' that might also access node data, there's no indication of when search-based retrieval is preferred over direct access or full-graph reading. No prerequisites, exclusions, or comparative context is mentioned.

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/AgentWong/optimized-memory-mcp-server'

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