Skip to main content
Glama
alxspiker

MCP Server for FTP Access

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
NameRequiredDescriptionDefault
remotePathYesPath of the directory to delete

Implementation Reference

  • 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)}` } ] }; }
  • 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)}` } ] }; } } );
  • 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)}`); } }

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