search_memory_graph
Search a semantic memory graph using natural language queries to find relevant information and discover connected context through graph traversal.
Instructions
Search the memory graph by meaning with graph traversal. First finds direct matches via embedding similarity, then traverses 1st/2nd-degree neighbors to discover linked context. Returns both direct hits and graph-connected neighbors with relevance scores.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Natural language query to search the memory graph. | |
| max_depth | No | How many hops to traverse from direct matches. Default: 1. | |
| top_k | No | Number of direct matches to return. Default: 5. | |
| edge_filter | No | Only traverse edges of these types. Omit for all types. |
Implementation Reference
- src/tools/memory-tools.ts:84-99 (handler)The toolSearchMemoryGraph function acts as the handler for the 'search_memory_graph' tool. It calls searchGraph from the core memory graph implementation and formats the output for the MCP client.
export async function toolSearchMemoryGraph(options: SearchMemoryGraphOptions): Promise<string> { const result = await searchGraph(options.rootDir, options.query, options.maxDepth, options.topK, options.edgeFilter); if (result.direct.length === 0) return `No memory nodes found for: "${options.query}"\nGraph has ${result.totalNodes} nodes, ${result.totalEdges} edges.`; const sections: string[] = [`Memory Graph Search: "${options.query}"`, `Graph: ${result.totalNodes} nodes, ${result.totalEdges} edges\n`]; sections.push("Direct Matches:"); for (const hit of result.direct) sections.push(formatTraversalResult(hit)); if (result.neighbors.length > 0) { sections.push("\nLinked Neighbors:"); for (const neighbor of result.neighbors) sections.push(formatTraversalResult(neighbor)); } return sections.join("\n"); } - src/tools/memory-tools.ts:24-30 (schema)Definition of input parameters for the search_memory_graph tool.
export interface SearchMemoryGraphOptions { rootDir: string; query: string; maxDepth?: number; topK?: number; edgeFilter?: RelationType[]; }