Spring AI MCP客户端集成者-MCP SyncClient初始化失败导致doChatWithMcp测试中断-求可执行方案

个人情况

目前在写 AI 超级智能体项目

学习内容

现在学到测试高德地图 MCP 服务,根据https://www.codefather.cn/course/1915010091721236482/section/1939870483951702018#course-comment-view 文章中的测试 使用MCP inspector测试高德地图没有问题

学习问题

但是使用源码中的测试案例测试 MCP 时,测试代码如下:

@Test
复制代码
void doChatWithMcp() { String chatId = UUID.randomUUID().toString(); // 测试地图 MCP String message = "我的另一半居住在上海静安区,请帮我找到 5 公里内合适的约会地点"; String answer = loveApp.doChatWithMcp(message, chatId); Assertions.assertNotNull(answer); // 测试图片搜索 MCP // String message = "帮我搜索一些哄另一半开心的图片"; // String answer = loveApp.doChatWithMcp(message, chatId); // Assertions.assertNotNull(answer); } }

控制台报 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'yuManus' defined in file [D:\a_project\yu-ai-agent-master\target\classes\com\yupi\yuaiagent\agent\YuManus.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'dashscopeChatModel' defined in class path resource [com/alibaba/cloud/ai/autoconfigure/dashscope/DashScopeChatAutoConfiguration.class]: Unsatisfied dependency expressed through method 'dashscopeChatModel' parameter 1: Error creating bean with name 'toolCallingManager' defined in class path resource [org/springframework/ai/model/tool/autoconfigure/ToolCallingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'toolCallingManager' parameter 0: Error creating bean with name 'toolCallbackResolver' defined in class path resource [org/springframework/ai/model/tool/autoconfigure/ToolCallingAutoConfiguration.class]: Unsatisfied dependency expressed through method 'toolCallbackResolver' parameter 2: Error creating bean with name 'mcpToolCallbacks' defined in class path resource [org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.class]: Failed to instantiate [org.springframework.ai.mcp.SyncMcpToolCallbackProvider]: Factory method 'mcpToolCallbacks' threw exception with message: Error creating bean with name 'mcpSyncClients' defined in class path resource [org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.class]: Failed to instantiate [java.util.List]: Factory method 'mcpSyncClients' threw exception with message: Failed to wait for the message endpoint

已有尝试

  • 重启 IDEA,清空缓存
  • 卸载 node 重新安装 node v22.22.2

期望帮助

测试代码能够成功执行

0个评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
下载 APP