From 8bcde094768fd3a0daa68d374da37b1c3c408350 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 21 Jun 2026 16:11:27 -0400 Subject: [PATCH] refactor(mcp): update ai_client.py 3 TOOL_NAMES sites (t1_5) Phase 1 of any_type_componentization_20260621. Migrates ai_client.py: - Line 560: new_tools = {name: False for name in mcp_client.TOOL_NAMES} -> mcp_tool_specs.tool_names() - Line 582: _agent_tools = {name: True for name in mcp_client.TOOL_NAMES} -> mcp_tool_specs.tool_names() - Line 1012: is_native = name in mcp_client.TOOL_NAMES -> name in mcp_tool_specs.tool_names() Plus adds: from src import mcp_tool_specs Verified: uv run pytest tests/test_mcp_tool_specs.py tests/test_mcp_client_beads.py tests/test_mcp_client_paths.py tests/test_audit_dataclass_coverage.py tests/test_type_aliases.py 39 passed in 11.79s No regressions. The mcp_client.TOOL_NAMES re-export is preserved for backward compatibility with any external test/code that imports it. --- src/ai_client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ai_client.py b/src/ai_client.py index 187f9510..0e68150d 100644 --- a/src/ai_client.py +++ b/src/ai_client.py @@ -39,6 +39,7 @@ from typing import Optional, Callable, Any, List, Union, cast, Iterable from src import project_manager from src import file_cache from src import mcp_client +from src import mcp_tool_specs from src import mma_prompts from src import performance_monitor from src import project_manager @@ -557,7 +558,7 @@ def _set_tool_preset_result(preset_name: Optional[str]) -> Result[None]: if preset_name in presets: preset = presets[preset_name] _active_tool_preset = preset - new_tools = {name: False for name in mcp_client.TOOL_NAMES} + new_tools = {name: False for name in mcp_tool_specs.tool_names()} new_tools[TOOL_NAME] = False for cat in preset.categories.values(): for tool in cat: @@ -579,7 +580,7 @@ def set_tool_preset(preset_name: Optional[str]) -> None: _tool_approval_modes = {} if not preset_name or preset_name == "None": # Enable all tools if no preset - _agent_tools = {name: True for name in mcp_client.TOOL_NAMES} + _agent_tools = {name: True for name in mcp_tool_specs.tool_names()} _agent_tools[TOOL_NAME] = True _active_tool_preset = None else: @@ -1009,7 +1010,7 @@ async def _execute_single_tool_call_async( tool_executed = True if not tool_executed: - is_native = name in mcp_client.TOOL_NAMES + is_native = name in mcp_tool_specs.tool_names() ext_tools = mcp_client.get_external_mcp_manager().get_all_tools() is_external = name in ext_tools if name and (is_native or is_external):