@@ -76,15 +76,15 @@ def get_tool_description(self) -> Tool:
76
76
async def run_tool (self , arguments : Dict [str , Any ]) -> Sequence [TextContent ]:
77
77
"""Execute the tool with given arguments."""
78
78
try :
79
- # Handle 'files' key missing
80
79
if "files" not in arguments :
81
80
if "file_path" not in arguments :
82
81
raise RuntimeError ("Missing required argument: 'files'" )
83
82
84
- # Convert legacy format to new format
83
+ # Legacy format support
85
84
file_path = arguments ["file_path" ]
86
85
line_start = arguments .get ("line_start" , 1 )
87
86
line_end = arguments .get ("line_end" )
87
+ # Convert to new format with mandatory fields
88
88
arguments = {
89
89
"files" : [
90
90
{
@@ -98,15 +98,17 @@ async def run_tool(self, arguments: Dict[str, Any]) -> Sequence[TextContent]:
98
98
}
99
99
]
100
100
}
101
+ # Legacy format request
101
102
legacy_format = True
102
103
else :
103
104
legacy_format = False
104
105
105
106
# Handle request
106
107
result = await self .editor .read_multiple_ranges (arguments ["files" ])
107
108
108
- # Convert to legacy format if it was a legacy request
109
+ # Convert to appropriate format based on request type
109
110
if legacy_format :
111
+ # Legacy format expects a flat structure
110
112
file_path = arguments ["files" ][0 ]["file_path" ]
111
113
file_result = result [file_path ]
112
114
range_result = file_result ["ranges" ][0 ]
@@ -120,14 +122,15 @@ async def run_tool(self, arguments: Dict[str, Any]) -> Sequence[TextContent]:
120
122
"file_size" : range_result ["content_size" ],
121
123
}
122
124
else :
125
+ # New format returns multi-file, multi-range structure
123
126
response = result
124
127
125
128
return [TextContent (type = "text" , text = json .dumps (response , indent = 2 ))]
126
129
127
130
except KeyError as e :
128
- raise RuntimeError (f"Missing required argument: '{ e } '" )
131
+ raise RuntimeError (f"Missing required argument: '{ e } '" ) from e
129
132
except Exception as e :
130
- raise RuntimeError (f"Error processing request: { str (e )} " )
133
+ raise RuntimeError (f"Error processing request: { str (e )} " ) from e
131
134
132
135
133
136
class EditTextFileContentsHandler :
0 commit comments