Skip to main content
Glama
angrysky56

Narrative Graph MCP

rtm_traverse_narrative

Traverse narrative trees to generate summaries at different abstraction levels by adjusting traversal depth and branching parameters.

Instructions

Traverse a narrative tree at different depths to get summaries at varying abstraction levels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe narrative text to traverse
titleYesTitle of the narrative
traversalDepthYesDepth to traverse in the tree (controls abstraction level)
maxBranchingFactorNoMaximum number of child nodes (K parameter)
maxRecallDepthNoMaximum depth for recall (D parameter)

Implementation Reference

  • Main execution logic for the rtm_traverse_narrative tool: builds RTM tree from narrative text, traverses to specified depth, computes recall sequence and statistics, returns JSON-structured content.
    export default async function traverseNarrative(params: TraverseNarrativeParams) {
      try {
        // Create narrative and build tree
        const narrative = createNarrative(params.text, params.title);
        
        const parameters = {
          ...createDefaultParameters(),
          maxBranchingFactor: params.maxBranchingFactor || 4,
          maxRecallDepth: params.maxRecallDepth || 6
        };
        
        const builder = new RTMTreeBuilder(parameters);
        const tree = builder.buildTree(narrative);
        
        // Create clause map for traversal
        const clauseMap = new Map(
          narrative.clauses.map(c => [c.id, c])
        );
        
        // Traverse to specified depth
        const traversal = createTraversal(tree, clauseMap);
        const result = traversal.traverseToDepth(params.traversalDepth);
        
        // Get sequential recall
        const recallSequence = traversal.simulateRecall(params.traversalDepth);
        
        // Get tree statistics
        const treeStats = traversal.getTreeStatistics();
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              success: true,
              treeId: tree.id,
              traversalResult: {
                depth: result.depth,
                nodeCount: result.nodes.length,
                totalClauses: result.totalClauses,
                avgCompressionRatio: result.compressionRatio,
                summaries: result.summary
              },
              recallSequence: recallSequence,
              treeStatistics: treeStats,
              message: `Traversed to depth ${result.depth}, found ${result.nodes.length} nodes covering ${result.totalClauses} clauses`
            }, null, 2)
          }],
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              success: false,
              error: error instanceof Error ? error.message : "Unknown error occurred"
            }, null, 2)
          }],
        };
      }
    }
  • Zod input schema defining parameters for the tool: text, title, traversalDepth (required), and optional branching/recall parameters.
    export const traverseNarrativeSchema = z.object({
      text: z.string().describe('The narrative text to traverse'),
      title: z.string().describe('Title of the narrative'),
      traversalDepth: z.number().min(1).max(10).describe('Depth to traverse in the tree (controls abstraction level)'),
      maxBranchingFactor: z.number().default(4).describe('Maximum number of child nodes (K parameter)'),
      maxRecallDepth: z.number().default(6).describe('Maximum depth for recall (D parameter)'),
    });
  • src/index.ts:47-52 (registration)
    Tool handler registry: maps 'rtm_traverse_narrative' to the traverseNarrative function imported from tools/traverseNarrative.js
    const tools = {
      rtm_create_narrative_tree: createNarrativeTree,
      rtm_generate_ensemble: generateEnsemble,
      rtm_traverse_narrative: traverseNarrative,
      rtm_find_optimal_depth: findOptimalDepth,
    };
  • src/index.ts:66-70 (registration)
    Tool metadata registration: defines name, description, and references the input schema for MCP tool listing and validation.
    {
      name: 'rtm_traverse_narrative',
      description: 'Traverse a narrative tree at different depths to get summaries at varying abstraction levels',
      inputSchema: traverseNarrativeSchema,
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'traverse' and 'get summaries' but lacks critical details: whether this is a read-only operation, if it modifies data, what the output format looks like, or any performance/rate limits. For a tool with 5 parameters and no annotations, this is insufficient.

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?

The description is a single, efficient sentence that front-loads the core action ('traverse a narrative tree') and outcome ('get summaries at varying abstraction levels'). Every word earns its place with zero redundancy or wasted phrasing.

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

Completeness2/5

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

Given the tool's complexity (5 parameters, no annotations, no output schema), the description is inadequate. It doesn't explain what a 'narrative tree' is, how summaries are generated, the format of results, or error conditions. For a tool that likely produces structured output, this leaves significant gaps for an AI agent.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value by hinting at 'different depths' and 'varying abstraction levels', which loosely relates to 'traversalDepth', but doesn't provide additional semantic context beyond what's in the schema. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('traverse') and resource ('narrative tree'), and indicates the outcome ('get summaries at varying abstraction levels'). However, it doesn't explicitly differentiate from sibling tools like 'rtm_create_narrative_tree' or 'rtm_find_optimal_depth', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus its siblings (rtm_create_narrative_tree, rtm_find_optimal_depth, rtm_generate_ensemble). It doesn't mention prerequisites, alternatives, or specific contexts for application, leaving the agent without clear usage direction.

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/angrysky56/narrative-graph-mcp'

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