Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesNatural language query to search the memory graph.
max_depthNoHow many hops to traverse from direct matches. Default: 1.
top_kNoNumber of direct matches to return. Default: 5.
edge_filterNoOnly traverse edges of these types. Omit for all types.

Implementation Reference

  • 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");
    }
  • Definition of input parameters for the search_memory_graph tool.
    export interface SearchMemoryGraphOptions {
      rootDir: string;
      query: string;
      maxDepth?: number;
      topK?: number;
      edgeFilter?: RelationType[];
    }

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/ForLoopCodes/contextplus'

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