From d26878af70e8d160fa7bcac69c438ab2e0269ddd Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Sat, 7 Feb 2026 13:17:13 -0800 Subject: [PATCH] fix: only show semantic tool filter warning when feature is configured (#20651) The warning 'Semantic tool filter hook not initialized' was appearing on every startup, even when the mcp_semantic_tool_filter feature was not configured. This was confusing for users. Now the function checks if the feature is actually configured and enabled before proceeding with initialization. The warning will only appear if the feature was explicitly enabled but failed to initialize. Co-authored-by: Cursor Agent --- litellm/proxy/proxy_server.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 22d63579986..294294cdda7 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -4942,13 +4942,17 @@ class ProxyStartupEvent: """Initialize MCP semantic tool filter if configured""" from litellm.proxy.hooks.mcp_semantic_filter import SemanticToolFilterHook - verbose_proxy_logger.info( - f"Initializing semantic tool filter: llm_router={llm_router is not None}, " - f"litellm_settings keys={list(litellm_settings.keys())}" - ) - mcp_semantic_filter_config = litellm_settings.get("mcp_semantic_tool_filter", None) - verbose_proxy_logger.debug(f"Semantic filter config: {mcp_semantic_filter_config}") + + # Only proceed if the feature is configured and enabled + if not mcp_semantic_filter_config or not mcp_semantic_filter_config.get("enabled", False): + verbose_proxy_logger.debug("Semantic tool filter not configured or not enabled, skipping initialization") + return + + verbose_proxy_logger.debug( + f"Initializing semantic tool filter: llm_router={llm_router is not None}, " + f"config={mcp_semantic_filter_config}" + ) hook = await SemanticToolFilterHook.initialize_from_config( config=mcp_semantic_filter_config, @@ -4956,10 +4960,11 @@ class ProxyStartupEvent: ) if hook: - verbose_proxy_logger.debug("✅ Semantic tool filter hook registered") + verbose_proxy_logger.debug("Semantic tool filter hook registered") litellm.logging_callback_manager.add_litellm_callback(hook) else: - verbose_proxy_logger.warning("❌ Semantic tool filter hook not initialized") + # Only warn if the feature was configured but failed to initialize + verbose_proxy_logger.warning("Semantic tool filter hook was configured but failed to initialize") @classmethod def _initialize_jwt_auth(