From 77ab20315430490852d8bd169cf57fcb9fe19584 Mon Sep 17 00:00:00 2001 From: lorenzejay Date: Mon, 9 Mar 2026 16:09:28 -0700 Subject: [PATCH] linted --- lib/crewai/src/crewai/tools/mcp_native_tool.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/crewai/src/crewai/tools/mcp_native_tool.py b/lib/crewai/src/crewai/tools/mcp_native_tool.py index ffae56c2a..6fd6d05f6 100644 --- a/lib/crewai/src/crewai/tools/mcp_native_tool.py +++ b/lib/crewai/src/crewai/tools/mcp_native_tool.py @@ -5,12 +5,16 @@ for better performance and connection management. """ import asyncio +import logging import threading from typing import Any from crewai.tools import BaseTool +logger = logging.getLogger(__name__) + + _mcp_loop_lock = threading.Lock() _mcp_shared_loop: asyncio.AbstractEventLoop | None = None _mcp_shared_loop_thread: threading.Thread | None = None @@ -152,7 +156,7 @@ class MCPNativeTool(BaseTool): try: await self._mcp_client.disconnect() except Exception: - pass # best-effort; may already be stale + logger.debug("Failed to disconnect stale MCP client", exc_info=True) await self._mcp_client.connect() @@ -169,7 +173,7 @@ class MCPNativeTool(BaseTool): try: await self._mcp_client.disconnect() except Exception: - pass # best-effort cleanup + logger.debug("Failed to disconnect MCP client during retry", exc_info=True) await self._mcp_client.connect() result = await self._mcp_client.call_tool( self.original_tool_name, kwargs @@ -180,7 +184,7 @@ class MCPNativeTool(BaseTool): try: await self._mcp_client.disconnect() except Exception: - pass # best-effort cleanup + logger.debug("Failed to disconnect MCP client during cleanup", exc_info=True) # Extract result content if isinstance(result, str):