feat(mcp): finalize Python structural tools with security checks and indentation normalization

This commit is contained in:
2026-05-13 22:03:37 -04:00
parent 46a415c9a0
commit b9e4050175
7 changed files with 203 additions and 26 deletions
+15 -5
View File
@@ -1357,27 +1357,37 @@ def dispatch(tool_name: str, tool_input: dict[str, Any]) -> str:
if tool_name == "ts_cpp_update_definition":
return ts_cpp_update_definition(path, str(tool_input.get("name", "")), str(tool_input.get("new_content", "")))
if tool_name == "py_remove_def":
return py_struct_tools.py_remove_def(path, str(tool_input.get("name", "")))
p, err = _resolve_and_check(path)
if err: return err
return py_struct_tools.py_remove_def(str(p), str(tool_input.get("name", "")))
if tool_name == "py_add_def":
p, err = _resolve_and_check(path)
if err: return err
return py_struct_tools.py_add_def(
path,
str(p),
str(tool_input.get("name", "")),
str(tool_input.get("new_content", "")),
str(tool_input.get("anchor_type", "")),
tool_input.get("anchor_symbol")
)
if tool_name == "py_move_def":
p_src, err = _resolve_and_check(str(tool_input.get("src_path", "")))
if err: return err
p_dest, err = _resolve_and_check(str(tool_input.get("dest_path", "")))
if err: return err
return py_struct_tools.py_move_def(
str(tool_input.get("src_path", "")),
str(tool_input.get("dest_path", "")),
str(p_src),
str(p_dest),
str(tool_input.get("name", "")),
str(tool_input.get("dest_name", "")),
str(tool_input.get("anchor_type", "")),
tool_input.get("anchor_symbol")
)
if tool_name == "py_region_wrap":
p, err = _resolve_and_check(path)
if err: return err
return py_struct_tools.py_region_wrap(
path,
str(p),
int(tool_input.get("start_line", 1)),
int(tool_input.get("end_line", 1)),
str(tool_input.get("region_name", ""))