关于 Model Context Protocol (MCP) Servers: Sequential Thinking with bonus Leave Management server.
这组基于 FastMCP 的 MCP 服务分别用于迭代式问题求解和 HR 假期管理,可同时启动并供 Claude Desktop 等客户端使用。
主要功能
- 01逐步推理并支持修订与分支
- 02按会话维护思考上下文
- 03查询假期余额、申请及历史
- 04提供个性化问候资源
- 05并发启动两个服务
适用场景
- 01规划供应链或其他多步骤任务
- 02查询员工假期余额
- 03提交假期日期并查看记录
MCP 相关
通过两个 MCP 服务提供 sequential_thinking 和假期管理工具,以及问候资源。启动脚本可并发运行这两个服务。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Model Context Protocol (MCP) 服务:顺序思考,另附休假管理服务。
本项目使用 FastMCP 框架实现了两个 Model Context Protocol (MCP) 服务:
- 顺序思考:用于结构化问题解决的工具,适用于供应链管理规划等任务。
- 休假管理器:供 HR 管理员工休假任务的 AI 工具,可与模拟休假数据库交互。
这些服务通过 main.py 脚本并发启动,并可通过 Claude Desktop 进行查询。Claude Desktop 可集成 MCP 服务,并使用 Model Context Protocol 发送 API 请求。
项目结构
directory/
├── main.py # Launches both MCP servers
├── leave_manager.py # Leave Manager MCP server
├── sequential.py # Sequential Thinking MCP server
功能
顺序思考 MCP 服务
- 用途:使用 Model Context Protocol 进行结构化、逐步的问题解决,适用于供应链管理等复杂任务的规划。
- 工具:
sequential_thinking- 将问题拆解为一系列思考步骤。
- 支持修改思考内容、为备选策略创建分支,以及动态调整步骤数量。
- 通过
sessionId保持上下文。
- 使用场景:规划供应链、项目或任何需要迭代推理的任务。
- 端口:运行于
http://localhost:8001。
休假管理器 MCP 服务
- 用途:使用 Model Context Protocol 协助 HR 管理员工休假。
- 工具:
get_leave_balance:查看员工剩余的休假天数。apply_leave:申请指定日期的休假。get_leave_history:查看员工的休假记录。
- 资源:
greeting://{name},用于发送个性化问候。 - 端口:运行于
http://localhost:8000。
主启动器
- main.py:使用
multiprocessing在各自的端口上并发运行两个服务。
前置要求
- Python:版本 3.8 或更高。
- Claude Desktop:用于向服务发送 MCP 查询。
- uv:用于安装依赖项的包管理器。
- 操作系统:已在 Linux(例如 Ubuntu)上测试。
设置步骤
按照以下步骤设置项目:
-
安装 Claude Desktop:
- 从官方来源下载并安装 Claude Desktop。
- 确保已配置好 API 查询发送方式(例如,通过查询输入框)。
-
安装 uv:
pip install uv -
创建项目目录:
uv init my-first-mcp-server cd my-first-mcp-server -
添加 MCP CLI:
uv add "mcp[cli]" -
添加服务代码:
- 将以下文件放入
my-first-mcp-server/:main.py:两个服务的启动器。leave_manager.py:休假管理器服务代码。sequential.py:顺序思考服务代码。
- 确保代码与提供的实现一致(请参阅项目仓库或文档)。
- 将以下文件放入
-
运行服务:
- 不要使用
uv run mcp install main.py(该命令可能因存在多个服务而失败),而应运行:uv run python main.py
- 不要使用
-
重启 Claude Desktop(如有需要):
- 通过任务管理器(Windows)或
killall(Linux)终止所有正在运行的 Claude Desktop 实例。 - 重启 Claude Desktop,确保其识别正在运行的服务。
- 通过任务管理器(Windows)或
用法
运行服务
使用以下命令启动两个服务:
cd ~/my-first-mcp-server
uv run python main.py
这将启动:
- 运行于
http://localhost:8000的休假管理器。 - 运行于
http://localhost:8001的顺序思考服务。
注意:保持终端打开,以维持服务运行。
通过 Claude Desktop 交互
使用 Claude Desktop 的查询输入框,通过 Model Context Protocol 向服务发送 JSON 查询。以下是两个服务的示例,重点展示如何使用顺序思考服务进行供应链管理。
Sequential Thinking MCP 服务
- 端点:
http://localhost:8001/tool/sequential_thinking - 用途:使用 MCP 将供应链拆分为多个步骤、修订计划或探索替代方案。
- 输入:将 JSON 查询粘贴到 Claude Desktop 的查询框中并提交。
示例:规划智能手表的供应链
-
确定目标:
{ "thought": "Define objective: Plan a cost-efficient supply chain for a new smartwatch, ensuring global delivery within 5 months.", "nextThoughtNeeded": true, "thoughtNumber": 1, "totalThoughts": 8 }- 在 Claude Desktop 中提交(例如,粘贴到查询框中并点击“发送”)。
- 从响应中复制
sessionId(例如,123e4567-...)。
-
选择供应商:
{ "sessionId": "<sessionId>", "thought": "Select suppliers: Source microchips from Supplier X (Taiwan), displays from Supplier Y (South Korea), batteries from Supplier Z (China).", "nextThoughtNeeded": true, "thoughtNumber": 2, "totalThoughts": 8 }- 将
<sessionId>替换为步骤 1 中的 ID。
- 将
-
规划制造:
{ "sessionId": "<sessionId>", "thought": "Plan manufacturing: Assemble smartwatches in Factory A (Vietnam) for low labor costs and supplier proximity.", "nextThoughtNeeded": true, "thoughtNumber": 3, "totalThoughts": 8 } -
修订供应商:
{ "sessionId": "<sessionId>", "thought": "Revised: Switch battery supplier to Supplier W (Japan) for better quality, despite 10% higher cost.", "nextThoughtNeeded": true, "thoughtNumber": 2, "totalThoughts": 8, "isRevision": true, "revisesThought": 2 } -
探索替代物流方案(分支):
{ "sessionId": "<sessionId>", "thought": "Alternative: Use air freight for distribution to Europe to ensure 7-day delivery.", "nextThoughtNeeded": true, "thoughtNumber": 4, "totalThoughts": 8, "branchFromThought": 3, "branchId": "air_freight" } -
规划库存:
{ "sessionId": "<sessionId>", "thought": "Plan inventory: Maintain 20,000 units in regional warehouses (USA, Europe, Asia) with just-in-time delivery.", "nextThoughtNeeded": true, "thoughtNumber": 5, "totalThoughts": 8 } -
降低风险:
{ "sessionId": "<sessionId>", "thought": "Mitigate risks: Dual-source microchips and maintain 15% buffer inventory for supply disruptions.", "nextThoughtNeeded": true, "thoughtNumber": 6, "totalThoughts": 10, "needsMoreThoughts": true } -
设置时间线:
{ "sessionId": "<sessionId>", "thought": "Set timeline: Supplier contracts by Month 1, manufacturing by Month 3, distribution by Month 4.", "nextThoughtNeeded": false, "thoughtNumber": 7, "totalThoughts": 10 }
提示:
- 会话 ID:首次查询后保存
sessionId,以供后续查询使用。 - Claude Desktop 格式:如有需要,在 JSON 前添加:
示例:POST http://localhost:8001/tool/sequential_thinkingPOST http://localhost:8001/tool/sequential_thinking { "thought": "Define objective: Plan a cost-efficient supply chain for a new smartwatch, ensuring global delivery within 5 months.", "nextThoughtNeeded": true, "thoughtNumber": 1, "totalThoughts": 8 } - 自定义:修改
thought内容以适用于其他供应链(例如,食品、制药)。食品行业示例:{ "thought": "Define objective: Plan a cold-chain supply chain for fresh produce, ensuring delivery within 48 hours.", "nextThoughtNeeded": true, "thoughtNumber": 1, "totalThoughts": 8 }
Leave Manager MCP 服务
- 端点:
http://localhost:8000 - 用途:使用 MCP 通过模拟数据库(
employee_leaves.json)管理员工休假。 - 示例查询:
- 查看休假余额:
发送至{ "employee_id": "E001" }http://localhost:8000/tool/get_leave_balance。 - 申请休假:
发送至{ "employee_id": "E001", "leave_dates": ["2025-06-01", "2025-06-02"] }http://localhost:8000/tool/apply_leave。 - 获取休假历史:
发送至{ "employee_id": "E001" }http://localhost:8000/tool/get_leave_history。
- 查看休假余额:
扩展项目
- Sequential Thinking 持久化:添加 JSON 或数据库存储,以保存供应链计划,类似于
employee_leaves.json。 - Claude Desktop 自动化:创建脚本来管理
sessionId并简化查询输入。 - 可视化:根据 Sequential Thinking 数据生成供应链流程图或时间线。
- 指标:增强
sequential_thinking,根据思考内容计算成本或交付周期。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。