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.
This commit is contained in:
+4
-3
@@ -39,6 +39,7 @@ from typing import Optional, Callable, Any, List, Union, cast, Iterable
|
|||||||
from src import project_manager
|
from src import project_manager
|
||||||
from src import file_cache
|
from src import file_cache
|
||||||
from src import mcp_client
|
from src import mcp_client
|
||||||
|
from src import mcp_tool_specs
|
||||||
from src import mma_prompts
|
from src import mma_prompts
|
||||||
from src import performance_monitor
|
from src import performance_monitor
|
||||||
from src import project_manager
|
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:
|
if preset_name in presets:
|
||||||
preset = presets[preset_name]
|
preset = presets[preset_name]
|
||||||
_active_tool_preset = preset
|
_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
|
new_tools[TOOL_NAME] = False
|
||||||
for cat in preset.categories.values():
|
for cat in preset.categories.values():
|
||||||
for tool in cat:
|
for tool in cat:
|
||||||
@@ -579,7 +580,7 @@ def set_tool_preset(preset_name: Optional[str]) -> None:
|
|||||||
_tool_approval_modes = {}
|
_tool_approval_modes = {}
|
||||||
if not preset_name or preset_name == "None":
|
if not preset_name or preset_name == "None":
|
||||||
# Enable all tools if no preset
|
# 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
|
_agent_tools[TOOL_NAME] = True
|
||||||
_active_tool_preset = None
|
_active_tool_preset = None
|
||||||
else:
|
else:
|
||||||
@@ -1009,7 +1010,7 @@ async def _execute_single_tool_call_async(
|
|||||||
tool_executed = True
|
tool_executed = True
|
||||||
|
|
||||||
if not tool_executed:
|
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()
|
ext_tools = mcp_client.get_external_mcp_manager().get_all_tools()
|
||||||
is_external = name in ext_tools
|
is_external = name in ext_tools
|
||||||
if name and (is_native or is_external):
|
if name and (is_native or is_external):
|
||||||
|
|||||||
Reference in New Issue
Block a user