Skip to main content
Glama
alxspiker

MCP Server for FTP Access

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

Implementation Reference

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

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