Skip to main content
Glama
T1nker-1220

Knowledge Graph Memory Server

search_nodes

Locate nodes in a knowledge graph by querying entity names, types, or observation content to enhance interaction and memory retention in the MCP system.

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 searchNodes in KnowledgeGraphManager class that implements the tool logic: caches, loads graph, filters entities matching query in name/type/observations, filters relations between them, returns subgraph.
    async searchNodes(query: string): Promise<KnowledgeGraph> { const cacheKey = this.getCacheKey('searchNodes', { query }); const cached = this.cache.get<KnowledgeGraph>(cacheKey); if (cached) return cached; const graph = await this.loadGraph(); 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())) ); const filteredEntityNames = new Set(filteredEntities.map(e => e.name)); const filteredRelations = graph.relations.filter(r => filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to) ); const result = { entities: filteredEntities, relations: filteredRelations, }; this.cache.set(cacheKey, result); return result; }
  • The input schema and metadata for the search_nodes tool, defined in the tools list returned by ListToolsRequestSchema.
    { 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"], }, },
  • index.ts:1240-1241 (registration)
    The dispatch case in CallToolRequestSchema handler that registers and invokes the search_nodes tool by calling the handler.
    case "search_nodes": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.searchNodes(args.query as string), null, 2) }] };

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/T1nker-1220/memories-with-lessons-mcp-server'

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