From 1f38fa46b81728b2d2a062d19d54d6ed1ed4d618 Mon Sep 17 00:00:00 2001 From: educoder Date: Wed, 29 Apr 2026 21:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SKILL.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SKILL.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/SKILL.md b/SKILL.md index dc24493..02e3067 100644 --- a/SKILL.md +++ b/SKILL.md @@ -20,11 +20,19 @@ description: 提供 Educoder 用户与课堂相关查询能力,当前支持用 ## 前置配置 -接入 OpenClaw 时,多个会话使用同一个 `Authorization` token。第一次安装 skill 时,把 MCP 服务地址和 token 一起写到 OpenClaw 的 MCP 配置文件中;后续调用 MCP 时,从配置文件读取 token 并放到请求头里。 +接入 OpenClaw 时,多个会话使用同一个 `Authorization` token。第一次安装 skill 时,把 MCP 服务地址和 token 一起写到固定的 OpenClaw MCP 配置文件 `.openclaw/educoder-skill/.mcp.json` 中;后续调用 MCP 时,也只从 `.openclaw/educoder-skill/.mcp.json` 读取 token 并放到请求头里。 ### Authorization 配置 -安装 skill 时要求把用户输入 Educoder `Authorization` token写入 MCP 配置文件。 +安装 skill 时要求把用户输入 Educoder `Authorization` token 写入 MCP 配置文件 `.openclaw/educoder-skill/.mcp.json`。 + +配置文件路径必须固定为: + +```text +.openclaw/educoder-skill/.mcp.json +``` + +不要写入 `.openclaw/mcp.json` 或 `.openclaw/config/mcp.json`,否则新开会话时可能读取不到配置。 MCP 配置示例: @@ -76,7 +84,7 @@ async with streamable_http_client(self.server_url, headers=headers or None) as ( ### 多会话共享 Token -多个会话共用 MCP 配置文件中的同一个 `Authorization` token。安装后不需要每个会话重复输入 token;每次调用 MCP 时读取配置里的 `headers.Authorization` 即可。 +多个会话共用 `.openclaw/educoder-skill/.mcp.json` 中的同一个 `Authorization` token。安装后不需要每个会话重复输入 token;每次调用 MCP 时读取配置里的 `headers.Authorization` 即可。 ### 401 Token 过期处理 @@ -86,7 +94,7 @@ async with streamable_http_client(self.server_url, headers=headers or None) as ( 1. 停止继续使用当前 token 重试 2. 提示用户重新输入新的 `Authorization` -3. 将用户输入的新 token 写入 OpenClaw 的 MCP 配置文件 +3. 将用户输入的新 token 写入 `.openclaw/educoder-skill/.mcp.json` 4. 重新创建 MCP 连接,并从 MCP 配置读取最新 token 5. 使用新 token 重新发起本次工具调用 @@ -104,7 +112,7 @@ async with streamable_http_client(self.server_url, headers=headers or None) as ( 1. 安装 skill 时,MCP 服务地址填写:`http://47.98.32.66:48000/mcp` 2. 安装 skill 时,要求用户输入 Educoder `Authorization` token -3. OpenClaw 将 MCP 地址和 token 写入 MCP 配置文件,其中 token 放到 `headers.Authorization` +3. OpenClaw 将 MCP 地址和 token 写入 `.openclaw/educoder-skill/.mcp.json`,其中 token 放到 `headers.Authorization` 4. 当前用户发起工具调用时,后端创建 MCPClient 5. MCPClient 建连时从 MCP 配置读取 token 6. MCPClient 把读取到的 token 原文放进 MCP headers,不要添加 `Bearer ` 前缀 @@ -333,7 +341,8 @@ async def main(openclaw_mcp_config): - 当前服务使用 `streamable-http`,不是 SSE - 如果客户端使用了 `sse_client`,将无法正常调用当前服务 - `Authorization` 应从 OpenClaw MCP 配置读取 token 原文,通过 MCP 连接层 headers 传入,不放在工具参数里,也不要添加 `Bearer ` 前缀 -- 调用接口返回 `401 Unauthorized` 时,视为 token 过期或无效,应要求用户重新输入 token,并更新 OpenClaw MCP 配置文件中的 `headers.Authorization` -- 新开会话直接从 MCP 配置读取 `headers.Authorization` +- 调用接口返回 `401 Unauthorized` 时,视为 token 过期或无效,应要求用户重新输入 token,并更新 `.openclaw/educoder-skill/.mcp.json` 中的 `headers.Authorization` +- 新开会话直接从 `.openclaw/educoder-skill/.mcp.json` 读取 `headers.Authorization` +- MCP 配置文件路径固定为 `.openclaw/educoder-skill/.mcp.json`,不要写入或读取 `.openclaw/mcp.json`、`.openclaw/config/mcp.json` - 当前工具返回空 `data` 数组属于预期行为,因为外部接口尚未接入 - 后续新增或调整工具时,需要同步更新本文件