Skip to main content
Glama
alxspiker

MCP Server for FTP Access

delete-file

Remove files directly from an FTP server by specifying the remote file path. Simplifies file management for users accessing FTP systems.

Instructions

Delete a file from the FTP server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
remotePathYesPath of the file to delete

Implementation Reference

  • Handler function that executes the delete-file tool logic: calls ftpClient.deleteFile(remotePath), handles errors, and returns formatted text response.
    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)}` } ] }; }
  • Input schema definition for the delete-file tool using Zod (z.string for remotePath).
    { remotePath: z.string().describe("Path of the file to delete"), },
  • src/index.ts:166-196 (registration)
    Registration of the 'delete-file' tool on the MCP server using server.tool(name, description, schema, handler).
    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)}` } ] }; } } );
  • Supporting method in FtpClient class that connects to FTP, calls client.remove(remotePath) from basic-ftp, and handles deletion 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)}`); } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alxspiker/mcp-server-ftp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server