feat: 集成 MCP 工具支持

- 添加 spring-ai-starter-mcp-client 依赖
- 创建 Node.js MCP 服务器(risk-cost-server)
- 在 Application.java 中配置 MCP 工具回调
- 添加 get_customer_risk_cost 工具(返回 1.2%-2.5% 的风险成本率)
- 支持通过 FunctionToolCallback 调用 MCP 工具
- 更新系统提示,指导 AI 使用 MCP 工具
- 降级 Spring AI 到 1.1.2 版本

技术实现:
- 使用 FunctionToolCallback 包装 MCP 工具
- 通过 Stdio 方式与 MCP 服务器通信
- JSON-RPC 协议调用工具

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hughhuangandClaude Sonnet 4.5 committed 2026-01-29 20:58:16 +08:00
1 parent c6f3eef29b
commit 581f731de3
10 files changed
+1045 -98

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
# 客户风险成本 MCP 服务器
## 功能
提供获取客户风险成本率的工具,用于定价计算。
## 工具
### get_customer_risk_cost
获取客户的风险成本率(%)。
**输入参数**:
- `company_name` (string, 必需): 客户的企业名称
**输出**:
```json
{
"company_name": "某某科技有限公司",
"risk_cost_rate": 1.8765,
"unit": "%",
"description": "客户\"某某科技有限公司\"的风险成本率为 1.8765%",
"timestamp": "2026-01-29T12:00:00.000Z"
}
```
**风险成本率范围**:1.2% ~ 2.5%
## 安装
```bash
cd mcp-servers/risk-cost-server
npm install
```
## 运行
```bash
npm start
```
## 配置到 Spring AI
在 `application.properties` 中添加:
```properties
spring.ai.mcp.client.risk-cost.command=node
spring.ai.mcp.client.risk-cost.args=D:/project/spring-ai-skill/mcp-servers/risk-cost-server/index.js
```
## 测试
```bash
# 测试工具调用
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_customer_risk_cost","arguments":{"company_name":"测试企业"}}}' | node index.js
```