diff --git a/src/mcp/tool_adapter.rs b/src/mcp/tool_adapter.rs index 9e483c4..32498c1 100644 --- a/src/mcp/tool_adapter.rs +++ b/src/mcp/tool_adapter.rs @@ -100,6 +100,7 @@ impl PicoBotTool for McpToolWrapper { } async fn execute(&self, args: serde_json::Value) -> anyhow::Result { + let mcp_start = std::time::Instant::now(); tracing::debug!( server_key = %self.server_key, tool = %self.tool_name, @@ -131,6 +132,15 @@ impl PicoBotTool for McpToolWrapper { call.await? }; + // MCP 全链路往返耗时(含 stdio 传输 + server 派发 + 工具执行 + 回传)。 + // 与 server 侧 wrapper 进入时间戳、结果内 duration_ms 对比可定位慢在哪一段。 + tracing::debug!( + server_key = %self.server_key, + tool = %self.tool_name, + roundtrip_ms = mcp_start.elapsed().as_millis() as u64, + "MCP tool call finished" + ); + // Convert MCP CallToolResult to PicoBot ToolResult let output = extract_text_content(&result); let is_error = result.is_error.unwrap_or(false);