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

+12 -2
View File
@@ -20,7 +20,7 @@
<properties>
<java.version>17</java.version>
<maven.deploy.skip>true</maven.deploy.skip>
<spring-ai.version>2.0.0-SNAPSHOT</spring-ai.version>
<spring-ai.version>1.1.2</spring-ai.version>
</properties>
<dependencies>
@@ -34,7 +34,7 @@
<dependency>
<groupId>org.springaicommunity</groupId>
<artifactId>spring-ai-agent-utils</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.4.2</version>
</dependency>
@@ -53,6 +53,12 @@
<artifactId>spring-ai-starter-model-google-genai</artifactId>
</dependency> -->
<!-- MCP Client Support -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-client</artifactId>
</dependency>
<!-- Netty DNS resolver for macOS -->
<dependency>
<groupId>io.netty</groupId>
@@ -70,6 +76,10 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>