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[];
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It effectively discloses the two-phase algorithmic behavior (embedding search followed by 1st/2nd-degree traversal) and return structure (direct hits + neighbors with scores), though it omits explicit safety/side-effect declarations (implied read-only by 'Search').

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?

Three sentences with zero waste: sentence 1 states purpose, sentence 2 explains mechanism, sentence 3 specifies returns. Front-loaded and appropriately sized for the complexity.

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

Completeness5/5

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

Given no output schema, the description compensates by specifying return composition ('direct hits and graph-connected neighbors with relevance scores'). With 100% schema parameter coverage and no annotations to repeat, the description provides sufficient context for tool selection.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, establishing baseline 3. Description adds conceptual context beyond the schema: 'embedding similarity' explains the query mechanism, and '1st/2nd-degree neighbors' explains max_depth semantics, elevating it above baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Specific verb ('Search') with resource ('memory graph') and distinct methodology ('by meaning with graph traversal'). The two-phase mechanism description (embedding similarity + neighbor traversal) clearly distinguishes this from sibling semantic_search tools and pure traversal tools like retrieve_with_traversal.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Describes the mechanism (embedding similarity then graph traversal) which implies when to use it, but lacks explicit when-to-use/when-not guidance or named alternatives among siblings like semantic_code_search or semantic_navigate.

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

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