fix: 修复 MCP 工具未注入到 AI 请求的问题
关键修复: - chatService 现在使用 mcpClientService 单例而不是创建新实例 - 这确保使用的是应用中实际连接的 MCP 服务器 问题原因: - chatService 之前创建了独立的 MCPClientService 实例 - 该实例没有任何已连接的 MCP 服务器 - 导致 getTools() 返回空数组 - AI 请求中没有包含工具定义 增强的调试日志: - MCPClientService.getTools 现在显示连接的服务器列表 - 显示 capabilities 和 tools 的详细信息 - chatService 显示 MCP 工具获取和转换过程 现在工具调用流程应该正常工作: 1. 用户选择 MCP 服务器 2. chatService 从 mcpClientService 获取工具列表 3. 工具被转换为 OpenAI 格式并注入请求 4. AI 可以识别并调用工具
This commit is contained in:
@@ -114,16 +114,6 @@
|
||||
</n-button>
|
||||
</n-dropdown>
|
||||
|
||||
<!-- 添加服务器 -->
|
||||
<n-button size="small" text>
|
||||
<template #icon>
|
||||
<n-icon :component="PlusIcon" />
|
||||
</template>
|
||||
添加服务器...
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
<!-- 模型选择器 -->
|
||||
<n-dropdown
|
||||
trigger="click"
|
||||
@@ -138,8 +128,11 @@
|
||||
<n-icon :component="ChevronDownIcon" size="14" style="margin-left: 4px;" />
|
||||
</n-button>
|
||||
</n-dropdown>
|
||||
</div>
|
||||
|
||||
<span class="toolbar-divider">|</span>
|
||||
<span class="toolbar-divider">|</span>
|
||||
|
||||
<div class="toolbar-right">
|
||||
|
||||
<!-- 快捷操作 -->
|
||||
<n-button-group size="small">
|
||||
|
||||
Reference in New Issue
Block a user