关于 Mcp Thinking
MCP Thinking 是为 AI Agent 提供结构化思考能力的 MCP 服务,面向需要处理复杂推理任务的应用。它提供 19 种思考模式,以及会话管理、置信度评估和认知偏差检测。
主要功能
- 0119 种思考模式
- 02树状思路与元认知分析
- 03逻辑一致性检查
- 04多会话管理与导出
- 05置信度和偏差分析
适用场景
- 01拆解复杂问题并探索备选方案
- 02分析研究材料与论据
- 03比较决策方案并检查偏差
MCP 相关
该 MCP 服务通过标准化接口向 AI Agent 提供思考能力,并以 SSE 连接支持客户端会话。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
MCP Thinking 🤖
一款功能强大的模型上下文协议(MCP)服务,通过先进的序列化思考能力增强大模型(LLM)。该服务基于模型上下文协议标准构建,可让 AI Agent 执行结构化推理,并高精度地完成复杂认知任务。
📑 目录
概述
MCP Thinking Server 是一款基于 Model Context Protocol(MCP) 标准构建的强大思考引擎。该服务通过标准化接口实现先进的思考能力,使 AI Agent 能够参与复杂的认知过程。
如需详细了解 MCP 标准,请参阅 MCP 官方规范。
✨ 主要功能
-
🤖 高级思考
- 19 种不同的思考模式
- 树状思维
- 元认知分析
- 逻辑一致性检查
-
🔄 会话管理
- 基于 UUID 的标识
- 稳健的上下文处理
- 全面的导出工具
- 支持多会话
-
🔍 质量与分析
- 置信度评估
- 认知偏差检测
- 自适应规划
- 多语言支持
-
⚡ 性能
- 异步优先架构
- 高效的资源管理
- 支持水平扩展
- 优化的会话处理
🏗️ 架构
系统概述
graph TB
Client[Client Application] -->|SSE Connection| Server[MCP Server]
Server -->|Process| Thinking[Thinking Engine]
Thinking -->|Manage| Sessions[Session Manager]
Thinking -->|Execute| Tools[Tool Executor]
Thinking -->|Analyze| Metacognition[Metacognitive Analyzer]
subgraph "MCP Server Components"
Sessions
Tools
Metacognition
end
subgraph "Thinking Modes"
Linear[Linear Thinking]
Tree[Tree Thinking]
Dialectical[Dialectical Thinking]
Creative[Creative Thinking]
end
Thinking --> Linear
Thinking --> Tree
Thinking --> Dialectical
Thinking --> Creative
会话流程
sequenceDiagram
participant Client
participant Server
participant Session
participant Engine
Client->>Server: Connect (SSE)
Server->>Session: Create Session
Session-->>Client: Session ID
loop Thinking Process
Client->>Server: Send Thought
Server->>Engine: Process Thought
Engine->>Session: Update Context
Session-->>Client: Analysis Result
end
Client->>Server: Export Session
Server->>Session: Gather Data
Session-->>Client: Export Result
思考模式交互
graph LR
Input[Input Thought] --> Mode[Thinking Mode]
Mode --> Analysis[Analysis]
Mode --> Synthesis[Synthesis]
Mode --> Evaluation[Evaluation]
Analysis --> Output[Output Thought]
Synthesis --> Output
Evaluation --> Output
subgraph "Thinking Process"
Mode
Analysis
Synthesis
Evaluation
end
🚀 快速开始
先决条件
- Python 3.13+
- Git
- pip(Python 包管理器)
安装
```bash
克隆代码仓库
git clone https://github.com/VitalyMalakanov/mcp-thinking.git cd mcp-thinking
创建并激活虚拟环境(推荐)
python -m venv venv
source venv/bin/activate # Linux/macOS .\venv\Scripts\activate # Windows
安装依赖
pip install -r requirements.txt
启动服务
python enhanced_sequential_thinking_server.py
The server will be available at `http://localhost:8000/sse`
### Docker Support
```bash
# Using Docker
docker-compose up
# Custom port
MCP_SERVER_PORT=8080 docker-compose up
🧠 思考模式
Enhanced Sequential Thinking Server 支持 19 种不同的思考模式,每种模式都针对特定类型的认知任务而设计:
线性思考
- 用途: 按顺序逐步推理
- 适用于:
- 将复杂问题拆解为易于处理的步骤
- 遵循逻辑顺序
- 构建结构化论证
- 特点:
- 清晰的因果关系
- 可预测的推进过程
- 系统化的方法
- 示例用法:
EnhancedThinkingInput( thought="Implementing a new feature requires: 1) Requirements analysis, 2) Design, 3) Development, 4) Testing", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.LINEAR, tags=["process", "implementation"] )
树状思考
- 用途: 探索多条思维分支
- 适用于:
- 探索替代方案
- 决策树分析
- 复杂问题分解
- 特点:
- 分支式探索
- 多条路径
- 层级结构
- 示例用法:
EnhancedThinkingInput( thought="Exploring different approaches to market entry: direct sales, partnerships, acquisitions", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.TREE, tags=["strategy", "exploration"] )
辩证思考
- 用途: 通过综合化解矛盾
- 适用于:
- 化解冲突
- 寻找共同点
- 制定全面的解决方案
- 特点:
- 正题—反题—合题
- 冲突化解
- 对立面的整合
- 示例用法:
EnhancedThinkingInput( thought="Analyzing opposing views on remote work: productivity vs. collaboration, finding optimal balance", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.DIALECTICAL, tags=["conflict", "resolution"] )
系统化思考
- 用途: 以组件为基础进行系统分析
- 适用于:
- 复杂系统分析
- 流程优化
- 质量改进
- 特点:
- 基于组件的分析
- 有条理的方法
- 系统化评估
- 示例用法:
EnhancedThinkingInput( thought="Analyzing software architecture components: frontend, backend, database, and their interactions", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.SYSTEMATIC, tags=["architecture", "analysis"] )
创造性思考
- 用途: 生成新颖的想法和解决方案
- 适用于:
- 头脑风暴
- 创新挑战
- 寻求多种解决方案的问题
- 特点:
- 发散式创意生成
- 打破思维定式
- 建立新颖的联系
- 示例用法:
EnhancedThinkingInput( thought="Exploring unconventional approaches to renewable energy storage using biomimicry principles", thought_type=ThoughtType.HYPOTHESIS, strategy=ThinkingStrategy.CREATIVE, tags=["innovation", "biomimicry"] )
分析性思考
- 用途: 严谨的逻辑分析与推理
- 适用于:
- 数据分析
- 科学研究
- 技术问题解决
- 特点:
- 演绎推理
- 归纳推理
- 基于证据的结论
- 示例用法:
EnhancedThinkingInput( thought="Analyzing market data trends: correlation analysis, statistical significance, predictive modeling", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.ANALYTICAL, tags=["data", "analysis"] )
元认知思维
- 目的: 对思维过程进行自我分析
- 最适用于:
- 改进流程
- 优化学习
- 完善策略
- 特点:
- 自我反思
- 流程意识
- 策略评估
- 使用示例:
EnhancedThinkingInput( thought="Reflecting on problem-solving approach: effectiveness, biases, and potential improvements", thought_type=ThoughtType.METACOGNITION, strategy=ThinkingStrategy.METACOGNITIVE, tags=["reflection", "improvement"] )
批判性思维
- 目的: 进行分析性评估与判断
- 最适用于:
- 评估论点与证据
- 识别逻辑谬误
- 做出明智决策
- 特点:
- 基于证据的推理
- 系统性评估
- 对偏见保持警觉
- 使用示例:
EnhancedThinkingInput( thought="Analyzing the validity of market research data: sample size, methodology, potential biases", thought_type=ThoughtType.EVALUATION, strategy=ThinkingStrategy.CRITICAL, tags=["analysis", "validation"] )
系统思维
- 目的: 理解复杂系统及其相互作用
- 最适用于:
- 系统分析
- 理解相互依赖关系
- 整体性地解决问题
- 特点:
- 系统视角
- 对相互关联的认知
- 涌现行为分析
- 使用示例:
EnhancedThinkingInput( thought="Analyzing the impact of climate change on global supply chains: direct effects, feedback loops, and systemic risks", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.SYSTEMIC, tags=["systems", "climate"] )
横向思维
- 目的: 寻找非常规解决方案
- 最适用于:
- 创造性地解决问题
- 打破思维障碍
- 寻找创新解决方案
- 特点:
- 非线性方法
- 打破思维定式
- 建立非常规联系
- 使用示例:
EnhancedThinkingInput( thought="Exploring unexpected applications of blockchain technology in healthcare data management", thought_type=ThoughtType.HYPOTHESIS, strategy=ThinkingStrategy.LATERAL, tags=["innovation", "blockchain"] )
战略思维
- 目的: 长期规划与目标导向推理
- 最适用于:
- 战略规划
- 资源分配
- 风险评估
- 特点:
- 目标导向分析
- 资源优化
- 面向未来的规划
- 使用示例:
EnhancedThinkingInput( thought="Developing a 5-year technology roadmap considering market trends, resource constraints, and competitive landscape", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.STRATEGIC, tags=["planning", "roadmap"] )
共情思维
- 目的: 理解他人的视角
- 最适用于:
- 用户体验设计
- 冲突解决
- 团队协作
- 特点:
- 换位思考
- 情绪觉察
- 以用户为中心
- 使用示例:
EnhancedThinkingInput( thought="Analyzing user feedback to understand pain points in the current interface design", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.EMPATHETIC, tags=["ux", "feedback"] )
抽象思维
- 目的: 运用模型与概括进行思考
- 最适用于:
- 理论分析
- 模型开发
- 模式识别
- 特点:
- 概念建模
- 模式抽象
- 理论框架构建
- 使用示例:
EnhancedThinkingInput( thought="Developing a theoretical framework for understanding complex adaptive systems in organizations", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.ABSTRACT, tags=["theory", "modeling"] )
实践思维
- 目的: 聚焦实施与结果
- 最适用于:
- 项目执行
- 资源管理
- 解决方案实施
- 特点:
- 以行动为导向
- 关注资源
- 注重结果
- 使用示例:
EnhancedThinkingInput( thought="Planning the implementation of a new feature: resource allocation, timeline, and deliverables", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.PRACTICAL, tags=["implementation", "planning"] )
整合思维
- 目的: 综合不同观点
- 最适用于:
- 复杂问题解决
- 多利益相关方分析
- 整体性决策
- 特点:
- 综合不同观点
- 整体整合
- 多视角分析
- 使用示例:
EnhancedThinkingInput( thought="Integrating technical, business, and user perspectives in product development strategy", thought_type=ThoughtType.SYNTHESIS, strategy=ThinkingStrategy.INTEGRATIVE, tags=["integration", "strategy"] )
演进思维
- 目的: 迭代开发与适应
- 最适用于:
- 产品演进
- 改进流程
- 持续学习
- 特点:
- 迭代方法
- 注重适应
- 持续改进
- 使用示例:
EnhancedThinkingInput( thought="Analyzing product evolution through user feedback cycles and market adaptation", thought_type=ThoughtType.ANALYSIS, strategy=ThinkingStrategy.EVOLUTIONARY, tags=["evolution", "adaptation"] )
聚合思维
- 目的: 寻找最优解决方案
- 最适用于:
- 决策
- 解决方案优化
- 问题解决
- 特点:
- 以解决方案为导向
- 缩小选项范围
- 以优化为导向
- 使用示例:
EnhancedThinkingInput( thought="Evaluating and selecting the optimal cloud infrastructure solution based on requirements", thought_type=ThoughtType.EVALUATION, strategy=ThinkingStrategy.CONVERGENT, tags=["decision", "optimization"] )
发散思维
- 目的: 探索多种视角与可能性
- 最适用于:
- 生成备选方案
- 探索不同观点
- 质疑假设
- 特点:
- 生成多种解决方案
- 转换视角
- 质疑假设
- 使用示例:
EnhancedThinkingInput( thought="Exploring various approaches to urban transportation: autonomous vehicles, public transit, micro-mobility, and their combinations", thought_type=ThoughtType.QUESTION, strategy=ThinkingStrategy.DIVERGENT, tags=["transportation", "urban_planning"] )
反思性思考
- 目的: 自我分析与学习
- 适用场景:
- 改进流程
- 从经验中学习
- 个人发展
- 特点:
- 自我反思
- 经验分析
- 提炼经验
- 使用示例:
EnhancedThinkingInput( thought="Analyzing project outcomes and extracting key lessons for future improvements", thought_type=ThoughtType.METACOGNITION, strategy=ThinkingStrategy.REFLECTIVE, tags=["reflection", "learning"] )
每种思考模式都可以与不同的思维类型(分析、假设、评估、观察、提问等)结合,构建强大的推理链。服务器的元认知分析可帮助 Agent 了解哪种思考模式最适合特定任务,并据此调整方法。
🔄 会话管理
Enhanced Sequential Thinking Server 提供强大的会话管理功能,可处理多个并发思考过程:
会话生命周期
- 创建: 客户端连接到 SSE 端点时,会自动创建会话
- 标识: 每个会话都会获得一个唯一的 UUID(例如,
e1e8e0732ac84c908deabf136c6a1a69) - 持续时间: 会话会一直保留,直到明确关闭或超时
- 并发: 多个会话可以同时运行
会话操作
# Example: Working with sessions
async with sse_client(url="http://localhost:8000/sse") as (read_stream, write_stream):
session = ClientSession(read_stream, write_stream)
await session.initialize()
# Send thoughts within the session
result = await session.call_tool("enhanced_thinking", {
"thought": "Analyzing market trends",
"thought_type": "ANALYSIS",
"strategy": "SYSTEMIC"
})
# Export session data
export_result = await session.call_tool("export_thinking_session", {
"format_type": "markdown" # or "json", "summary"
})
会话分析
服务器提供了用于分析思考会话的工具:
# Get session analysis
analysis = await session.call_tool("analyze_thinking_session")
# Get thinking path for a specific thought
path = await session.call_tool("get_thinking_path", {
"thought_id": "thought_123"
})
# Perform metacognitive reflection
reflection = await session.call_tool("metacognitive_reflection", {
"focus_area": "Reasoning quality",
"analysis_depth": 3
})
会话导出格式
服务器支持以多种格式导出会话数据:
-
Markdown 导出
- 易于阅读的格式
- 包含思考链和分析
- 适用于文档编写
-
JSON 导出
- 完整的会话数据
- 包含元数据和关系
- 适用于程序化分析
-
摘要导出
- 简明概览
- 关键见解和模式
- 适用于快速查看
错误处理
服务器为会话实现了稳健的错误处理:
- 无效的会话 ID 会返回 400 Bad Request
- 妥善处理连接超时
- 重新连接时保留会话状态
- 自动清理过期会话
最佳实践
-
会话管理
- 正确初始化会话
- 处理重新连接场景
- 完成后清理资源
-
错误处理
- 实施适当的错误处理
- 使用恰当的超时时间
- 处理连接重置
-
性能
- 尽可能重用会话
- 监控会话状态
- 定期导出数据
📊 监控与日志记录
服务器提供全面的日志记录和监控功能:
日志级别
- INFO: 正常运行事件
- WARNING: 潜在问题(例如,无效的会话 ID)
- ERROR: 严重错误(例如,连接重置)
日志类别
- 服务器初始化和启动
- 会话管理
- 请求处理
- 错误处理
- 性能指标
日志输出示例
2025-05-25 19:33:47,417 - __main__ - INFO - Server initialization completed
2025-05-25 19:59:19,367 - mcp.server.sse - WARNING - Received invalid session ID
2025-05-25 20:00:22,769 - asyncio - ERROR - Connection reset by peer
监控端点
- 健康检查端点
- 会话统计信息
- 性能指标
- 错误率
🔒 安全注意事项
服务器实施了多项安全措施:
会话安全
- 基于 UUID 的会话标识
- 会话超时机制
- 按会话进行速率限制
- 输入验证
数据保护
- 输入清理
- 输出编码
- 安全的会话处理
- 资源限制
最佳实践
-
配置
- 使用安全的会话超时时间
- 实施速率限制
- 配置适当的资源限制
-
部署
- 在生产环境中使用 HTTPS
- 实施适当的访问控制
- 监控可疑活动
-
维护
- 定期进行安全更新
- 清理会话
- 监控日志
📈 性能优化
该服务器旨在满足各种场景下的最佳性能要求:
资源管理
- 内存使用: 高效管理长时间运行的会话所占用的内存
- CPU 利用率: 优化思考链处理
- 连接池: 智能处理并发连接
- 缓存管理: 智能缓存常用数据
扩展性考量
- 水平扩展: 支持多个服务实例
- 负载均衡: 兼容标准负载均衡器
- 会话分配: 在多个实例之间高效处理会话
- 资源分配: 根据负载动态调整资源
性能指标
- 响应时间: 标准操作的平均响应时间 < 100ms
- 并发会话: 支持 1000+ 个同时进行的会话
- 吞吐量: 每秒可处理 100+ 个思考
- 内存占用: 基础内存用量约为 50MB
🔧 故障排除指南
常见问题及其解决方案:
连接问题
-
连接重置错误
ConnectionResetError: [WinError 10054] Remote host forcibly closed the connection- 检查客户端网络稳定性
- 验证服务端超时设置
- 确保正确清理会话
-
无效会话 ID
WARNING - Received invalid session ID: test_session- 验证会话初始化
- 检查会话 ID 格式
- 确保正确管理会话
服务问题
-
启动问题
- 验证 Python 版本(3.13+)
- 检查端口是否可用
- 查看系统要求
-
性能问题
- 监控资源使用情况
- 检查连接限制
- 查看会话管理
客户端问题
-
超时错误
- 调整客户端超时设置
- 检查网络延迟
- 验证服务端负载
-
会话管理
- 实现正确的会话清理
- 处理重新连接场景
- 监控会话状态
📚 API 参考
核心端点
| 端点 | 方法 | 描述 |
|---|---|---|
/sse | GET | 建立 SSE 连接 |
/messages | POST | 处理思考请求 |
/health | GET | 健康检查端点 |
请求类型
| 类型 | 描述 | 示例 |
|---|---|---|
| 增强思考 | 处理思考内容 | 查看示例 |
| 元认知 | 分析思考过程 | 查看示例 |
| 策略调整 | 调整思考方式 | 查看示例 |
增强思考
{
"thought": "string",
"thought_type": "ANALYSIS|HYPOTHESIS|EVALUATION|OBSERVATION|QUESTION",
"strategy": "LINEAR|TREE|DIALECTICAL|...",
"tags": ["string"]
}
元认知反思
{
"focus_area": "string",
"analysis_depth": integer
}
策略调整
{
"current_strategy": "string",
"effectiveness_score": float,
"context": "string",
"constraints": ["string"]
}
响应格式
成功响应
{
"thought_id": "uuid",
"analysis": {
"coherence": float,
"confidence": float,
"insights": ["string"]
},
"metadata": {
"timestamp": "iso8601",
"thought_type": "string",
"strategy": "string"
}
}
错误响应
{
"error": "string",
"details": {
"code": "string",
"message": "string"
}
}
💡 使用场景
1. 复杂问题解决
商业策略分析
graph TD
A[Market Analysis] -->|Systemic Thinking| B[Trend Identification]
B -->|Critical Thinking| C[Risk Assessment]
C -->|Creative Thinking| D[Strategy Development]
D -->|Strategic Thinking| E[Implementation Plan]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333
style D fill:#fbf,stroke:#333
style E fill:#fbb,stroke:#333
AI Agent 交互流程:
- Agent 使用 SSE 端点连接到 MCP 服务
- 使用唯一 UUID 建立会话
- 通过 MCP 协议依次发送思考内容
- 实时接收分析结果和洞见
- 根据元认知反馈调整策略
2. 研究与分析
文献综述流程
graph TD
A[Research Question] -->|Linear Thinking| B[Literature Search]
B -->|Analytical Thinking| C[Data Extraction]
C -->|Systemic Thinking| D[Pattern Analysis]
D -->|Critical Thinking| E[Synthesis]
E -->|Creative Thinking| F[New Insights]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333
style D fill:#fbf,stroke:#333
style E fill:#fbb,stroke:#333
style F fill:#bff,stroke:#333
MCP 协议流程:
- Agent 发起研究会话
- 使用 MCP 工具进行结构化分析
- 通过会话管理保持上下文
- 实时接收分析结果
- 以多种格式导出研究结果
3. 决策制定
决策流程
graph TD
A[Problem Definition] -->|Observation| B[Data Collection]
B -->|Analysis| C[Option Generation]
C -->|Evaluation| D[Option Assessment]
D -->|Strategy| E[Decision]
E -->|Reflection| F[Implementation]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333
style D fill:#fbf,stroke:#333
style E fill:#fbb,stroke:#333
style F fill:#bff,stroke:#333
MCP 集成要点:
- Agent 建立决策会话
- 使用 MCP 思考模式进行分析
- 接收结构化反馈
- 根据 MCP 洞见调整策略
- 保持决策上下文
4. 创造性问题解决
创新流程
graph TD
A[Problem Space] -->|Divergent Thinking| B[Idea Generation]
B -->|Convergent Thinking| C[Solution Filtering]
C -->|Creative Thinking| D[Prototype Design]
D -->|Critical Thinking| E[Feasibility Check]
E -->|Strategic Thinking| F[Implementation]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333
style D fill:#fbf,stroke:#333
style E fill:#fbb,stroke:#333
style F fill:#bff,stroke:#333
MCP Agent 工作流:
- Agent 连接到创新会话
- 使用多种思考模式
- 实时接收创造性反馈
- 保持创新上下文
- 导出创造过程的结果
5. 多 Agent 协作
协作式问题解决
graph TD
A[Problem Space] -->|Agent 1| B[Analysis]
B -->|Agent 2| C[Synthesis]
C -->|Agent 3| D[Evaluation]
D -->|Agent 4| E[Implementation]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333
style D fill:#fbf,stroke:#333
style E fill:#fbb,stroke:#333
MCP 多 Agent 功能:
- 共享会话上下文
- 实时协调 Agent
- 结构化通信
- 基于角色的思考模式
- 协作式元认知
6. 学习与适应
自适应学习流程
graph TD
A[Learning Goal] -->|Observation| B[Experience]
B -->|Analysis| C[Pattern Recognition]
C -->|Synthesis| D[Knowledge Integration]
D -->|Evaluation| E[Strategy Adaptation]
style A fill:#f9f,stroke:#333
style B fill:#bbf,stroke:#333
style C fill:#bfb,stroke:#333
style D fill:#fbf,stroke:#333
style E fill:#fbb,stroke:#333
MCP 学习支持:
- 结构化学习会话
- 元认知分析
- 自适应策略选择
- 进度跟踪
- 知识整合
每个用例都展示了 AI Agent 如何利用 MCP 协议来:
- 建立结构化思考会话
- 运用多种思考模式
- 保持上下文连贯
- 接收实时分析
- 根据反馈调整策略
- 以多种格式导出结果
MCP 标准确保 AI Agent 与思考服务之间的交互一致、可靠且高效,从而能够以高精度和良好的适应性完成复杂的认知任务。
🌟 社区与支持
获取帮助
- GitHub Issues: 在 mcp-thinking issues 报告错误并请求功能
- 讨论: 在 mcp-thinking discussions 参与社区讨论
贡献
欢迎贡献!你可以通过以下方式提供帮助:
-
代码贡献
- Fork 此仓库
- 创建功能分支
- 提交拉取请求
-
文档
- 改进现有文档
- 添加示例
- 修正拼写错误
-
测试
- 编写单元测试
- 报告错误
- 提出改进建议
社区准则
- 尊重他人,包容多元
- 遵守行为准则
- 帮助他人学习
- 分享你的经验
📊 项目统计
🔍 关键词
#AI #MachineLearning #LLM #Reasoning #CognitiveComputing #Python #AsyncIO #FastAPI #MCP #ThinkingEngine #SequentialThinking #Metacognition #CognitiveArchitecture #AIReasoning #ThoughtChains #DecisionMaking #ProblemSolving #CognitiveScience #ArtificialIntelligence #MachineReasoning
📝 更新日志
[1.0.0] - 2024-05-25
- 首次发布
- 核心思考服务功能
- 会话管理
- 多种思考模式
- 元认知分析
- 导出功能
[0.9.0] - 2024-05-20
- Beta 版发布
- 基础思考服务
- 初始会话支持
- 核心思考模式
🔮 路线图
项目路线图即将发布。
📄 许可证
本项目采用 MIT License 许可。详情请参阅 LICENSE 文件。
🙏 致谢
- 感谢 FastAPI 提供出色的 Web 框架
- 感谢 Pydantic 提供数据验证功能
- 感谢 Uvicorn 提供 ASGI 服务
- 感谢开源社区带来的灵感与支持
本地安装
- 克隆仓库:
git clone https://github.com/VitalyMalakanov/mcp-thinking.git cd mcp-thinking ```
- 创建并激活虚拟环境:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ```
- 安装依赖:
pip install -r requirements.txt
主要依赖包括:
mcp[cli,http]- MCP 协议核心实现fastapi和uvicorn- Web 服务框架pydantic- 数据验证numpy和scikit-learn- 数据处理与分析textstat- 文本分析pytest和pytest-asyncio- 测试框架- 用于增强思考能力的其他依赖
客户端交互示例
以下是如何与服务交互的详细示例:
import asyncio
import json
from mcp.client.session import ClientSession
from mcp.client.sse import sse_client
from enhanced_sequential_thinking_server import EnhancedThinkingInput, ThoughtType, ThinkingStrategy
async def main():
async with sse_client(url="http://localhost:8000/sse", timeout=20) as (read_stream, write_stream):
session = ClientSession(read_stream, write_stream)
await session.initialize()
input_data = EnhancedThinkingInput(
thought="AI can significantly improve decision-making processes.",
thought_type=ThoughtType.ANALYSIS,
strategy=ThinkingStrategy.CRITICAL,
tags=["AI", "decision-making"]
)
# Using model_dump() for Pydantic v2+
result_list = await session.call_tool("enhanced_thinking", input_data.model_dump())
print("\nTool 'enhanced_thinking' result:")
if result_list and isinstance(result_list, list) and len(result_list) > 0:
# MCP tools typically return a single TextContent in the list for non-streaming responses
content_item = result_list[0]
if content_item.type == "text":
try:
# Attempt to parse JSON if expected
data = json.loads(content_item.text)
print(json.dumps(data, indent=2, ensure_ascii=False))
except json.JSONDecodeError:
# If not JSON, print the text directly
print(content_item.text)
else:
print(content_item) # For other content types
else:
print("No result or empty result list.")
await session.close()
if __name__ == "__main__":
asyncio.run(main())
Docker 测试
在 Docker 环境中运行测试:
- 确保你的
docker-compose.yml包含用于运行测试的服务:
services:
mcp-server:
build: .
volumes:
- .:/app
environment:
- LANG=en_US.UTF-8
mcp-tests:
build: .
volumes:
- .:/app
command: pytest tests/
depends_on:
- mcp-server
- 运行测试:
docker-compose run --rm mcp-tests
本地化
该服务通过环境变量支持多种语言:
- 使用环境变量(建议用于生产环境):
export LANG=ru_RU.UTF-8 # For Russian
python enhanced_sequential_thinking_server.py
- 以编程方式设置(用于开发):
from enhanced_sequential_thinking_server import EnhancedThinkingServer
server = EnhancedThinkingServer(language="ru") # For Russian
作者
Vitaly Malakanov
许可证
本项目采用 MIT 许可证。详情请参阅 LICENSE 文件。
致谢
- 感谢 FastAPI 提供出色的 Web 框架
- 感谢 Pydantic 提供数据验证功能
- 感谢 Uvicorn 提供 ASGI 服务
- 感谢开源社区提供灵感与支持
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。