Skip to main content
Glama
BRO3886

Memory Custom

by BRO3886

search_nodes

Find nodes in a knowledge graph by matching queries against entity names, types, and observation content within specified memory files.

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
memoryFilePathYesThe path to the memory file

Implementation Reference

  • The core handler function that implements the logic for searching nodes in the knowledge graph by filtering entities based on query matches in name, entityType, or observations, and including only relations between matched entities.
    async searchNodes(query: string, filepath: string): Promise<KnowledgeGraph> { await this.setMemoryFilePath(filepath); 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; }
  • Input schema defining the parameters for the search_nodes tool: query (string) and memoryFilePath (string).
    inputSchema: { type: "object", properties: { query: { type: "string", description: "The search query to match against entity names, types, and observation content", }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["query", "memoryFilePath"], },
  • index.ts:540-558 (registration)
    Registration of the search_nodes tool in the list of available tools, including name, description, and input schema.
    { 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", }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["query", "memoryFilePath"], }, },
  • index.ts:692-707 (registration)
    Dispatch handler in the CallToolRequestSchema switch statement that invokes the searchNodes method with provided arguments and returns the result as JSON.
    case "search_nodes": return { content: [ { type: "text", text: JSON.stringify( await knowledgeGraphManager.searchNodes( args.query as string, args.memoryFilePath as string ), null, 2 ), }, ], };

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/BRO3886/mcp-memory-custom'

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