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

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
committed by Windpicker-owo
parent 4686327d8d
commit 781b7f92a9
14 changed files with 1418 additions and 27 deletions

View File

@@ -17,7 +17,12 @@ def get_tool_instance(tool_name: str) -> BaseTool | None:
plugin_config = None
tool_class: type[BaseTool] = component_registry.get_component_class(tool_name, ComponentType.TOOL) # type: ignore
return tool_class(plugin_config) if tool_class else None
if tool_class:
return tool_class(plugin_config)
# 如果不是常规工具检查是否是MCP工具
# MCP工具不需要返回实例会在execute_tool_call中特殊处理
return None
def get_llm_available_tool_definitions():
@@ -29,4 +34,16 @@ def get_llm_available_tool_definitions():
from src.plugin_system.core import component_registry
llm_available_tools = component_registry.get_llm_available_tools()
return [(name, tool_class.get_tool_definition()) for name, tool_class in llm_available_tools.items()]
tool_definitions = [(name, tool_class.get_tool_definition()) for name, tool_class in llm_available_tools.items()]
# 添加MCP工具
try:
from src.plugin_system.utils.mcp_tool_provider import mcp_tool_provider
mcp_tools = mcp_tool_provider.get_mcp_tool_definitions()
tool_definitions.extend(mcp_tools)
if mcp_tools:
logger.debug(f"已添加 {len(mcp_tools)} 个MCP工具到可用工具列表")
except Exception as e:
logger.debug(f"获取MCP工具失败可能未配置: {e}")
return tool_definitions