Skip to main content
Glama
alxspiker

MCP Server for FTP Access

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

Implementation Reference

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

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