顺序思维MCP服务器
一种模型上下文协议(MCP)服务器,通过定义的阶段促进结构化、渐进式思维。该工具有助于将复杂问题分解为连续的想法,跟踪思维过程的进展,并生成总结。
特性
- 结构化思维框架:通过标准认知阶段(问题定义、研究、分析、综合、结论)组织思想
- 思路追踪:使用元数据记录和管理连续的想法
- 相关思想分析:识别相似想法之间的联系
- 进度监控:跟踪你在整体思维序列中的位置
- 摘要生成:创建整个思维过程的简明概述
- 持久存储:使用线程安全自动保存您的思考会话
- 数据导入/导出:分享和重复使用思考环节
- 可扩展架构:轻松定制和扩展功能
- 稳健的错误处理:妥善处理边缘情况和损坏的数据
- 类型安全:全面的类型注释和验证
先决条件
- Python 3.10或更高版本
- UV包管理器(安装指南)
关键技术
- 派丹蒂克:用于数据验证和序列化
- 便携式储物柜:用于线程安全的文件访问
- FastMCP:用于模型上下文协议集成
- 富有的:用于增强控制台输出
- Yaml:用于配置管理
项目结构
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22mcp-sequential-thinking/
├── mcp_sequential_thinking/
│ ├── server.py # Main server implementation and MCP tools
│ ├── models.py # Data models with Pydantic validation
│ ├── storage.py # Thread-safe persistence layer
│ ├── storage_utils.py # Shared utilities for storage operations
│ ├── analysis.py # Thought analysis and pattern detection
│ ├── utils.py # Common utilities and helper functions
│ ├── logging_conf.py # Centralized logging configuration
│ └── __init__.py # Package initialization
├── tests/
│ ├── test_analysis.py # Tests for analysis functionality
│ ├── test_models.py # Tests for data models
│ ├── test_storage.py # Tests for persistence layer
│ └── __init__.py
├── run_server.py # Server entry point script
├── debug_mcp_connection.py # Utility for debugging connections
├── README.md # Main documentation
├── CHANGELOG.md # Version history and changes
├── example.md # Customization examples
├── LICENSE # MIT License
└── pyproject.toml # Project configuration and dependencies
快速开始
- 建立项目
BASH``` 1 2 3 4 5 6 7 8 9 10# Create and activate virtual environment uv venv .venv\Scripts\activate # Windows source .venv/bin/activate # Unix
Install package and dependencies
uv pip install -e .
For development with testing tools
uv pip install -e ”.[dev]“
For all optional dependencies
uv pip install -e ”.[all]”
2. **运行服务器**
BASH```
1
2
3
4# Run directly
uv run -m mcp_sequential_thinking.server
# Or use the installed script
mcp-sequential-thinking
- 运行测试
BASH``` 1 2 3 4# Run all tests pytest
Run with coverage report
pytest —cov=mcp_sequential_thinking
## Claude桌面集成
添加到您的Claude Desktop配置中:
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **视窗**: `%APPDATA%\Claude\claude_desktop_config.json`
### 选项1:使用虚拟环境(建议用于Linux/macOS)
如果您已设置项目 `uv venv && uv pip install -e .`,直接指向venv Python解释器。这避免了依赖解析问题(例如,在使用Python 3.14+的系统上):
JSON```
1
2
3
4
5
6
7
8
9
10
11
12{
"mcpServers": {
"sequential-thinking": {
"command": "/path/to/mcp-sequential-thinking/.venv/bin/python",
"args": [
"-m",
"mcp_sequential_thinking.server"
],
"cwd": "/path/to/mcp-sequential-thinking"
}
}
}
选项2:使用uv运行
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14{ “mcpServers”: { “sequential-thinking”: { “command”: “uv”, “args”: [ “run”, “—directory”, “/path/to/mcp-sequential-thinking”, “-m”, “mcp_sequential_thinking.server” ] } } }
### 选项3:使用已安装的入口点
如果您已使用全局安装了该软件包 `pip install -e .`:
JSON```
1
2
3
4
5
6
7{
"mcpServers": {
"sequential-thinking": {
"command": "mcp-sequential-thinking"
}
}
}
选项4:使用uvx(无需本地安装)
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14{ “mcpServers”: { “sequential-thinking”: { “command”: “uvx”, “args”: [ “—from”, “git+https://github.com/arben-adm/mcp-sequential-thinking”, “—with”, “portalocker”, “mcp-sequential-thinking” ] } } }
## 编辑器和IDE集成
### 光标
添加到您的光标MCP配置 `.cursor/mcp.json` 在您的项目根目录中(或全局位于 `~/.cursor/mcp.json`):
JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13
14{
"mcpServers": {
"sequential-thinking": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/mcp-sequential-thinking",
"-m",
"mcp_sequential_thinking.server"
]
}
}
}
VS代码(副驾驶MCP)
VS Code自1.99+版本起支持MCP服务器。添加 .vscode/mcp.json 在您的工作区或发送给您的用户 settings.json:
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14{ “servers”: { “sequential-thinking”: { “command”: “uv”, “args”: [ “run”, “—directory”, “/path/to/mcp-sequential-thinking”, “-m”, “mcp_sequential_thinking.server” ] } } }
> **注:** 通过以下方式在VS代码中启用MCP支持 `"chat.mcp.enabled": true` 在您的设置中。
### 泽德
添加到Zed设置(`~/.config/zed/settings.json`):
JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16{
"context_servers": {
"sequential-thinking": {
"command": {
"path": "uv",
"args": [
"run",
"--directory",
"/path/to/mcp-sequential-thinking",
"-m",
"mcp_sequential_thinking.server"
]
}
}
}
}
克劳德代码(CLI)
使用CLI添加服务器:
BASH``` 1claude mcp add sequential-thinking — uv run —directory /path/to/mcp-sequential-thinking -m mcp_sequential_thinking.server
或手动创建/编辑 `.mcp.json` 在项目根目录中:
JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13
14{
"mcpServers": {
"sequential-thinking": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/mcp-sequential-thinking",
"-m",
"mcp_sequential_thinking.server"
]
}
}
}
帆板运动
添加到您的Windsurf MCP配置 ~/.codeium/windsurf/mcp_config.json:
JSON``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14{ “mcpServers”: { “sequential-thinking”: { “command”: “uv”, “args”: [ “run”, “—directory”, “/path/to/mcp-sequential-thinking”, “-m”, “mcp_sequential_thinking.server” ] } } }
### 双子星命令行工具
添加到您的Gemini CLI设置 `~/.gemini/settings.json`:
JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16{
"mcpServers": {
"sequential-thinking": {
"type": "stdio",
"command": "uvx",
"args": [
"--from",
"git+https://github.com/arben-adm/mcp-sequential-thinking",
"--with",
"portalocker",
"mcp-sequential-thinking"
],
"env": {}
}
}
}
提示: 以上所有编辑器配置都使用
uv run或uvx。您也可以直接指向venv Python解释器(参见 克劳德桌面选项1)或使用uvx(参见 选项4)如果您不想克隆存储库。
运作原理
服务器维护思想的历史记录,并通过结构化的工作流对其进行处理。每个想法都使用Pydantic模型进行验证,分为思维阶段,并与相关元数据一起存储在线程安全存储系统中。服务器自动处理数据持久性、备份创建,并提供分析思想之间关系的工具。
使用指南
Sequential Thinking服务器提供了五个主要工具:
1. process_thought
在你的顺序思维过程中记录和分析一个新的想法。
参数:
-
thought(string):你的思想内容 -
thought_number(整数):在序列中的位置(例如,1表示第一次思考) -
total_thoughts(整数):序列中预期的总想法数 -
next_thought_needed(boolean):在此之后是否需要更多思考 -
stage(string):思考阶段-必须是以下之一: -
“问题定义”
-
“研究”
-
“分析”
-
“合成”
-
“结论”
-
tags(字符串列表,可选):您的想法的关键字或类别 -
axioms_used(字符串列表,可选):在你的思想中应用的原则或公理 -
assumptions_challenged(字符串列表,可选):假设你的思维问题或挑战
例子:
PYTHON``` 1 2 3 4 5 6 7 8 9 10 11# First thought in a 5-thought sequence process_thought( thought=“The problem of climate change requires analysis of multiple factors including emissions, policy, and technology adoption.”, thought_number=1, total_thoughts=5, next_thought_needed=True, stage=“Problem Definition”, tags=[“climate”, “global policy”, “systems thinking”], axioms_used=[“Complex problems require multifaceted solutions”], assumptions_challenged=[“Technology alone can solve climate change”] )
### 2. `generate_summary`
生成整个思维过程的摘要。
**输出示例:**
JSON```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19{
"summary": {
"totalThoughts": 5,
"stages": {
"Problem Definition": 1,
"Research": 1,
"Analysis": 1,
"Synthesis": 1,
"Conclusion": 1
},
"timeline": [
{"number": 1, "stage": "Problem Definition"},
{"number": 2, "stage": "Research"},
{"number": 3, "stage": "Analysis"},
{"number": 4, "stage": "Synthesis"},
{"number": 5, "stage": "Conclusion"}
]
}
}
3. clear_history
通过清除所有记录的想法来重置思维过程。
4. export_session
将当前思维会话导出到JSON文件以供共享或备份。
参数:
file_path(string):输出JSON文件的路径(父目录是自动创建的)
例子:
PYTHON``` 1export_session(file_path=“/home/user/exports/my-analysis.json”)
### 5. `import_session`
从JSON文件导入以前导出的思维会话。
**参数:**
- `file_path` (string):要导入的JSON文件的路径
## 实际应用
- **决策**:有条不紊地处理重要决策
- **问题解决**:将复杂问题分解为可管理的组件
- **研究规划**:用明确的阶段来构建你的研究方法
- **写作组织**:在写作之前逐步发展想法
- **项目分析**:通过确定的分析阶段评估项目
## 入门指南
使用正确的MCP设置,只需使用 `process_thought` 开始按顺序处理你的想法的工具。随着您的进步,您可以通过以下方式获得概述 `generate_summary` 并在需要时重置 `clear_history`.
# 定制顺序思维服务器
有关如何自定义和扩展Sequential Thinking服务器的详细示例,请参阅 example.md。它包括以下代码示例:
- 修改思维阶段
- 用Pydantic增强思维数据结构
- 添加数据库的持久性
- 使用NLP实现增强分析
- 创建自定义提示
- 设置高级配置
- 构建web UI集成
- 实施可视化工具
- 连接到外部服务
- 创建协作环境
- 分离测试代码
- 构建可重复使用的公用设施
## 许可证
MIT许可证