深度思考MCP
 
## ⚠️ 截至2026年4月12日已退役 deepthinking-mcp 不再处于积极开发阶段。 它已被替换为 深度思考插件 --一个Claude Code插件,提供与基于本地提示的技能相同的34种推理模式,没有Node.js服务器,没有依赖足迹,也没有上下文污染。 新用户:跳过此仓库 安装插件. 现有用户:v9.1.3可以无限期地工作。 安全修复土地至2026年10月12日;之后,仅进行维护。看 DEPRECATED.md 完整的迁移指南(约10分钟)、基本原理和时间表。 |快速链接|| |---|---| |新插件仓库|https://github.com/danielsimonjr/deepthinking-plugin | |迁移指南| 弃用.md#迁移指南 | |为什么被替换| DEPRECATED.md#为什么被替换 | |最新插件发布| v0.4.1 |______________________________________________________________________
  
一种具有以下特点的综合模型上下文协议(MCP)服务器 34种推理模式 (30种具有专用思维类型,4种高级运行时模式),包括历史推理、用于战略监督的元推理、智能模式推荐、基于分类的分类、企业安全以及用于复杂问题解决、分析和决策的生产就绪功能。
📋 最终功能发布:v9.1.3--请参见 DEPRECATED.md 对于迁移路径 deepthinking-plugin。2026年10月12日之前的安全修复。 🎉 v9.1.0已添加历史推理模式——分析历史事件,评估来源,识别模式,追踪因果链,并用5种思维类型定义时期。 ✨ 代码库:237个TypeScript文件|~102500个LOC|15个模块|5148+测试通过目录
特性
- 34种专业推理模式 -从顺序思维到历史分析、博弈论、形式逻辑和元推理(30种全思维类型,4种高级运行时模式)
- 模式处理器架构(v9.x) -具有37个专门处理程序的策略模式,为所有34种模式提供高级验证和增强功能
- 历史推理(v9.1.0) -事件分析、来源评估、模式识别、因果链、5种思维类型的分期
- 专用处理程序增强功能 -系统原型(8种模式)、苏格拉底式问题(6类)、自贝叶斯后验、纳什均衡、源可靠性评分
- 可视化生成器API -14个流畅的构建器类:DOTGraphBuilder、MermaidGraphBuilder、MermaidGanttBuilder、MermaidStateDiagramBuilder、ASCIIDocBuilder、SVGBuilder、TikZBuilder、UMLBuilder、HTMLDocBuilder、MarkdownBuilder、ModelicaBuilder、JSONExportBuilder、GraphMLBuilder、SVGGroupBuilder
- 学术研究模式 -综合(文献综述)、论证(图尔敏)、批评(同行评审)、分析(定性方法)
- 算法推理 -CLRS全面覆盖100多种命名算法、复杂性分析、设计模式
- 历史计算扩展 -可计算性(图灵机)、密码分析(分析者)、扩展博弈论(冯·诺伊曼)
- 证明分解 -将证明分解为原子陈述,检测差距,跟踪假设链
- 原生SVG导出 -无需外部工具即可直接生成SVG进行可视化证明
- 元推理 -监控有效性、建议模式切换和评估质量的战略监督
- 智能模式推荐 -基于问题特征的自动模式选择
- 分类学分类器 -用于智能任务分类的12个类别的69种推理类型(计划110种)
- 可视化导出 -生成Mermaid图、DOT图、ASCII艺术、SVG图形和LaTeX文档
- 文件导出系统 -将会话导出到具有可配置输出目录和配置文件的文件
- 生产就绪 -搜索引擎、会话管理、缓存、多实例支持
- 企业安全 -输入验证(Zod)、路径净化、PII编辑
- 高性能 -LRU缓存,具有自动驱逐和异步I/O功能
- 类型安全 -100%TypeScript,具有全面的类型覆盖率
- 可扩展 -自定义推理模式的插件架构
- MCP兼容 -与模型上下文协议完全集成
安装
NPM包
npm install deepthinking-mcp来源
git clone https://github.com/danielsimonjr/deepthinking-mcp.git
cd deepthinking-mcp
npm install
npm run buildMCP配置
添加到MCP设置文件中:
{
"mcpServers": {
"deepthinking": {
"command": "npx",
"args": ["deepthinking-mcp"]
}
}
}使用环境变量进行配置
使用环境变量配置服务器:
{
"mcpServers": {
"deepthinking": {
"command": "npx",
"args": ["deepthinking-mcp"],
"env": {
"MCP_EXPORT_PATH": "C:/deepthinking-exports",
"MCP_EXPORT_OVERWRITE": "false",
"MCP_LOG_LEVEL": "info"
}
}
}
}| 变量 | 描述 | 默认值 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MCP_EXPORT_PATH | 文件导出的默认目录 | `` (returns content) | MCP_EXPORT_OVERWRITE | Overwrite existing files | false | MCP_LOG_LEVEL | Log level (debug/info/warn/error) | info | MCP_MAX_SESSIONS | Maximum active sessions | 100 | MCP_SESSION_TIMEOUT_MS | Session timeout (0 = none) | 0 | SESSION_DIR | Shared session storage for multi-instance | `` (记忆中) |
快速开始
MCP工具使用
DeepThinking MCP为不同的推理领域提供了13个专注的工具:
| 工具 | 模式 | 描述 |
|---|---|---|
deepthinking_core | 归纳、演绎、溯因 | 基本推理 |
deepthinking_standard | 顺序、shannon、混合 | 标准工作流模式 |
deepthinking_mathematics | 数学、物理、可计算性 | 数学/物理/可计算性 |
deepthinking_temporal | 时态 | 基于时间的推理 |
deepthinking_probabilistic | 贝叶斯证据推理 | |
deepthinking_causal | 因果、反事实 | 因果分析 |
deepthinking_strategic | 博弈论,优化 | 战略推理 |
deepthinking_analytical | 类比、第一原理、元推理、密码分析 | 分析推理 |
deepthinking_scientific | 科学方法、系统思维、形式逻辑 | 科学推理 |
deepthinking_engineering | 工程,算法 | 工程/算法 |
deepthinking_academic | 综合、论证、批判、分析 | 学术研究 |
deepthinking_session | - | 会话管理 |
deepthinking_analyze | 多模式 | 使用预设和合并策略进行分析 |
示例:顺序推理
{
"tool": "deepthinking_standard",
"arguments": {
"mode": "sequential",
"thought": "First, identify the main bottlenecks in the distributed system",
"thoughtNumber": 1,
"totalThoughts": 5,
"nextThoughtNeeded": true
}
}示例:因果分析
{
"tool": "deepthinking_causal",
"arguments": {
"mode": "causal",
"thought": "Analyzing the root cause of the service outage",
"thoughtNumber": 1,
"totalThoughts": 3,
"nextThoughtNeeded": true,
"causalGraph": {
"nodes": [
{"id": "n1", "name": "High Load", "type": "cause"},
{"id": "n2", "name": "Memory Exhaustion", "type": "mediator"},
{"id": "n3", "name": "Service Crash", "type": "effect"}
],
"edges": [
{"from": "n1", "to": "n2", "strength": 0.9},
{"from": "n2", "to": "n3", "strength": 0.95}
]
}
}
}示例:会话导出
{
"tool": "deepthinking_session",
"arguments": {
"action": "export",
"sessionId": "session-123",
"exportFormat": "markdown"
}
}推理模式
服务器支持34种推理模式,按类别组织:
- 核心模式(5):顺序,香农,数学,物理,混合
- 因果/概率(7):因果、贝叶斯、反事实、时间、历史、博弈论、证据
- 历史计算(二):可计算性(图灵)、密码分析(图灵)- *v7.2.0*
- 算法(1):算法(CLRS)- *v7.3.0*
- 学术研究(4):综合、论证、批评、分析- *v7.4.0*
- 高级运行时模式(6):元推理、递归、模态、随机、约束、优化
- 基本模式(3):归纳法、演绎法、绑架法
- 系统/科学(3):系统思维、科学方法、形式逻辑
- 类比(2):类比,第一原则
- 工程学(1):工程
核心模式
顺序的
具有修订功能的迭代优化。非常适合逐步解决问题。
mode: 'sequential'
// Use for: Debugging, algorithmic thinking, systematic analysis香农
五阶段系统问题解决方法→ 约束→ 模型→ 证明→ 实施)。
mode: 'shannon'
// Use for: Engineering problems, system design, complex optimizations数学
定理证明、引理推导、支持LaTeX的符号计算。
mode: 'mathematics'
// Use for: Proofs, mathematical modeling, symbolic algebra物理学
张量数学、量纲分析、守恒定律、场论。
mode: 'physics'
// Use for: Physical modeling, dimensional analysis, scientific computing混合
根据问题特征智能组合多种推理模式。
mode: 'hybrid'
// Use for: Complex multi-faceted problems requiring diverse approaches历史推理(v9.1.0)
历史的
综合历史分析,包括来源评估、模式识别和因果链分析。
mode: 'historical'
// Use for: Historical research, source criticism, event analysis, periodization
// Features: 5 thought types, aggregate reliability scoring, pattern detection5种思维类型:
event_analysis-用重要性评级分析历史事件source_evaluation-用可靠性评分评估一级/二级/三级来源pattern_identification-识别跨时间的重复模式(周期性、结构性、偶然性)causal_chain-用置信度得分追踪因果关系periodization-定义和分析具有特征的历史时期
数据结构:
HistoricalEvent-带有日期、参与者、因果关系、重要性级别的事件HistoricalSource-来源类型、可靠性(0-1)、偏差分析、佐证HistoricalPeriod-具有特征、关键事件、过渡的时间段CausalChain-与证据和信心相关的因果关系HistoricalActor-个人、团体、机构、国家、运动
处理器特性:
- 总可靠性计算(按源类型加权,并附有佐证奖金)
- 因果链连续性验证
- 从事件中自动检测模式
- 时间跨度计算
- 交叉引用验证(事件↔ 来源↔ 演员)
高级模式
因果
构建因果图,分析干预措施和效果。
mode: 'causal'
// Use for: Impact analysis, system design, decision making贝叶斯
基于先验、可能性和证据更新的概率推理。
mode: 'bayesian'
// Use for: Risk assessment, A/B testing, uncertainty quantification反事实
探索替代方案并比较结果。
mode: 'counterfactual'
// Use for: Post-mortems, strategic planning, what-if analysis类比
通过识别结构相似性跨领域转移知识。
mode: 'analogical'
// Use for: Design patterns, innovative problem-solving, knowledge transfer专业模式
时间
使用Allen的区间代数对事件、区间和时间关系进行建模。
mode: 'temporal'
// Use for: Timeline analysis, scheduling, event sequencing博弈论
分析战略互动,计算纳什均衡,构建博弈树。
mode: 'game-theory'
// Use for: Competitive analysis, mechanism design, strategic decisions证据的
Dempster-Shafer不确定证据推理理论。
mode: 'evidential'
// Use for: Sensor fusion, intelligence analysis, incomplete information基本原则
使用演绎推理从基本公理中得出结论。
mode: 'first-principles'
// Use for: Fundamental analysis, conceptual understanding, basic truths元推理
对推理过程进行战略监督——监控有效性,建议模式切换,评估质量。
mode: 'metareasoning'
// Use for: Strategy evaluation, adaptive mode switching, quality assessment
// Metrics: Effectiveness, Efficiency, Confidence, Quality (6 dimensions)
// Auto-switches at effectiveness **备注**DeepThinking MCP是一个MCP服务器,而不是一个库。这些功能可以通过MCP工具和内部架构访问。以下示例描述了内部功能。
### 证明分解(v7.0.0)
具有证明分析的高级数学推理:
- **校对分解器**:使用依赖图将证明分解为原子语句
- **镓分析仪**:检测缺失的步骤、不合理的跳跃、隐含的假设
- **假设跟踪器**:将结论追溯到其支持的假设
- **不一致检测器**:查找循环依赖关系和矛盾
- **原生SVG导出**:无需外部工具即可生成证明可视化
### 搜索引擎
带有分面过滤和相关性排名的全文搜索。内部用于按模式、标签、日期范围和内容在推理会话中搜索。
### 模板系统
用于常见推理模式的预构建模板,可通过会话创建访问。
### 文件导出系统
将推理会话直接导出到具有自动目录组织的文件中:
- **自动文件输出** -配置 `MCP_EXPORT_PATH` 将导出写入磁盘而不是返回内容
- **会话子目录** -按会话ID组织文件,便于管理
- **导出配置文件** -预配置捆绑包: `academic` (LaTeX+Markdown+JSON), `presentation` (美人鱼+HTML+ASCII), `documentation`, `archive`, `minimal`
- **8种导出格式** -Markdown、LaTeX、JSON、HTML、Jupyter、Mermaid、DOT、ASCII
- **覆盖保护** -除非满足以下条件,否则文件不会被覆盖 `overwrite: true` 或 `MCP_EXPORT_OVERWRITE=true`
// Export single format { "action": "export", "sessionId": "...", "exportFormat": "mermaid" }
// Export with profile { "action": "export", "sessionId": "...", "exportProfile": "academic" }
// Export all 8 formats { "action": "export_all", "sessionId": "..." }
### 安全与验证
MCP服务器内置的企业级安全功能:
- **输入验证** -Zod模式验证所有33个模式输入
- **速率限制** -用于API保护的滑动窗口速率限制器
- **路径消毒** -防止目录遍历攻击
- **PII补救措施** -符合GDPR的日志清理
### 分类学分类器
使用12个类别的69种推理类型对推理任务进行智能分类。使用 `recommend_mode` 行动中 `deepthinking_session` 根据问题特征获得模式建议。
## API 文档
### MCP工具接口
所有推理都是通过MCP工具完成的。每个工具都接受参数并返回JSON响应。
#### 通用参数(所有思维工具)
|参数|类型|必填|说明|
|-----------|------|----------|-------------|
| `sessionId` |string |否|会话ID(如果省略,则自动创建)|
| `thought` |string |是|推理内容|
| `thoughtNumber` |integer |是|当前想法数(从1开始)|
| `totalThoughts` |integer |是|估计总想法|
| `nextThoughtNeeded` |boolean |是|是否需要更多推理|
| `mode` |string |是|推理模式|
#### 会话操作(`deepthinking_session`)
|操作|参数|描述|
|--------|------------|-------------|
| `summarize` | `sessionId` |生成会话摘要|
| `export` | `sessionId`, `exportFormat` |导出为格式(json、markdown、latex、html、jupyter、mermaid、dot、ascii、svg)|
| `get_session` | `sessionId` |获取会话详细信息|
| `switch_mode` | `sessionId`, `newMode` |切换推理模式|
| `recommend_mode` | `problemType` 或 `problemCharacteristics` |获取模式建议|
#### 示例响应
{ "sessionId": "session-abc123", "thoughtId": "thought-xyz789", "thoughtNumber": 1, "mode": "sequential", "nextThoughtNeeded": true, "sessionComplete": false, "totalThoughts": 3 }
有关架构的详细信息,请参阅 [文档/架构/](docs/architecture/).
## 项目统计
|度量|值|
|--------|-------|
|TypeScript文件| 237|
|代码行|~102500|
|测试文件|181|
|通过测试| 5048|
|思维模式|34(30种思维类型)|
|ModeHandlers | 37个专业处理程序|
|MCP工具| 13个重点工具|
|导出格式|8+原生SVG|
|可视化导出器|42个文件(特定于24种模式)|
|构建器类| 14个流畅的API|
|推理类型|69(计划110)|
|模块|15|
|出口总额|1275(571转口)|
## 建筑
代码库被组织成15个模块,并进行了清晰的关注点分离。看 [文档/架构/依赖关系_GRAPH.md](docs/architecture/DEPENDENCY_GRAPH.md) 对于完整的依赖关系图。
### 核心结构
src/ ├── index.ts # MCP server entry point (tool handlers) ├── types/ # Type definitions including 33 mode types (36 files) │ ├── core.ts # ThinkingMode enum, Thought union type │ └── modes/ # One file per reasoning mode ├── services/ # Business logic layer (2 files) │ ├── ThoughtFactory.ts # Thought creation with handler integration │ └── ExportService.ts # Multi-format export handling ├── session/ # SessionManager, persistence, storage (4 files) ├── modes/ # ModeHandler architecture (v9.x) - 52 files │ ├── handlers/ # 38 specialized handlers (all modes covered) │ │ ├── CausalHandler.ts # Graph validation, cycle detection │ │ ├── BayesianHandler.ts # Auto posterior calculation │ │ ├── GameTheoryHandler.ts # Nash equilibria detection │ │ ├── CounterfactualHandler.ts # World state tracking │ │ ├── SynthesisHandler.ts # Source coverage tracking │ │ ├── SystemsThinkingHandler.ts # 8 Systems Archetypes │ │ ├── CritiqueHandler.ts # 6 Socratic categories │ │ └── [+ 31 more specialized handlers] │ └── registry.ts # ModeHandlerRegistry singleton ├── proof/ # Proof decomposition system (13 files) │ ├── decomposer.ts # ProofDecomposer class │ ├── gap-analyzer.ts # GapAnalyzer class │ └── assumption-tracker.ts # AssumptionTracker class └── tools/ # MCP tool definitions and schemas (18 files)
### 模式处理器架构(v9.x)
ModeHandler模式(策略模式)提供特定于模式的处理 **全部33种模式完全覆盖**:
// Handler interface interface ModeHandler { mode: ThinkingMode; validate(input: ThinkingToolInput): ValidationResult; enhance(thought: Thought, context: SessionContext): Thought; getSuggestions(thought: Thought): string[]; }
// Registry manages all 38 handlers const registry = ModeHandlerRegistry.getInstance(); registry.hasSpecializedHandler('causal'); // true for ALL 33 modes
**优点:**
- 所有33种模式都有专门的验证逻辑
- 自动增强(后验、均衡、原型)
- 特定模式的建议和警告
- 与ThoughtFactory彻底分离
- 总共38个处理程序(33种模式+通用模式处理程序+自定义处理程序+实用程序)
### 功能模块
src/ ├── taxonomy/ # 69 reasoning types, classifier, suggestion engine (5 files) │ ├── reasoning-types.ts # Full taxonomy definitions │ ├── classifier.ts # Task classification │ └── suggestion-engine.ts # Mode recommendations ├── export/ # Visual and document exporters (44 files) │ ├── visual/ # Mode-specific visual exporters + native SVG │ │ ├── proof-decomposition.ts # Proof visualization │ │ ├── utils/ # 14 builder classes │ │ └── modes/ # 22 mode-specific exporters │ └── latex.ts # LaTeX document generation ├── search/ # Full-text search with TF-IDF (3 files) ├── cache/ # LRU caching strategies (3 files) ├── validation/ # Zod schemas (44 files, 35 validators) └── utils/ # Utility functions (6 files)
### 安全特性
安全性内置于多个模块中:
- **验证/** -使用Zod模式对所有33种模式进行输入验证(35个验证器)
- **utils/sanitation.ts** -路径清理和穿越预防
- **utils/log-sanitizer.ts** -符合GDPR的PII编辑
- **utils/errors.ts** -带上下文的标准化错误层次结构
## 贡献
我们欢迎捐款!请在上打开问题或拉取请求 .
### 添加新的推理模式
想添加新的推理模式吗?我们让它变得简单:
📖 **[完整指南:添加新模式](docs/ADDING_NEW_MODE.md)**
本指南包括:
- 所有8个必需文件的分步说明
- 中的模板文件 `templates/mode-scaffolding/`
- 代码示例和常见模式
- 完成检查表,确保没有遗漏任何内容
- 测试指南
**快速开始**:
Copy template files
cp templates/mode-scaffolding/example-mode.type.ts src/types/modes/yourmode.ts cp templates/mode-scaffolding/example-mode.validator.ts src/validation/validators/modes/yourmode.ts
Follow the guide
cat docs/ADDING_NEW_MODE.md
### 开发设置
Clone repository
git clone https://github.com/danielsimonjr/deepthinking-mcp.git cd deepthinking-mcp
Install dependencies
npm install
Run tests
npm test
Run type checking
npm run typecheck
Build
npm run build
### 运行测试
Run all tests
npm test
Run specific test file
npm test -- path/to/test.test.ts
Run with coverage
npm run test:coverage
## 许可证
MIT许可证-请参阅 [许可证](LICENSE) 文件以获取详细信息。
## 致谢
该项目建立在MCP社区的基础工作之上:
- **[人的顺序思维](https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking)** -启发该项目核心架构的原始顺序思维服务器
- **[olaservo的香农思维MCP](https://github.com/olaservo/shannon-thinking)** -引入了香农5阶段方法论,该方法论成为我们的核心推理模式之一
其他致谢:
- 建立在 [模型上下文协议](https://modelcontextprotocol.io)
- 受认知科学和人工智能推理研究的启发
- 研究人员和从业者的社区贡献
## 支持
- 📚 [文档](docs/)
- 🐛 [问题追踪](https://github.com/danielsimonjr/deepthinking-mcp/issues)
- 💬 [讨论](https://github.com/danielsimonjr/deepthinking-mcp/discussions)
______________________________________________________________________
制作❤️ 由DeepThinking MCP团队