Skip to main content
Glama

retrieve_with_traversal

Explore connected memory nodes from a starting point to analyze relationships and dependencies within a semantic graph, using depth limits and edge type filters.

Instructions

Start from a specific memory node and traverse the graph outward. Returns the starting node plus all reachable neighbors within the depth limit, scored by edge weight decay and depth penalty. Use after search_memory_graph to explore a specific node's neighborhood.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_node_idYesID of the memory node to start traversal from.
max_depthNoMaximum traversal depth from start node. Default: 2.
edge_filterNoOnly traverse edges of these types. Omit for all.

Implementation Reference

  • The tool handler 'toolRetrieveWithTraversal' that processes the request and formats the output.
    export async function toolRetrieveWithTraversal(options: RetrieveWithTraversalOptions): Promise<string> {
      const results = await retrieveWithTraversal(options.rootDir, options.startNodeId, options.maxDepth, options.edgeFilter);
      if (results.length === 0) return `❌ Node not found: ${options.startNodeId}`;
    
      const sections = [`Traversal from: ${results[0].node.label} (depth limit: ${options.maxDepth ?? 2})\n`];
      for (const result of results) sections.push(formatTraversalResult(result));
    
      return sections.join("\n");
    }
  • The core implementation of 'retrieveWithTraversal' which handles graph traversal logic.
    export async function retrieveWithTraversal(rootDir: string, startNodeId: string, maxDepth: number = 2, edgeFilter?: RelationType[]): Promise<TraversalResult[]> {
      const graph = await loadGraph(rootDir);
      const startNode = graph.nodes[startNodeId];
      if (!startNode) return [];
    
      startNode.lastAccessed = Date.now();
      startNode.accessCount++;
    
      const results: TraversalResult[] = [{
        node: startNode,
        depth: 0,
        pathRelations: [startNode.label],
        relevanceScore: 100,
      }];
    
      const visited = new Set([startNodeId]);
      collectTraversal(graph, startNodeId, 1, maxDepth, [startNode.label], visited, results, edgeFilter);
    
      scheduleSave(rootDir);
      return results;
    }
  • The interface 'RetrieveWithTraversalOptions' defining the input schema for the tool.
    export interface RetrieveWithTraversalOptions {
      rootDir: string;
      startNodeId: string;
      maxDepth?: number;
      edgeFilter?: RelationType[];
    }
Behavior3/5

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

With no annotations provided, description carries full disclosure burden. It valuably explains the scoring algorithm ('edge weight decay and depth penalty') and return composition ('starting node plus all reachable neighbors'). However, it does not explicitly confirm read-only safety, state error handling for invalid node IDs, or mention performance characteristics.

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 well-structured sentences with zero waste: action definition, return value explanation with behavioral detail, and usage context. Information is front-loaded with the core operation, followed by mechanics, then workflow positioning.

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

Completeness4/5

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

For a 3-parameter traversal tool with no output schema, the description adequately explains the return structure conceptually (nodes with scoring) and establishes sibling relationships. Minor gap in explicit safety/assertion documentation given lack of annotations.

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

Parameters3/5

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

Schema coverage is 100%, so baseline score applies. Description reinforces parameter semantics by referencing 'depth limit' (max_depth) and 'edge weight' (edge_filter context), but does not add syntax details, format examples, or constraints beyond the schema definitions.

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?

Excellent specificity with 'traverse the graph outward' and clear resource identification (memory node). Explicitly distinguishes from sibling search_memory_graph by positioning it as the follow-up step ('Use after search_memory_graph'), establishing clear workflow boundaries.

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

Usage Guidelines4/5

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

Provides explicit temporal guidance ('Use after search_memory_graph') clarifying when to invoke this tool in the workflow. However, lacks explicit 'when not to use' guidance or comparison to similar traversal siblings like get_context_tree or get_blast_radius.

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