create-directory
Create new directories on an FTP server by specifying the remote path, enabling organized file storage and management through direct interaction.
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)MCP tool handler for create-directory: calls ftpClient.createDirectory and returns formatted MCP response.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)Input schema for the create-directory tool using Zod.{ remotePath: z.string().describe("Path of the directory to create"), },
- src/index.ts:133-163 (registration)Registration of the create-directory MCP tool via server.tool call.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)FtpClient helper method implementing the FTP directory creation logic using basic-ftp library.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)}`); } }