Skip to main content
Glama
m-siles

Branch Thinking MCP Server

by m-siles

branch-thinking

Organize and manage interconnected thought branches with insights, cross-references, and priority tracking to enhance structured idea exploration and decision-making.

Instructions

A tool for managing multiple branches of thought with insights and cross-references.

Each thought can:

  • Belong to a specific branch

  • Generate insights

  • Create cross-references to other branches

  • Include confidence scores and key points

The system tracks:

  • Branch priorities and states

  • Relationships between thoughts

  • Accumulated insights

  • Cross-branch connections

Commands:

  • list: Show all branches and their status

  • focus [branchId]: Switch focus to a specific branch

  • history [branchId?]: Show the history of thoughts in a branch (uses active branch if none specified)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchIdNoOptional: ID of the branch (generated if not provided)
commandNoOptional: Navigation command
confidenceNoOptional: Confidence score (0-1)
contentNoThe thought content
crossRefsNoOptional: Cross-references to other branches
keyPointsNoOptional: Key points identified in the thought
parentBranchIdNoOptional: ID of the parent branch
relatedInsightsNoOptional: IDs of related insights
typeNoType of thought (e.g., 'analysis', 'hypothesis', 'observation')

Implementation Reference

  • src/index.ts:137-225 (registration)
    Tool object definition registering 'branch-thinking' with detailed description and comprehensive input schema supporting thoughts, commands, insights, and cross-references.
    const BRANCHING_THOUGHT_TOOL: Tool = {
      name: "branch-thinking",
      description: `A tool for managing multiple branches of thought with insights and cross-references.
      
    Each thought can:
    - Belong to a specific branch
    - Generate insights
    - Create cross-references to other branches
    - Include confidence scores and key points
    
    The system tracks:
    - Branch priorities and states
    - Relationships between thoughts
    - Accumulated insights
    - Cross-branch connections
    
    Commands:
    - list: Show all branches and their status
    - focus [branchId]: Switch focus to a specific branch
    - history [branchId?]: Show the history of thoughts in a branch (uses active branch if none specified)`,
      inputSchema: {
        type: "object",
        properties: {
          content: {
            type: "string",
            description: "The thought content"
          },
          branchId: {
            type: "string",
            description: "Optional: ID of the branch (generated if not provided)"
          },
          parentBranchId: {
            type: "string",
            description: "Optional: ID of the parent branch"
          },
          type: {
            type: "string",
            description: "Type of thought (e.g., 'analysis', 'hypothesis', 'observation')"
          },
          confidence: {
            type: "number",
            description: "Optional: Confidence score (0-1)"
          },
          keyPoints: {
            type: "array",
            items: { type: "string" },
            description: "Optional: Key points identified in the thought"
          },
          relatedInsights: {
            type: "array",
            items: { type: "string" },
            description: "Optional: IDs of related insights"
          },
          crossRefs: {
            type: "array",
            items: {
              type: "object",
              properties: {
                toBranch: { type: "string" },
                type: { type: "string" },
                reason: { type: "string" },
                strength: { type: "number" }
              }
            },
            description: "Optional: Cross-references to other branches"
          },
          command: {
            type: "object",
            description: "Optional: Navigation command",
            properties: {
              type: {
                type: "string",
                enum: ["list", "focus", "history"],
                description: "Command type"
              },
              branchId: {
                type: "string",
                description: "Branch ID for commands that require it"
              }
            },
            required: ["type"]
          }
        },
        anyOf: [
          { required: ["content", "type"] },
          { required: ["command"] }
        ]
      }
    };
  • Core handler function processThought that processes tool inputs: handles commands or adds new thoughts to branches, generates status response, and manages errors.
    processThought(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } {
      try {
        const inputData = input as any;
        
        // Handle commands if present
        if (inputData.command) {
          return this.handleCommand(inputData.command);
        }
    
        // Handle regular thought input
        const thoughtInput = input as BranchingThoughtInput;
        const thought = this.branchManager.addThought(thoughtInput);
        const branch = this.branchManager.getBranch(thought.branchId)!;
        
        // Format the response with the branch status
        const formattedStatus = this.branchManager.formatBranchStatus(branch);
        console.error(formattedStatus); // Display in the console
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              thoughtId: thought.id,
              branchId: thought.branchId,
              branchState: branch.state,
              branchPriority: branch.priority,
              numInsights: branch.insights.length,
              numCrossRefs: branch.crossRefs.length,
              activeBranch: this.branchManager.getActiveBranch()?.id
            }, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: error instanceof Error ? error.message : String(error),
              status: 'failed'
            }, null, 2)
          }],
          isError: true
        };
      }
    }
  • MCP CallTool request handler that routes 'branch-thinking' tool calls to the processThought implementation.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name === "branch-thinking") {
        return thinkingServer.processThought(request.params.arguments);
      }
    
      return {
        content: [{
          type: "text",
          text: `Unknown tool: ${request.params.name}`
        }],
        isError: true
      };
    });
  • src/index.ts:241-243 (registration)
    Registers the 'branch-thinking' tool for listing in MCP ListTools requests.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [BRANCHING_THOUGHT_TOOL],
    }));
  • Key helper method implementing branch creation, thought addition, insight generation, cross-reference management, and metric updates.
    addThought(input: BranchingThoughtInput): ThoughtData {
      // Use active branch if no branchId provided
      const branchId = input.branchId || this.activeBranchId || this.generateId('branch');
      let branch = this.branches.get(branchId);
    
      if (!branch) {
        branch = this.createBranch(branchId, input.parentBranchId);
      }
    
      const thought: ThoughtData = {
        id: `thought-${++this.thoughtCounter}`,
        content: input.content,
        branchId: branch.id,
        timestamp: new Date(),
        metadata: {
          type: input.type,
          confidence: input.confidence || 1.0,
          keyPoints: input.keyPoints || []
        }
      };
    
      branch.thoughts.push(thought);
    
      // Create insights if key points are provided
      if (input.keyPoints) {
        const insight = this.createInsight(
          'observation',
          `Identified key points: ${input.keyPoints.join(', ')}`,
          [input.type],
          input.relatedInsights
        );
        branch.insights.push(insight);
      }
    
      // Create cross references if specified
      if (input.crossRefs) {
        input.crossRefs.forEach(ref => {
          const crossRef = this.createCrossReference(
            branch!.id,
            ref.toBranch,
            ref.type,
            ref.reason,
            ref.strength
          );
          branch!.crossRefs.push(crossRef);
        });
      }
    
      this.updateBranchMetrics(branch);
      return thought;
    }
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. It describes system tracking (priorities, states, relationships) and thought capabilities (insights, cross-references), but it fails to disclose critical behavioral traits such as whether operations are read-only or destructive, authentication needs, rate limits, or how data is persisted. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with a purpose statement, followed by bullet points and commands. Each sentence earns its place by detailing capabilities and usage, though it could be slightly more streamlined by integrating the commands into the flow rather than as a separate section.

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 (9 parameters, nested objects, no output schema) and lack of annotations, the description is incomplete. It covers basic functionality but misses critical context like return values, error handling, or operational constraints, making it inadequate for an agent to fully understand how to invoke and interpret results from this tool.

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 9 parameters thoroughly. The description adds no specific parameter semantics beyond what the schema provides, such as explaining how 'confidence' scores affect operations or the meaning of 'crossRefs' in practice. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose3/5

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

The description states the tool is for 'managing multiple branches of thought with insights and cross-references,' which gives a general purpose but lacks a specific verb and resource. It doesn't distinguish from siblings (none provided), but the purpose remains somewhat vague without concrete examples of what 'managing' entails beyond the listed commands.

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?

The description implies usage through the 'Commands' section (list, focus, history), suggesting when to use these specific actions, but it lacks explicit guidance on when to use this tool overall versus alternatives (none provided) or any exclusions. The context is implied rather than clearly stated.

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

Related 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/m-siles/branch-thinking'

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