delete-file
Remove files from an FTP server by specifying the remote file path. This tool helps manage storage and clean up unnecessary files on FTP servers.
Instructions
Delete a file from the FTP server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| remotePath | Yes | Path of the file to delete |
Implementation Reference
- src/index.ts:166-196 (registration)Registers the MCP 'delete-file' tool with Zod input schema for remotePath and an async handler that calls ftpClient.deleteFile(remotePath), handles success/error responses with markdown text content.server.tool( "delete-file", "Delete a file from the FTP server", { remotePath: z.string().describe("Path of the file to delete"), }, async ({ remotePath }) => { try { await ftpClient.deleteFile(remotePath); return { content: [ { type: "text", text: `File successfully deleted from ${remotePath}` } ] }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error deleting file: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- src/ftp-client.ts:131-141 (helper)Core implementation of file deletion in FtpClient class: connects to FTP server, calls basic-ftp Client.remove(remotePath) to delete the file, disconnects, and propagates errors.async deleteFile(remotePath: string): Promise<boolean> { try { await this.connect(); await this.client.remove(remotePath); await this.disconnect(); return true; } catch (error) { console.error("Delete file error:", error); throw new Error(`Failed to delete file: ${error instanceof Error ? error.message : String(error)}`); } }