delete-directory
Remove directories from FTP servers by specifying the remote path to delete. This tool helps manage server storage by eliminating unwanted folders through the MCP Server for FTP Access.
Instructions
Delete a directory from the FTP server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| remotePath | Yes | Path of the directory to delete |
Implementation Reference
- src/index.ts:205-227 (handler)The handler function for the 'delete-directory' tool, which invokes ftpClient.deleteDirectory and formats success or error responses.async ({ remotePath }) => { try { await ftpClient.deleteDirectory(remotePath); return { content: [ { type: "text", text: `Directory successfully deleted from ${remotePath}` } ] }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error deleting directory: ${error instanceof Error ? error.message : String(error)}` } ] }; }
- src/index.ts:202-204 (schema)Input schema definition using Zod for the remotePath parameter.{ remotePath: z.string().describe("Path of the directory to delete"), },
- src/index.ts:199-229 (registration)Registration of the 'delete-directory' tool on the MCP server using server.tool.server.tool( "delete-directory", "Delete a directory from the FTP server", { remotePath: z.string().describe("Path of the directory to delete"), }, async ({ remotePath }) => { try { await ftpClient.deleteDirectory(remotePath); return { content: [ { type: "text", text: `Directory successfully deleted from ${remotePath}` } ] }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error deleting directory: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- src/ftp-client.ts:143-153 (helper)Supporting method in FtpClient class that handles the actual FTP directory deletion using basic-ftp's removeDir.async deleteDirectory(remotePath: string): Promise<boolean> { try { await this.connect(); await this.client.removeDir(remotePath); await this.disconnect(); return true; } catch (error) { console.error("Delete directory error:", error); throw new Error(`Failed to delete directory: ${error instanceof Error ? error.message : String(error)}`); } }