delete-directory
Remove a directory from an FTP server by specifying its remote path using this tool designed for managing FTP server content.
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-228 (handler)The asynchronous handler function for the 'delete-directory' tool that orchestrates the directory deletion via ftpClient and formats MCP-compliant 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)Zod input schema defining the 'remotePath' parameter for the 'delete-directory' tool.{ remotePath: z.string().describe("Path of the directory to delete"), },
- src/index.ts:199-229 (registration)Registration of the 'delete-directory' MCP tool using server.tool(), including inline schema and handler.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)FtpClient class method that implements directory deletion using basic-ftp's client.removeDir(), with connection management and error handling.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)}`); } }