Skip to main content
Glama
angrysky56

Narrative Graph MCP

rtm_create_narrative_tree

Encode narrative text into a structured tree model for information compression and recall using configurable cognitive parameters.

Instructions

Create a Random Tree Model encoding of a narrative text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe narrative text to encode
titleYesTitle of the narrative
typeNoType of narrativeother
maxBranchingFactorNoMaximum number of child nodes (K parameter)
maxRecallDepthNoMaximum depth for recall (D parameter)

Implementation Reference

  • The exported default handler function implementing the core logic of rtm_create_narrative_tree: parses input, builds RTM narrative tree using core builders, computes stats, and returns JSON-formatted result.
    interface CreateNarrativeTreeParams {
      text: string;
      title: string;
      type?: 'story' | 'article' | 'dialogue' | 'technical' | 'other';
      maxBranchingFactor?: number;
      maxRecallDepth?: number;
    }
    
    // Tool implementation
    export default async function createNarrativeTree(params: CreateNarrativeTreeParams) {
      try {
        // Create narrative from text
        const narrative = createNarrative(
          params.text, 
          params.title, 
          params.type || 'other'
        );
        
        // Create RTM parameters
        const parameters = {
          ...createDefaultParameters(),
          maxBranchingFactor: params.maxBranchingFactor || 4,
          maxRecallDepth: params.maxRecallDepth || 6
        };
        
        // Build the tree
        const builder = new RTMTreeBuilder(parameters);
        const tree = builder.buildTree(narrative);
        
        // Get tree statistics
        const stats = {
          totalNodes: tree.nodes.size,
          totalClauses: narrative.clauses.length,
          maxDepth: Math.max(...Array.from(tree.nodes.values()).map(n => n.level)),
          parameters: parameters
        };
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              success: true,
              treeId: tree.id,
              narrativeId: narrative.id,
              statistics: stats,
              message: `Created RTM tree with ${stats.totalNodes} nodes from ${stats.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 for validating tool parameters: text, title, type, maxBranchingFactor, maxRecallDepth.
    export const createNarrativeTreeSchema = z.object({
      text: z.string().describe('The narrative text to encode'),
      title: z.string().describe('Title of the narrative'),
      type: z.enum(['story', 'article', 'dialogue', 'technical', 'other']).default('other').describe('Type of narrative'),
      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 registry mapping the name 'rtm_create_narrative_tree' to its handler function createNarrativeTree.
    const tools = {
      rtm_create_narrative_tree: createNarrativeTree,
      rtm_generate_ensemble: generateEnsemble,
      rtm_traverse_narrative: traverseNarrative,
      rtm_find_optimal_depth: findOptimalDepth,
    };
  • src/index.ts:56-60 (registration)
    Tool definition registration including name, description, and input schema for listTools response and validation.
    {
      name: 'rtm_create_narrative_tree',
      description: 'Create a Random Tree Model encoding of a narrative text',
      inputSchema: createNarrativeTreeSchema,
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Create' implying a write operation, but doesn't specify if this is idempotent, requires specific permissions, or has side effects like storing data. It also omits details on output format, error handling, or 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?

The description is a single, clear sentence with zero waste. It's front-loaded and efficiently conveys the core purpose without unnecessary elaboration, making it easy to parse quickly.

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 complexity of creating an encoding model with 5 parameters and no output schema, the description is insufficient. It doesn't explain what a 'Random Tree Model encoding' entails, the format of the output, or how the parameters influence the result. This leaves significant gaps for an AI agent to understand the tool's behavior.

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 fully documents all parameters. The description adds no additional meaning beyond the schema, such as explaining how 'maxBranchingFactor' and 'maxRecallDepth' affect the encoding quality or performance. Baseline 3 is appropriate when the schema handles parameter documentation.

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 action ('Create') and the resource ('Random Tree Model encoding of a narrative text'), making the purpose evident. However, it doesn't differentiate this tool from its siblings (rtm_find_optimal_depth, rtm_generate_ensemble, rtm_traverse_narrative), which likely operate on similar narrative data but with different functions.

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 or alternatives. It lacks context about prerequisites, such as whether the text needs preprocessing, or when this encoding method is preferred over other narrative analysis tools.

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