- 给飞书 MCP 新增 download 能力(复用
tools/download.go逻辑) - 将 card 相关工具(
card_create等 6 个)从tools/迁移到tools/feishu_mcp/ - 新增 发送文件给用户 工具(
feishu_send_file) - 完善 飞书渠道专属 prompt
| 组件 | 位置 | 说明 |
|---|---|---|
DownloadFile | tools/download.go | 核心工具,用 tenant_access_token 下载消息资源 |
card_create/add/send 等 6 个 | tools/card_tools.go + tools/card_builder.go | 飞书专属,但在通用 tools 包 |
feishu_send_card | tools/feishu_mcp/wiki.go | 已在 MCP 中,发送原始 card JSON |
feishu_upload_file | tools/feishu_mcp/file.go | 上传到云空间(不是发到聊天) |
| 发送文件到聊天 | channel/feishu.go:sendFile | 内部方法,未暴露为工具 |
| 飞书 prompt | channel/feishu.go:ChannelSystemParts | 仅 5 行 |
Q: download 应该用 tenant_access_token 还是 user_access_token?
- 消息资源 API(
/im/v1/messages/{id}/resources/{key})需要的是 tenant_access_token - 现有
download.go通过 env vars 获取 tenant_access_token - feishu_mcp 中的
FeishuMCP结构体持有lark.Client,可复用其 tenant token 能力 - 方案:在
FeishuMCP中新增GetTenantToken()方法,复用 lark client 的 app credential
Q: card_builder.go 是否整体迁移?
CardBuilder被channel/feishu.go引用(回调处理)- 如果迁移到
feishu_mcp/,channel/需要导入tools/feishu_mcp,但这会引入不需要的依赖 - 方案:
card_builder.go留在tools/(它是 session 状态管理器,不涉及飞书 API),只迁移card_tools.go中的 6 个 Tool 定义到tools/feishu_mcp/
- 目标:在
tools/feishu_mcp/file.go新增DownloadFileTool - 复用:
tools/download.go中的 HTTP 请求逻辑 - 改动:
tools/feishu_mcp/file.go:新增DownloadFileTool(使用FeishuMCP的 tenant token)tools/feishu_mcp/feishu_mcp.go:新增GetTenantToken()方法(通过 lark client 获取)main.go:注册feishu_mcp.DownloadFileTool- 保留原
tools/download.go中的DownloadFileTool作为 core 工具(兼容非飞书渠道和自动触发场景)
- 目标:
card_create等 6 个 Tool 定义从tools/card_tools.go迁移到tools/feishu_mcp/card_tools.go - 改动:
- 新建
tools/feishu_mcp/card_tools.go:6 个 Tool 定义(CardCreateTool等) tools/card_tools.go:删除 Tool 定义,保留动态注册/注销辅助函数tools/card_builder.go:保留不动(session 管理器,被 channel 和 feishu_mcp 共用)agent/agent.go:更新 import 和注册路径main.go:注册路径从tools.NewCardCreateTool→feishu_mcp.NewCardCreateTool- 所有 6 个 Tool 需要实现
SupportedChannels() → ["feishu"]
- 新建
- 目标:Agent 可主动调用,将本地文件发送到飞书聊天
- 改动:
tools/feishu_mcp/file.go:新增SendFileTool- 参数:
file_path(必填)、chat_id(选填,默认当前)、type(选填,“file”/“image”,自动检测) - 实现:通过
ctx.SendFunc发送__FEISHU_FILE__::path或直接用 lark IM API - 注意:需要与
channel/feishu.go中的sendFile方法协调,避免代码重复 main.go:注册feishu_mcp.SendFileTool
- 目标:扩充
ChannelSystemParts内容,覆盖关键使用指南 - 改动:
channel/feishu.go:ChannelSystemParts:扩展 prompt- 内容要点:
- 飞书 Markdown 限制(不支持复杂表格、嵌套列表)
- 文件/图片处理(
<file><image>标签 + download 工具) - 卡片使用(
card_create构建交互卡片,适用于表单、选择、按钮交互) - 发送文件(
feishu_send_file发送本地文件给用户)
- 长度控制:不超过 40 行
- 任务 1:DownloadFile(独立,无依赖)
- 任务 3:SendFile(独立,无依赖)
- 任务 2:Card 迁移(改动面最大,涉及 import 调整)
- 任务 4:Prompt 完善(最后做,确保所有工具就位后编写)
- 验证:build / test / lint
| 任务 | 风险 | 等级 |
|---|---|---|
| DownloadFile | 复用现有逻辑,低风险 | 🟢 |
| Card 迁移 | import 变更面广,需仔细处理循环依赖 | 🟡 |
| SendFile | 需协调 channel 和 mcp 之间的文件发送逻辑 | 🟢 |
| Prompt | 纯文本修改 | 🟢 |