UltraThink MCP服务器
用于顺序思维和问题解决的Python MCP服务器
   
______________________________________________________________________
增强的Python端口 的 顺序思维MCP服务器 通过Anthropic。 添加时保持完全兼容性 信心评分, 自动分配的思维编号,以及 多会话支持.
\[!提示\] 使用克劳德代码? 安装 UltraThink插件 无缝集成-无需设置MCP服务器! ``bash # Via terminal claude plugin marketplace add husniadil/ekstend claude plugin install ultrathink@ekstend # Or interactively in Claude Code /plugin marketplace add husniadil/ekstend /plugin install ultrathink@ekstend ``\[!注意\] 元:此MCP服务器是使用UltraThink本身迭代构建的,这是该工具分解复杂问题、管理架构决策和维护开发会话上下文能力的一个实际例子。
______________________________________________________________________
特性
- UltraThink:将复杂问题分解为可管理的步骤
- 动态调整:随着理解的加深,修改和完善想法
- 分支探索其他推理路径
- 信心评分:显式不确定性跟踪(0.0-1.0标度)
- 自动调整:如果需要,自动调整总想法
- 多会话支持:使用会话ID管理多个并发思考会话
- 格式化测井:彩色终端输出,格式丰富(可禁用)
- 100%测试覆盖率:具有完整代码覆盖率的全面测试套件
- 类型安全:对生产代码进行完整的mypy严格模式类型检查
- 简单分层架构:与模型、服务和接口层进行干净的分离
安装
快速安装(推荐)
直接从GitHub使用uvx运行(无需安装):
uvx --from git+https://github.com/husniadil/ultrathink ultrathink开发设置
对于当地发展:
# Clone the repository
git clone https://github.com/husniadil/ultrathink.git
cd ultrathink
# Install all dependencies (including dev dependencies)
uv sync用法
任务命令(类似npm)
# List all available tasks
uv run task --list
# Run the server
uv run task run
# Run tests with coverage
uv run task test
# Run tests without coverage (quick)
uv run task test-quick
# Run the test client
uv run task client
# Format code (ruff + prettier)
uv run task format
# Lint code
uv run task lint
# Type check with mypy
uv run task typecheck
# Clean cache files
uv run task clean直接命令(替代)
对于没有任务运行器的直接执行:
# Run the server directly
uv run ultrathink
# Run the test client directly
uv run python examples/client.py注: 对于测试、linting和格式化,最好使用 uv run task 上面显示的命令。
工具:超薄
该服务器通过结构化思维为动态和反思性问题解决提供了一个单一的工具。
参数
必修的:
thought(str):你目前的思考步骤total_thoughts(int):估计所需的总想法数(>=1)
可选:
thought_number(int):当前思想编号-如果省略,则按顺序自动分配(1、2、3…),或为分支/语义控制提供明确的编号next_thought_needed(bool):是否需要另一个思考步骤。自动分配为 `thought_number ThoughtResponse:
request = ThoughtRequest(thought=thought, total_thoughts=total_thoughts, ...) return thinking_service.process_thought(request)
**类型安全优势:**
- 对所有输入/输出进行Pydantic验证
- 没有任意的字典-全程严格打字
- 自动验证错误
- 接口和业务逻辑之间的明确分离
### 架构优势
1. **明确区分关注点**:
- 模型层=具有验证和行为的数据模型
- 服务层=业务逻辑和编排
- 接口层=外部API(MCP工具)
1. **结构更简单**:更平坦的文件夹层次结构(2级而不是3级)
1. **更容易进口**:相对导入路径更短(`..models` vs `...domain.entities`)
1. **合并模型**:相关模型组合在一起(Thought、ThoughtRequest、ThoughtResponse在一个文件中)
1. **可测试的**:易于单独测试每一层
1. **可维护性**:
- 更改界面? → 仅更新接口层
- 更改业务规则? → 仅更新服务层
- 更改验证? → 仅更新模型层
1. **可扩展**:易于添加新模型、服务或工具
1. **接口独立性**:可以使用不同的接口(REST API、gRPC、CLI等)重用服务
1. **类型安全**:Pydantic模型始终确保在所有边界进行验证
## 发展
### 运行测试
Run all tests with coverage (recommended)
uv run task test
Run tests without coverage (quick)
uv run task test-quick
Coverage is 100%
### 类型检查
Run mypy type checker on all code
uv run task typecheck
Mypy runs in strict mode on entire codebase
该项目使用 **mypy处于严格模式** 在整个代码库中(`src/`, `tests/`, `examples/`)以确保完全的类型安全。
### 测试组织
测试按层组织,反映源结构(100%覆盖率):
**模型层测试** (`tests/models/`)
- **test_thought.py**:模型属性、自动调整、格式、验证和置信度评分
- **test_session.py**:会话日志记录和格式化输出
**服务层测试** (`tests/services/`)
- **test_thinking_service.py**:服务验证、功能、分支、边缘情况、响应格式、引用验证和多会话支持
**接口层测试** (`tests/interface/`)
- **test_mcp_server.py**:MCP工具函数调用
**根测试**
- **test_cli.py**:CLI入口点
## 学分
这个项目是Python移植的 [顺序思维MCP服务器](https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking) Anthropic,模型上下文协议服务器集合的一部分。原始实现为结构化思维和解决问题提供了基础。
## 新功能
在保持与原始设计完全兼容的同时,UltraThink添加了几个增强功能:
1. **信心评分** -每种思维都有0.0-1.0的显式不确定性跟踪
1. **自动分配的思维编号** -可选思维编号(如果省略,则自动递增)
1. **多会话支持** -使用会话ID管理多个并发思考会话
1. **假设跟踪** -通过明确的假设、依赖关系和无效跟踪使推理透明
## 许可证
[麻省理工学院](LICENSE)