交错顺序思维MCP服务器
](https://www.npmjs.com/package/@jochenyang/interleaved-thinking)  ](https://modelcontextprotocol.io)
______________________________________________________________________
MCP服务器实现,使AI能够通过动态工具调用执行交错顺序思维。该服务器允许人工智能在灵活的“思考-执行-反映”循环中在推理、工具执行和结果分析之间交替。
特性
- 自动相位检测:无需指定阶段-根据上下文自动推断
- 简化的API:工作方式类似于顺序思维,但具有工具执行能力
- 三阶段交错执行:在思考、工具调用和分析阶段之间无缝切换
- 动态工具调用:在推理过程中执行外部工具,并根据结果调整策略
- 上下文连续性:在整个交错周期中保持完整的上下文
- 灵活的战略调整:支持修订、分支和动态步数调整
- 完成历史跟踪:记录所有思维步骤和工具调用,并提供详细信息
- 资源控制:内置工具调用限制和超时控制,以防止无限循环
- 测试支持:用于测试的模拟工具结果,无需实际执行工具
用例
此工具设计用于:
- 分解需要多个步骤的复杂问题
- 在推理过程中需要外部信息的任务
- 需要根据中期结果调整战略的问题
- 开始时不清楚全部范围的情况
- 需要反复验证和信息收集的任务
- 受益于“思考-执行-反映”周期的问题
工具
交错思维
通过动态工具调用促进交错顺序思维。
核心参数:
thought(string):您当前的思考内容stepNumber(整数):当前步数(从1开始)totalSteps(整数):估计所需的总步骤数nextStepNeeded(boolean):是否需要下一步
相位控制(可选-如果省略,则自动推断):
phase(枚举,可选):当前阶段-“思考”、“工具调用”或“分析”
- 如果省略,则自动推断: - 提供 toolCall → 自动检测为“tool_call” - 在“tool_call”之后→ 自动检测为“分析” - 否则→ 默认为“思考”
工具调用参数(提供时触发工具执行):
toolCall(对象,可选):
- toolName (string):要执行的工具的名称 - parameters (object):工具参数作为键值对 - metadata (对象,可选):超时、重试计数、优先级
高级参数(可选):
isRevision(boolean):这是否修改了之前的推理revisesStep(整数):正在重新考虑哪一步branchFromStep(整数):分支点步数branchId(string):分支标识符needsMoreSteps(boolean):如果需要更多步骤
配置
使用Claude Code CLI
将此添加到您的Claude Code CLI MCP设置中:
{
"interleaved-thinking": {
"command": "cmd",
"args": [
"/c",
"npx",
"@jochenyang/interleaved-thinking@latest"
],
"env": {},
"type": "stdio"
}
}使用游标
将此添加到光标MCP设置中:
{
"mcpServers": {
"interleaved-thinking": {
"command": "npx",
"args": [
"-y",
"@jochenyang/interleaved-thinking"
]
}
}
}使用Kiro
将此添加到您的Kiro MCP配置中:
{
"mcpServers": {
"interleaved-thinking": {
"command": "npx",
"args": [
"-y",
"@jochenyang/interleaved-thinking"
]
}
}
}使用VS代码
对于手动安装,请将配置添加到 .vscode/mcp.json 在您的工作空间中:
{
"servers": {
"interleaved-thinking": {
"command": "npx",
"args": [
"-y",
"@jochenyang/interleaved-thinking"
]
}
}
}码头工人
{
"mcpServers": {
"interleaved-thinking": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"jochenyang/interleaved-thinking"
]
}
}
}环境变量
DISABLE_THOUGHT_LOGGING:设置为true禁用控制台日志记录(默认值:false)
建筑
NPM
npm install
npm run build码头工人
docker build -t jochenyang/interleaved-thinking -f Dockerfile .示例用法
简单模式(自动相位检测)
// Step 1: Just thinking (phase auto-inferred as 'thinking')
{
"thought": "I need to analyze this problem step by step",
"stepNumber": 1,
"totalSteps": 5,
"nextStepNeeded": true
}
// Step 2: Tool call (phase auto-inferred as 'tool_call' because toolCall is provided)
{
"thought": "Now I need to fetch some data",
"stepNumber": 2,
"totalSteps": 5,
"nextStepNeeded": true,
"toolCall": {
"toolName": "fetch_data",
"parameters": {
"query": "example"
}
}
}
// Step 3: Analysis (phase auto-inferred as 'analysis' because previous step was tool_call)
{
"thought": "Based on the tool results, I can now conclude...",
"stepNumber": 3,
"totalSteps": 5,
"nextStepNeeded": false
}高级模式(显式相位控制)
// You can still explicitly specify phase for fine-grained control
{
"thought": "I want to explicitly control the phase",
"stepNumber": 1,
"totalSteps": 3,
"nextStepNeeded": true,
"phase": "thinking" // Explicitly set phase
}许可证
此MCP服务器根据MIT许可证获得许可。有关详细信息,请参阅LICENSE文件。
