|
| 1 | +# Sequential Thinking MCP Server |
| 2 | + |
| 3 | +This example shows a Model Context Protocol (MCP) server that enables dynamic and reflective problem-solving through structured thinking processes. It helps break down complex problems into manageable, sequential thought steps with support for revision and branching. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +The server provides three main tools for managing thinking sessions: |
| 8 | + |
| 9 | +### 1. Start Thinking (`start_thinking`) |
| 10 | + |
| 11 | +Begins a new sequential thinking session for a complex problem. |
| 12 | + |
| 13 | +**Parameters:** |
| 14 | + |
| 15 | +- `problem` (string): The problem or question to think about |
| 16 | +- `sessionId` (string, optional): Custom session identifier |
| 17 | +- `estimatedSteps` (int, optional): Initial estimate of thinking steps needed |
| 18 | + |
| 19 | +### 2. Continue Thinking (`continue_thinking`) |
| 20 | + |
| 21 | +Adds the next thought step, revises previous steps, or creates alternative branches. |
| 22 | + |
| 23 | +**Parameters:** |
| 24 | + |
| 25 | +- `sessionId` (string): The thinking session to continue |
| 26 | +- `thought` (string): The current thought or analysis |
| 27 | +- `nextNeeded` (bool, optional): Whether another thinking step is needed |
| 28 | +- `reviseStep` (int, optional): Step number to revise (1-based) |
| 29 | +- `createBranch` (bool, optional): Create an alternative reasoning path |
| 30 | +- `estimatedTotal` (int, optional): Update total estimated steps |
| 31 | + |
| 32 | +### 3. Review Thinking (`review_thinking`) |
| 33 | + |
| 34 | +Provides a complete review of the thinking process for a session. |
| 35 | + |
| 36 | +**Parameters:** |
| 37 | + |
| 38 | +- `sessionId` (string): The session to review |
| 39 | + |
| 40 | +## Resources |
| 41 | + |
| 42 | +### Thinking History (`thinking://sessions` or `thinking://{sessionId}`) |
| 43 | + |
| 44 | +Access thinking session data and history in JSON format. |
| 45 | + |
| 46 | +- `thinking://sessions` - List all thinking sessions |
| 47 | +- `thinking://{sessionId}` - Get specific session details |
| 48 | + |
| 49 | +## Core Concepts |
| 50 | + |
| 51 | +### Sequential Processing |
| 52 | + |
| 53 | +Problems are broken down into numbered thought steps that build upon each other, maintaining context and allowing for systematic analysis. |
| 54 | + |
| 55 | +### Dynamic Revision |
| 56 | + |
| 57 | +Any previous thought step can be revised and updated, with the system tracking which thoughts have been modified. |
| 58 | + |
| 59 | +### Alternative Branching |
| 60 | + |
| 61 | +Create alternative reasoning paths to explore different approaches to the same problem, allowing for comparative analysis. |
| 62 | + |
| 63 | +### Adaptive Planning |
| 64 | + |
| 65 | +The estimated number of thinking steps can be adjusted dynamically as understanding of the problem evolves. |
| 66 | + |
| 67 | +## Running the Server |
| 68 | + |
| 69 | +### Standard I/O Mode |
| 70 | + |
| 71 | +```bash |
| 72 | +go run . |
| 73 | +``` |
| 74 | + |
| 75 | +### HTTP Mode |
| 76 | + |
| 77 | +```bash |
| 78 | +go run . -http :8080 |
| 79 | +``` |
| 80 | + |
| 81 | +## Example Usage |
| 82 | + |
| 83 | +### Starting a Thinking Session |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "method": "tools/call", |
| 88 | + "params": { |
| 89 | + "name": "start_thinking", |
| 90 | + "arguments": { |
| 91 | + "problem": "How should I design a scalable microservices architecture?", |
| 92 | + "sessionId": "architecture_design", |
| 93 | + "estimatedSteps": 8 |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +### Adding Sequential Thoughts |
| 100 | + |
| 101 | +```json |
| 102 | +{ |
| 103 | + "method": "tools/call", |
| 104 | + "params": { |
| 105 | + "name": "continue_thinking", |
| 106 | + "arguments": { |
| 107 | + "sessionId": "architecture_design", |
| 108 | + "thought": "First, I need to identify the core business domains and their boundaries to determine service decomposition." |
| 109 | + } |
| 110 | + } |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +### Revising a Previous Step |
| 115 | + |
| 116 | +```json |
| 117 | +{ |
| 118 | + "method": "tools/call", |
| 119 | + "params": { |
| 120 | + "name": "continue_thinking", |
| 121 | + "arguments": { |
| 122 | + "sessionId": "architecture_design", |
| 123 | + "thought": "Actually, before identifying domains, I should analyze the current system's pain points and requirements.", |
| 124 | + "reviseStep": 1 |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +### Creating an Alternative Branch |
| 131 | + |
| 132 | +```json |
| 133 | +{ |
| 134 | + "method": "tools/call", |
| 135 | + "params": { |
| 136 | + "name": "continue_thinking", |
| 137 | + "arguments": { |
| 138 | + "sessionId": "architecture_design", |
| 139 | + "thought": "Alternative approach: Start with a monolith-first strategy and extract services gradually.", |
| 140 | + "createBranch": true |
| 141 | + } |
| 142 | + } |
| 143 | +} |
| 144 | +``` |
| 145 | + |
| 146 | +### Completing the Thinking Process |
| 147 | + |
| 148 | +```json |
| 149 | +{ |
| 150 | + "method": "tools/call", |
| 151 | + "params": { |
| 152 | + "name": "continue_thinking", |
| 153 | + "arguments": { |
| 154 | + "sessionId": "architecture_design", |
| 155 | + "thought": "Based on this analysis, I recommend starting with 3 core services: User Management, Order Processing, and Inventory Management.", |
| 156 | + "nextNeeded": false |
| 157 | + } |
| 158 | + } |
| 159 | +} |
| 160 | +``` |
| 161 | + |
| 162 | +### Reviewing the Complete Process |
| 163 | + |
| 164 | +```json |
| 165 | +{ |
| 166 | + "method": "tools/call", |
| 167 | + "params": { |
| 168 | + "name": "review_thinking", |
| 169 | + "arguments": { |
| 170 | + "sessionId": "architecture_design" |
| 171 | + } |
| 172 | + } |
| 173 | +} |
| 174 | +``` |
| 175 | + |
| 176 | +## Session State Management |
| 177 | + |
| 178 | +Each thinking session maintains: |
| 179 | + |
| 180 | +- **Session metadata**: ID, problem statement, creation time, current status |
| 181 | +- **Thought sequence**: Ordered list of thoughts with timestamps and revision history |
| 182 | +- **Progress tracking**: Current step and estimated total steps |
| 183 | +- **Branch relationships**: Links to alternative reasoning paths |
| 184 | +- **Status management**: Active, completed, or paused sessions |
| 185 | + |
| 186 | +## Use Cases |
| 187 | + |
| 188 | +**Ideal for:** |
| 189 | + |
| 190 | +- Complex problem analysis requiring step-by-step breakdown |
| 191 | +- Design decisions needing systematic evaluation |
| 192 | +- Scenarios where initial scope is unclear and may evolve |
| 193 | +- Problems requiring alternative approach exploration |
| 194 | +- Situations needing detailed reasoning documentation |
| 195 | + |
| 196 | +**Examples:** |
| 197 | + |
| 198 | +- Software architecture design |
| 199 | +- Research methodology planning |
| 200 | +- Strategic business decisions |
| 201 | +- Technical troubleshooting |
| 202 | +- Creative problem solving |
| 203 | +- Academic research planning |
0 commit comments