delete_directory
Remove a directory and all its contents permanently through recursive deletion. This operation cannot be undone, so use with caution when managing file systems.
Instructions
Permanently delete a directory and all of its contents, including all files and subdirectories. This is a recursive operation that cannot be undone. Use with extreme caution.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The path to the directory to delete |
Implementation Reference
- src/index.ts:395-406 (handler)Handler implementation for the 'delete_directory' tool. It takes a directory path from arguments, uses Node.js fs.rm with recursive and force options to delete the directory and all contents, then returns a success message.case "delete_directory": { const dirPath = args.path as string; await fs.rm(dirPath, { recursive: true, force: true }); return { content: [ { type: "text", text: `Successfully deleted directory ${dirPath}`, }, ], }; }
- src/index.ts:126-139 (schema)Tool schema definition including name, description, and input schema requiring a 'path' string parameter. This is part of the TOOLS array used for tool registration and listing.{ name: "delete_directory", description: "Permanently delete a directory and all of its contents, including all files and subdirectories. This is a recursive operation that cannot be undone. Use with extreme caution.", inputSchema: { type: "object", properties: { path: { type: "string", description: "The path to the directory to delete", }, }, required: ["path"], }, },
- src/index.ts:261-262 (registration)Registration of all tools, including delete_directory, via the ListToolsRequestSchema handler that returns the TOOLS array containing the tool definitions.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS };