create-directory
Create new directories on FTP servers by specifying remote paths, enabling organized file management through structured folder creation.
Instructions
Create a new directory on the FTP server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| remotePath | Yes | Path of the directory to create |
Implementation Reference
- src/index.ts:139-162 (handler)The handler function that executes the create-directory tool logic: calls ftpClient.createDirectory(remotePath) and returns formatted text response or error.async ({ remotePath }) => { try { await ftpClient.createDirectory(remotePath); return { content: [ { type: "text", text: `Directory successfully created at ${remotePath}` } ] }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error creating directory: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- src/index.ts:136-138 (schema)Zod input schema for the create-directory tool defining the remotePath parameter.{ remotePath: z.string().describe("Path of the directory to create"), },
- src/index.ts:133-163 (registration)Registration of the create-directory tool with the MCP server using server.tool().server.tool( "create-directory", "Create a new directory on the FTP server", { remotePath: z.string().describe("Path of the directory to create"), }, async ({ remotePath }) => { try { await ftpClient.createDirectory(remotePath); return { content: [ { type: "text", text: `Directory successfully created at ${remotePath}` } ] }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error creating directory: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- src/ftp-client.ts:119-129 (helper)Supporting FtpClient method that performs the actual directory creation using basic-ftp's ensureDir.async createDirectory(remotePath: string): Promise<boolean> { try { await this.connect(); await this.client.ensureDir(remotePath); await this.disconnect(); return true; } catch (error) { console.error("Create directory error:", error); throw new Error(`Failed to create directory: ${error instanceof Error ? error.message : String(error)}`); } }