@@ -319,13 +319,14 @@ def _filter_tools(self, tools: List[types.Tool], openapi_schema: Dict[str, Any])
319319 Returns:
320320 Filtered list of tools
321321 """
322- if (
323- self ._include_operations is None
324- and self ._exclude_operations is None
325- and self ._include_tags is None
326- and self ._exclude_tags is None
327- and self ._max_tool_name_length is None
328- ):
322+ include_exclude_conditions_exist = (
323+ self ._include_operations is not None
324+ or self ._exclude_operations is not None
325+ or self ._include_tags is not None
326+ or self ._exclude_tags is not None
327+ )
328+
329+ if not include_exclude_conditions_exist and self ._max_tool_name_length is None :
329330 return tools
330331
331332 operations_by_tag : Dict [str , List [str ]] = {}
@@ -356,8 +357,6 @@ def _filter_tools(self, tools: List[types.Tool], openapi_schema: Dict[str, Any])
356357 operations_to_include .update (self ._include_operations )
357358 elif self ._exclude_operations is not None :
358359 operations_to_include .update (all_operations - set (self ._exclude_operations ))
359- elif self ._max_tool_name_length is not None :
360- operations_to_include .update (all_operations ) # all_operations
361360
362361 if self ._include_tags is not None :
363362 for tag in self ._include_tags :
@@ -369,6 +368,11 @@ def _filter_tools(self, tools: List[types.Tool], openapi_schema: Dict[str, Any])
369368
370369 operations_to_include .update (all_operations - excluded_operations )
371370
371+ # This condition means that no include/exclude conditions exist,
372+ # and we've reached this point because we have a max-length limit
373+ if not include_exclude_conditions_exist :
374+ operations_to_include = all_operations
375+
372376 if self ._max_tool_name_length is not None :
373377 long_operations = {
374378 tool .name for tool in tools if len (self .get_combined_full_name (tool .name )) > self ._max_tool_name_length
0 commit comments