OpenClaw MCP Stateless Migration Checker
MCP (Model Context Protocol) 将在 2026年7月28日 发布无状态化规范,这是一个重大变更:
无状态化规范正式发布
10周迁移窗口结束,旧版规范废弃
| 变化 | 影响 | 风险 |
|---|---|---|
❌ 移除 initialize 握手 |
所有 MCP 客户端需要修改 | 高 |
❌ 移除 Session ID |
依赖会话的服务器需要重写 | 高 |
| ✅ 新增 Apps + Tasks 扩展 | 可选迁移 | 低 |
递归扫描项目目录,检测所有 MCP 相关配置文件
支持终端彩色输出、JSON、HTML 多种报告格式
6种状态化模式检测,覆盖常见的 MCP 实现方式
每个检测项都提供具体的修复建议和迁移指南
| 规则 | 说明 | 风险 |
|---|---|---|
INITIALIZE_CALL |
检测是否使用旧版 initialize 握手 | 🔴 高 |
SESSION_ID |
检测是否依赖 Session ID 机制 | 🔴 高 |
INITIALIZED_NOTIFICATION |
检测初始化完成通知 | 🟡 中 |
PROTOCOL_VERSION |
检测是否使用旧版协议 | 🟡 中 |
STATE_STORAGE |
检测服务端状态存储模式 | 🟡 中 |
CONTEXT_CARRY |
检测跨请求上下文传递 | 🟢 低 |
# 克隆仓库
git clone https://github.com/jingchang0623-crypto/miaoquai.git
cd miaoquai/openclaw-mcp-stateless-migrator
# 直接运行
node index.js scan /path/to/your/project
# 扫描当前目录
node index.js scan
# 扫描指定目录
node index.js scan /path/to/mcp/config
# 扫描 OpenClaw 配置
node index.js scan ~/.openclaw/config/
node index.js report --output migration-report.html
// ❌ 旧版代码
const init = await client.request('initialize', {
protocolVersion: '2025-03-26',
capabilities: {}
});
// ✅ 新版代码 - 直接调用工具
const result = await client.request('tools/call', {
name: 'my_tool',
arguments: {}
});
// ❌ 旧版代码
const sessionId = response.headers['mcp-session-id'];
fetch(url, { headers: { 'mcp-session-id': sessionId } });
// ✅ 新版代码 - 每个请求独立
fetch(url, { method: 'POST', body: JSON.stringify(request) });
// ✅ 新规范推荐
const app = await client.request('apps/create', {
name: 'my-app',
tools: ['tool1', 'tool2']
});
运行扫描后,终端会显示彩色报告:
📋 MCP 无状态化迁移检测报告
──────────────────────────────────────
🔴 高风险 (2项)
────────────────────────
📁 src/mcp-client.js
问题: initialize 调用
匹配: 2处 (行: 15, 23)
修复: 移除 initialize 调用
📊 统计: 5项问题 | 🔴2高 | 🟡2中 | 🟢1低
⚠️ 发现高风险项!请尽快迁移!
🤖 妙趣AI - 让AI更有趣