Files
dukang/docs/杜康好客-v3.5.18-开发文档.md
T
jacy 976bde37cc feat(wecom): 企微 API 插件增加 MCP Streamable HTTP 端点
与 REST/OpenAPI 并存,按实例权限自动 tools/list,免手填工具。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 16:57:42 +08:00

51 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 杜康好客 · v3.5.18 开发文档
> **2026-09-08** · integrations/wecom · admin-web · shared-types
> **主题**:企微智能机器人 **MCP 插件**(Streamable HTTP),与 REST API 插件并存
---
## 1. 版本目标
企微后台「添加 MCP 插件」可对接本系统:托管大模型按 MCP `tools/list` / `tools/call` 拉数。不改长连接 Bot、不删 REST/OpenAPI。
**不做**:写操作、明文手机/地址、把 `/admin/*` JWT 暴露给企微、第一期 SSE 传输。
---
## 2. 端点
| 项 | 值 |
|----|-----|
| MCP URL | `/api/v1/wecom/plugin/mcp` |
| 传输 | Streamable HTTP,无状态(每请求新建 `McpServer`) |
| 鉴权 | Header `X-Api-Key`(与 REST 同一套 HQ 实例) |
| 响应 | JSON-RPC;**无** `{code,message,data}` 信封 |
| 工具结果 | `JSON.stringify(查询结果)` |
| 权限 | `tools/list` 只注册已勾选权限;QueryService 仍 `requirePerm` |
生产:`https://api.dukanghaoke.com/api/v1/wecom/plugin/mcp`
测试:`https://api-test.dukanghaoke.com/api/v1/wecom/plugin/mcp`
---
## 3. 变更面
| 层 | 路径 |
|----|------|
| shared-types | `WECOM_PLUGIN_MCP_*`、`allowedWecomPluginMcpTools` |
| API | `wecom-plugin-mcp.*`;`WecomPluginMcpFactory`;Interceptor skip MCP |
| HQ | `WecomApiPluginsPage` 展示 MCP URL |
| 文档 | [`企微API插件-配置手册.md`](./企微API插件-配置手册.md) |
---
## 4. 验收
- [ ] 无 Key / 错 Key → MCP 入口 401
- [ ] 带 Key `tools/list` 仅含该实例已勾选权限
- [ ] `tools/call` 查询口径与 REST 一致,结果无 REST 信封
- [ ] HQ 日志 `botKey=plugin:{id}`
- [ ] 现有 API 插件机器人行为不变
- [ ] 长连接 Bot 不变