fix(runtime): 修复 Skill/MCP 调用链路3个断点
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

1. Anthropic Driver ToolResult 格式修复 — ContentBlock 添加 ToolResult 变体,
   tool_call_id 不再被丢弃, 按 Anthropic API 规范发送 tool_result 格式
2. 前端 callMcpTool 参数名对齐 — serviceName/toolName/args 改为
   service_name/tool_name/arguments, 后端支持 service_name 精确路由
3. MCP 工具桥接到 ToolRegistry — McpToolAdapter 添加 service_name/clone,
   新建 McpToolWrapper 实现 Tool trait, Kernel 添加 mcp_adapters 共享状态,
   McpManagerState 与 Kernel 共享同一 Arc<RwLock<Vec>>, MCP 服务启停时
   自动同步工具列表到 LLM 可见的 ToolRegistry
This commit is contained in:
iven
2026-04-11 16:20:38 +08:00
parent 2843bd204f
commit 9e0aa496cd
12 changed files with 389 additions and 29 deletions

View File

@@ -63,6 +63,7 @@ pub async fn kernel_init(
state: State<'_, KernelState>,
scheduler_state: State<'_, SchedulerState>,
heartbeat_state: State<'_, HeartbeatEngineState>,
mcp_state: State<'_, crate::kernel_commands::mcp::McpManagerState>,
config_request: Option<KernelConfigRequest>,
) -> Result<KernelStatusResponse, String> {
let mut kernel_lock = state.lock().await;
@@ -168,6 +169,20 @@ pub async fn kernel_init(
kernel.set_extraction_driver(std::sync::Arc::new(extraction_driver));
}
// Bridge MCP adapters — kernel reads from this shared list during
// create_tool_registry() so the LLM can discover MCP tools.
// Share the McpManagerState's Arc with the Kernel so both point to the same list.
{
let shared_arc = mcp_state.kernel_adapters.clone();
// Copy any adapters already in the kernel's default list into the shared one
let kernel_default = kernel.mcp_adapters();
if let (Ok(src), Ok(mut dst)) = (kernel_default.read(), shared_arc.write()) {
*dst = src.clone();
}
kernel.set_mcp_adapters(shared_arc);
tracing::info!("[kernel_init] Bridged MCP adapters to Kernel for LLM tool discovery");
}
// Configure summary driver so the Growth system can generate L0/L1 summaries
if let Some(api_key) = config_request.as_ref().and_then(|r| r.api_key.clone()) {
crate::summarizer_adapter::configure_summary_driver(