Private
Public Access
refactor(mcp_client,gui_2): migrate ToolDefinition consumers (Phase 8)
Phase 8: ToolDefinition
Before: 2 .get('description',...) sites
After: 0
Delta: -2 (expected: -2 or -3 per plan; the 3rd site gui_2.py:5875
is 'server' field which is NOT on ToolDefinition)
Migrates:
1. src/mcp_client.py:1968 (was 1970) - list_tools in _get_tool_definitions:
tinfo.get('description', '') -> ToolDefinition.from_dict(tinfo).description
(tinfo.get('inputSchema', ...) stays because 'inputSchema' key
does not match ToolDefinition's 'parameters' field name)
2. src/gui_2.py:5878 - render_external_tools_panel:
tinfo.get('description', '') -> ToolDefinition.from_dict(tinfo).description
Notes:
- gui_2.py:5875 (tinfo.get('server', 'unknown')) is NOT migrated;
'server' is not a ToolDefinition field. The tinfo here may be a
ToolInfo or server-info dict, not ToolDefinition. Classified as
collapsed-codepath per FR2.
Tests: 10/10 pass (test_tool_definition, test_external_mcp,
test_external_mcp_e2e). 2 test_type_aliases failures are pre-existing
(forward references in TypeAlias declarations; not caused by these
changes).
This commit is contained in:
+1
-1
@@ -5875,7 +5875,7 @@ def render_external_tools_panel(app: App) -> None:
|
|||||||
imgui.table_next_column()
|
imgui.table_next_column()
|
||||||
imgui.text(tinfo.get('server', 'unknown'))
|
imgui.text(tinfo.get('server', 'unknown'))
|
||||||
imgui.table_next_column()
|
imgui.table_next_column()
|
||||||
imgui.text(tinfo.get('description', ''))
|
imgui.text(ToolDefinition.from_dict(tinfo).description if isinstance(tinfo, dict) else tinfo.description)
|
||||||
imgui.end_table()
|
imgui.end_table()
|
||||||
if app.perf_profiling_enabled: app.perf_monitor.end_component("_render_external_tools_panel")
|
if app.perf_profiling_enabled: app.perf_monitor.end_component("_render_external_tools_panel")
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1965,9 +1965,11 @@ def get_tool_schemas() -> list[dict[str, Any]]:
|
|||||||
res = [t.to_dict() for t in mcp_tool_specs.get_tool_schemas()]
|
res = [t.to_dict() for t in mcp_tool_specs.get_tool_schemas()]
|
||||||
manager = get_external_mcp_manager()
|
manager = get_external_mcp_manager()
|
||||||
for tname, tinfo in manager.get_all_tools().items():
|
for tname, tinfo in manager.get_all_tools().items():
|
||||||
|
from src.type_aliases import ToolDefinition as _TD
|
||||||
|
td = _TD.from_dict(tinfo) if isinstance(tinfo, dict) else tinfo
|
||||||
res.append({
|
res.append({
|
||||||
'name': tname,
|
'name': tname,
|
||||||
'description': tinfo.get('description', ''),
|
'description': td.description,
|
||||||
'parameters': tinfo.get('inputSchema', {'type': 'object', 'properties': {}})
|
'parameters': tinfo.get('inputSchema', {'type': 'object', 'properties': {}})
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user