-
Notifications
You must be signed in to change notification settings - Fork 27
mcp: add sequential thinking server example #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nsega
wants to merge
3
commits into
modelcontextprotocol:main
Choose a base branch
from
nsega:add-sequentialthinking-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,366
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
# Sequential Thinking MCP Server | ||
|
||
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. | ||
|
||
## Features | ||
|
||
The server provides three main tools for managing thinking sessions: | ||
|
||
### 1. Start Thinking (`start_thinking`) | ||
|
||
Begins a new sequential thinking session for a complex problem. | ||
|
||
**Parameters:** | ||
|
||
- `problem` (string): The problem or question to think about | ||
- `sessionId` (string, optional): Custom session identifier | ||
- `estimatedSteps` (int, optional): Initial estimate of thinking steps needed | ||
|
||
### 2. Continue Thinking (`continue_thinking`) | ||
|
||
Adds the next thought step, revises previous steps, or creates alternative branches. | ||
|
||
**Parameters:** | ||
|
||
- `sessionId` (string): The thinking session to continue | ||
- `thought` (string): The current thought or analysis | ||
- `nextNeeded` (bool, optional): Whether another thinking step is needed | ||
- `reviseStep` (int, optional): Step number to revise (1-based) | ||
- `createBranch` (bool, optional): Create an alternative reasoning path | ||
- `estimatedTotal` (int, optional): Update total estimated steps | ||
|
||
### 3. Review Thinking (`review_thinking`) | ||
|
||
Provides a complete review of the thinking process for a session. | ||
|
||
**Parameters:** | ||
|
||
- `sessionId` (string): The session to review | ||
|
||
## Resources | ||
|
||
### Thinking History (`thinking://sessions` or `thinking://{sessionId}`) | ||
|
||
Access thinking session data and history in JSON format. | ||
|
||
- `thinking://sessions` - List all thinking sessions | ||
- `thinking://{sessionId}` - Get specific session details | ||
|
||
## Core Concepts | ||
|
||
### Sequential Processing | ||
|
||
Problems are broken down into numbered thought steps that build upon each other, maintaining context and allowing for systematic analysis. | ||
|
||
### Dynamic Revision | ||
|
||
Any previous thought step can be revised and updated, with the system tracking which thoughts have been modified. | ||
|
||
### Alternative Branching | ||
|
||
Create alternative reasoning paths to explore different approaches to the same problem, allowing for comparative analysis. | ||
|
||
### Adaptive Planning | ||
|
||
The estimated number of thinking steps can be adjusted dynamically as understanding of the problem evolves. | ||
|
||
## Running the Server | ||
|
||
### Standard I/O Mode | ||
|
||
```bash | ||
go run . | ||
``` | ||
|
||
### HTTP Mode | ||
|
||
```bash | ||
go run . -http :8080 | ||
``` | ||
|
||
## Example Usage | ||
|
||
### Starting a Thinking Session | ||
|
||
```json | ||
{ | ||
"method": "tools/call", | ||
"params": { | ||
"name": "start_thinking", | ||
"arguments": { | ||
"problem": "How should I design a scalable microservices architecture?", | ||
"sessionId": "architecture_design", | ||
"estimatedSteps": 8 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Adding Sequential Thoughts | ||
|
||
```json | ||
{ | ||
"method": "tools/call", | ||
"params": { | ||
"name": "continue_thinking", | ||
"arguments": { | ||
"sessionId": "architecture_design", | ||
"thought": "First, I need to identify the core business domains and their boundaries to determine service decomposition." | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Revising a Previous Step | ||
|
||
```json | ||
{ | ||
"method": "tools/call", | ||
"params": { | ||
"name": "continue_thinking", | ||
"arguments": { | ||
"sessionId": "architecture_design", | ||
"thought": "Actually, before identifying domains, I should analyze the current system's pain points and requirements.", | ||
"reviseStep": 1 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Creating an Alternative Branch | ||
|
||
```json | ||
{ | ||
"method": "tools/call", | ||
"params": { | ||
"name": "continue_thinking", | ||
"arguments": { | ||
"sessionId": "architecture_design", | ||
"thought": "Alternative approach: Start with a monolith-first strategy and extract services gradually.", | ||
"createBranch": true | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Completing the Thinking Process | ||
|
||
```json | ||
{ | ||
"method": "tools/call", | ||
"params": { | ||
"name": "continue_thinking", | ||
"arguments": { | ||
"sessionId": "architecture_design", | ||
"thought": "Based on this analysis, I recommend starting with 3 core services: User Management, Order Processing, and Inventory Management.", | ||
"nextNeeded": false | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Reviewing the Complete Process | ||
|
||
```json | ||
{ | ||
"method": "tools/call", | ||
"params": { | ||
"name": "review_thinking", | ||
"arguments": { | ||
"sessionId": "architecture_design" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Session State Management | ||
|
||
Each thinking session maintains: | ||
|
||
- **Session metadata**: ID, problem statement, creation time, current status | ||
- **Thought sequence**: Ordered list of thoughts with timestamps and revision history | ||
- **Progress tracking**: Current step and estimated total steps | ||
- **Branch relationships**: Links to alternative reasoning paths | ||
- **Status management**: Active, completed, or paused sessions | ||
|
||
## Use Cases | ||
|
||
**Ideal for:** | ||
|
||
- Complex problem analysis requiring step-by-step breakdown | ||
- Design decisions needing systematic evaluation | ||
- Scenarios where initial scope is unclear and may evolve | ||
- Problems requiring alternative approach exploration | ||
- Situations needing detailed reasoning documentation | ||
|
||
**Examples:** | ||
|
||
- Software architecture design | ||
- Research methodology planning | ||
- Strategic business decisions | ||
- Technical troubleshooting | ||
- Creative problem solving | ||
- Academic research planning |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Though we might not need to prepare for README.md for each example, I created this file, just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I appreciate your input.