没想到吧,我还是没测试()

feat(mcp): 集成MCP SSE协议支持并扩展工具调用能力

新增MCP客户端类型(mcp_ssd),支持通过Model Context Protocol连接外部工具服务器。
更新文档和配置模板,提供完整的MCP接入指南;主程序启动时自动初始化MCP工具提供器,
tool_api 与 tool_use 核心链路新增对MCP工具的检测与调用,实现与既有插件工具的无缝兼容。
同步更新配置模型、模板与帮助文档。
This commit is contained in:
subiz
2025-10-05 19:24:57 +08:00
parent 33f7128a5a
commit 43fe6046b4
14 changed files with 1418 additions and 27 deletions

View File

@@ -279,6 +279,23 @@ class ToolExecutor:
logger.info(
f"{self.log_prefix} 正在执行工具: [bold green]{function_name}[/bold green] | 参数: {function_args}"
)
# 检查是否是MCP工具
try:
from src.plugin_system.utils.mcp_tool_provider import mcp_tool_provider
if function_name in mcp_tool_provider.mcp_tools:
logger.info(f"{self.log_prefix}执行MCP工具: {function_name}")
result = await mcp_tool_provider.call_mcp_tool(function_name, function_args)
return {
"tool_call_id": tool_call.call_id,
"role": "tool",
"name": function_name,
"type": "function",
"content": result.get("content", ""),
}
except Exception as e:
logger.debug(f"检查MCP工具时出错: {e}")
function_args["llm_called"] = True # 标记为LLM调用
# 检查是否是二步工具的第二步调用