From b9b9081bace52d8fe5ffe9e47e27b79b46c88bc1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 7 Feb 2026 18:32:57 +0000 Subject: [PATCH] fix: only show semantic tool filter warning when feature is configured 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: Krish Dholakia --- 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 cf9e00512b1..46b57d8480d 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -4941,13 +4941,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, @@ -4955,10 +4959,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(