Skip to main content
Glama
nao9net

FTP MCP Server

by nao9net

FTP MCP 服务器(多服务器支持版)

这是一个本地服务器,用于通过一个 MCP 服务器向多个 FTP 服务器批量上传/列出/删除文件。

每次调用工具时,通过 server 参数(别名)指定要操作哪台服务器。 上传目标使用本地绝对路径指定,文件内容本身不包含在工具调用的参数中 (这样可以将图片等二进制数据排除在 LLM 的上下文之外)。

主要用途:将生成的图片上传到 Web 服务器上的公开文件夹,然后将该 URL 传递给 wp_upload_media_from_url(wp-mcp)以正式注册到 WordPress 媒体库, 这是这个两阶段流程的前半段。


1. 设置

cd ftp-mcp
npm install

将 servers.json.example 复制为 servers.json,并填写所有要管理的服务器信息 (此文件包含所有服务器的认证信息,绝对不要公开、共享或提交到 Git。 已包含在 .gitignore 中)。

cp servers.json.example servers.json
{
  "mysite": {
    "host": "ftp.example.com",
    "user": "user@example.com",
    "password": "xxxxxxxx",
    "base_path": "/resource",
    "public_base_url": "https://example.com/resource"
  }
}
  • base_path:该服务器的上传目标根文件夹(相对于 FTP 根目录的绝对路径)。 所有工具都以这个 base_path 为起点,使用相对路径指定文件。

  • public_base_url:与 base_path 对应的公开 URL 基础地址。上传后返回此地址与相对路径 拼接而成的 URL。

  • port(可选,默认 21)、secure(可选,默认 false。使用 FTPS(隐式 TLS)时设为 true)。

Related MCP server: mcp-ftp-server

2. 注册到 Claude Code

在使用 Claude Code 的项目根文件夹中,将 mcp 服务器信息添加到 .mcp.json 中。

{
  "mcpServers": {
    "ftp": {
      "command": "node",
      "args": ["/MCPの保存パス/ftp-mcp/index.js"],
      "env": {
        "SERVERS_CONFIG_PATH": "/MCPの保存パス/ftp-mcp/servers.json"
      }
    }
  }
}

3. 提供的工具

  • ftp_list_servers — 获取已配置的服务器列表(别名、主机、base_path、public_base_url)

  • ftp_upload_file — 上传本地文件(绝对路径)并返回公开 URL。 remote_path 中包含的子文件夹会自动创建

  • ftp_list_files — 获取以 base_path 为起点的指定文件夹内的文件列表

  • ftp_delete_file — 指定以 base_path 为起点的相对路径来删除文件 (用于在导入 WordPress 媒体库后清理临时文件)

补充说明

  • 依赖库使用 basic-ftp(支持 FTP/FTPS,基于 Promise)。

  • remote_path 中包含 .. 的路径会报错(以防止写入/删除 base_path 之外的内容)。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables users to upload local files to S3-compatible storage and retrieve shareable public URLs. Files are automatically organized into unique UUID-based folders to prevent naming conflicts while preserving original filenames.
    9 npm
    MIT
  • F
    license
    A
    quality
    F
    maintenance
    Enables FTP file operations such as upload, download, list, and delete directly from Claude Desktop or Claude CLI.
    15
    -
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI agents to perform FTP/FTPS/SFTP file operations including upload, download, sync, and directory management with multi-server support.
    36
    40 npm
    5
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables accessing and managing files from configured folders with filtering and size limits, allowing listing, reading, and searching files via MCP tools and resources.
    3
    -