feat: 新增mcp server

This commit is contained in:
2026-08-18 00:00:46 +08:00
parent 202926180a
commit 964f516ade
21 changed files with 688 additions and 14 deletions
@@ -2,7 +2,7 @@
> 文档目的:换机后续做时,先读本文再动手。
> 日期:2026-08-17
> 现状:后端 `Spring Boot 3.5.16` + MyBatis-Plus `3.5.8`;尚未引入 Spring AI / MCP。
> 现状:后端 `Spring Boot 3.5.16` + MyBatis-Plus `3.5.8` + Spring AI MCP `1.1.8`(STREAMABLE `/mcp`);已有 BI 只读 tool。
---
@@ -50,16 +50,20 @@
- 依赖方向:`org.springframework.ai:spring-ai-starter-mcp-server-webmvc`
- 协议:优先 **STREAMABLE** 或 **STATELESS**;**不要用已弃用的 SSE**
- 端点示意:`/api/mcp`(具体以 Spring AI 配置为准)
- 端点:`/mcp`(与 `/api/...` 业务接口前缀分开)
- 鉴权:Agent **独立凭证**(Bearer / m2m),与浏览器 JWT、扩展 Open API Key 分开;Security 单独放行 MCP 路径
### 3.2 模块目录(拟定,未建)
### 3.2 模块目录
```text
modules/agent/mcp/
config/ # MCP 与 Security 放行
tools/ # @McpTool(product / order / shop / adfee…)
support/ # 瘦 VO、分页裁剪、错误文案
config/ # MCP 凭证与租户绑定
security/ # Agent Bearer 鉴权
tools/ # 薄 @McpTool 入口(非 REST /api)
application/ # 用例编排 Facade
adapter/
common/ # 通用入参适配(日期等)
bi/ # BI 瘦 VO 与映射(按业务域扩展)
```
### 3.3 Python Agent(另仓/另目录,未建)
@@ -147,10 +151,10 @@ Boot 4 = Spring Framework 7 + Jakarta EE 11 + **Jackson 3** + Security 7 等,
## 6. 换机后续待办(建议顺序)
1. [x] Boot `3.2.3` → `3.5.16`,MyBatis-Plus → `3.5.8`(暂未上 3.5.9+,避免 IService 包路径迁移),编译通过
2. [ ] 本地回归核心链路
3. [ ] 引入 Spring AI 1.x BOM + `spring-ai-starter-mcp-server-webmvc`,配置 STREAMABLE/STATELESS
4. [ ] Security:MCP 路径 + Agent 鉴权
5. [ ] 落地 2~3 个只读 tool(如商品搜索、订单摘要)打通 LangGraph `get_tools()`
2. [x] 本地回归核心链路(登录等接口冒烟通过)
3. [x] 引入 Spring AI 1.1.8 BOM + `spring-ai-starter-mcp-server-webmvc`,配置 STREAMABLE `/mcp`
4. [x] Security:`/mcp` 跳过 JWT + Agent Bearer(`ecom.agent.mcp.bearer-token` / `AGENT_MCP_TOKEN`);含探测 tool `mcp_ping`
5. [x] 落地 BI 只读 tool:`bi_workbench_finance` / `bi_shop_overview` / `bi_product_overview`(瘦返回;租户 `ecom.agent.mcp.company-id`)
6. [ ] 新建 Python LangGraph 工程,接 MCP HTTP
---