Fractal Thinking MCP Server

March 30, 2025 ยท View on GitHub

An MCP (Model Context Protocol) server that provides tools and resources for fractal thinking analysis.

What is Fractal Thinking?

Fractal thinking is an approach to problem-solving that uses recursive, self-similar patterns. It involves breaking down complex problems into smaller, similar sub-problems, and then solving each one. This approach helps:

  • Maintain the big picture while exploring details
  • Find patterns and connections across different levels of abstraction
  • Systematically explore complex problem spaces
  • Organize thoughts in a hierarchical yet interconnected way

Features

This MCP server provides:

Resources

  • thoughts://tree - Access the entire fractal thought tree
  • thoughts://thought/{thoughtId} - Access a specific thought and its sub-thoughts

Tools

  • breakDownThought - Decompose a thought into fractal branches using predefined patterns
  • addFractalThought - Add a new thought to the tree with fractal analysis
  • summarizeFractalAnalysis - Generate and cache compact summaries of thought analyses
  • analyzeFractalDepth - Perform detailed fractal pattern analysis

Analysis Features

  • Pattern Recognition: Identifies recursive patterns across different scales
  • Emergent Properties: Detects properties that emerge from pattern interactions
  • Caching System: Efficient storage and retrieval of analysis results
  • Summary Format: D{depth}|C{completion%}|P[patterns]|E[properties]|S{strength%}

Analytics for LLM Fractal Thinking

The analytics provided by the server, particularly in the addFractalThought and analyzeFractalDepth responses, are designed to help an LLM guide the fractal thinking process effectively. Here's how some key metrics contribute:

  • key_patterns (type, strength, evolution): Identifies the dominant structural patterns (like expansion, deepening, completion) within a thought's subtree. The LLM can use this to understand how the thinking is progressing (e.g., is it broadening, going deeper, or concluding?). The evolution shows how patterns change across depths, indicating self-similarity or transformation.
  • emergent_properties (property, strength): Highlights higher-level characteristics (like Systematic Exploration, Iterative Refinement) that arise from the interaction of basic patterns. This helps the LLM identify the style or nature of the thinking process in a particular area.
  • overall_strength: A composite score reflecting the robustness and development of patterns within the subtree. A low score might prompt the LLM to suggest further development or restructuring, while a high score indicates well-established patterns.
  • completion_ratio: Simple metric showing the percentage of thoughts marked as isComplete. Helps the LLM gauge progress towards resolving a particular line of thought.
  • branching_factor: Average number of subthoughts per thought. Indicates whether the thinking is diverging broadly or focusing narrowly.
  • depth_consistency: Measures how consistently patterns repeat at different depths. High consistency suggests strong self-similarity, a key aspect of fractal thinking.
  • structural_complexity: A composite score reflecting the overall size, depth, and branching of the subtree. Helps the LLM understand the scale and intricacy of the thought structure being analyzed.
  • pattern_stability: Measures the consistency of patterns between a parent thought and its children. High stability indicates that the chosen decomposition or thinking pattern is being applied consistently down the hierarchy.
  • natural_language_summary: Provides concise, human-readable interpretations of the metrics and patterns, making it easier for the LLM to grasp the state of the analysis and formulate next steps or insights.
  • recommendations: Offers suggestions based on the metrics (e.g., "Pattern strength low - consider restructuring"). The LLM can use these as prompts for guiding the user or refining the thought process.
  • required_next_action: Explicitly guides the LLM on the mandatory next step (usually calling summarizeFractalAnalysis), enforcing the correct workflow for optimal analysis and caching.

By interpreting these analytics, an LLM can make more informed decisions about where to focus attention, which branches need further exploration, whether patterns are developing as expected, and when a line of thought might be nearing completion.

Decomposition Patterns

  • Problem-Solution: Analysis, Design, Implementation, Validation
  • Concept-Implementation: Core Concept, Requirements, Strategy, Testing
  • Abstract-Concrete: Model, Examples, Edge Cases, Integration
  • System-Components: Overview, Components, Interactions, Boundaries
  • Custom: User-defined decomposition patterns

Installation

# Clone the repository
git clone https://github.com/yourusername/fractal-thinking-mcp-server.git
cd fractal-thinking-mcp-server

# Install dependencies
npm install

# Build the server
npm run build

Usage

Starting the Server

# Start the server
npm start

# Optionally specify a storage file to persist the fractal tree
FRACTAL_STORAGE_FILE=my-thoughts.json npm start

Connecting to Claude

To use this server with Claude for Desktop, add it to your Claude for Desktop configuration:

{
  "mcpServers": {
    "fractalThinking": {
      "command": "node",
      "args": [
        "/path/to/fractal-thinking-mcp-server/build/index.js"
      ],
      "env": {
        "FRACTAL_STORAGE_FILE": "/path/to/storage/fractal-tree.json"
      }
    }
  }
}

Using with MCP Inspector

For development and testing, you can use the MCP Inspector:

npx @modelcontextprotocol/inspector node build/index.js

Required Workflow

  1. Break down initial thoughts:
breakDownThought({
  thought: "Your complex thought",
  decompositionPattern: "system-components" // or other patterns
})
  1. Add and summarize thoughts (always paired):
// First, add the thought
addFractalThought({
  thought: "Your thought",
  isComplete: false,
  needsDeeperAnalysis: true
})

// Immediately summarize using the returned ID
summarizeFractalAnalysis({
  thoughtId: "returned_id",
  forceSummarize: true
})
  1. Optional deep analysis:
analyzeFractalDepth({
  thoughtId: "thought_id"
})

Fractal Thought Structure

Each thought in the fractal tree has the following structure:

interface FractalThought {
  thoughtId: string;       // Unique identifier
  thought: string;         // Content of the thought
  depth: number;           // Depth level in the tree
  parentId: string | null; // Parent thought ID (null for root thoughts)
  subThoughts: FractalThought[]; // Sub-thoughts
  isComplete: boolean;     // Whether the thought is resolved
  needsDeeperAnalysis: boolean; // Whether it needs deeper analysis
  createdAt: string;       // Creation timestamp
}

Analysis Caching

The server implements an efficient caching system:

  • Full analysis results are cached for 5 minutes
  • Summaries are cached for 30 minutes
  • Automatic cache cleanup for expired entries
  • Force regeneration available when needed

License

MIT