MCPcopy Create free account
hub / github.com/vercel/examples / delete_folder

Function delete_folder

python/vibe-coding-ide/backend/src/agent/tools/fs_ops.py:220–270  ·  view source on GitHub ↗

Delete a folder and all files beneath it in the project mapping (for large cleanups only). Use with caution; this removes every file under the path. Prefer rename_folder to archive first when possible. Args: folder_path: Folder path to remove. Returns: JSON string inclu

(ctx: RunContextWrapper[IDEContext], folder_path: str)

Source from the content-addressed store, hash-verified

218
219@function_tool
220async def delete_folder(ctx: RunContextWrapper[IDEContext], folder_path: str) -> str:
221 """Delete a folder and all files beneath it in the project mapping (for large cleanups only).
222
223 Use with caution; this removes every file under the path. Prefer rename_folder to archive first when possible.
224
225 Args:
226 folder_path: Folder path to remove.
227 Returns:
228 JSON string including count of removed files.
229 """
230 tool_id = f"tc_{len(ctx.context.events) + 1}"
231 args = {"folder_path": folder_path}
232 ctx.context.events.append(
233 {
234 "phase": "started",
235 "tool_id": tool_id,
236 "name": "delete_folder",
237 "arguments": args,
238 }
239 )
240
241 normalized = folder_path.rstrip("/")
242 removed = 0
243 removed_paths: list[str] = []
244 remaining: dict[str, str] = {}
245 for path, content in ctx.context.project.items():
246 if path == normalized or path.startswith(normalized + "/"):
247 removed += 1
248 removed_paths.append(path)
249 continue
250 remaining[path] = content
251 ctx.context.project = remaining
252
253 # best-effort autosync to running sandboxes
254 output = {"folder_path": folder_path, "deleted": True, "removed_files": removed}
255 try:
256 await autosync_after_fs_change(
257 ctx, deleted_files=removed_paths, deleted_dirs=[normalized]
258 )
259 except Exception:
260 pass
261
262 ctx.context.events.append(
263 {
264 "phase": "completed",
265 "tool_id": tool_id,
266 "name": "delete_folder",
267 "output_data": output,
268 }
269 )
270 return json.dumps(output)
271
272
273@function_tool

Callers

nothing calls this directly

Calls 1

autosync_after_fs_changeFunction · 0.90

Tested by

no test coverage detected