Skip to main content
Glama
alxspiker

MCP Server for FTP Access

用于 FTP 访问的 MCP 服务器

此模型上下文协议 (MCP) 服务器提供了与 FTP 服务器交互的工具。它允许 Claude.app 在 FTP 服务器上列出目录、下载和上传文件、创建目录以及删除文件/目录。

功能

  • 列出目录内容:查看 FTP 服务器上的文件和文件夹

  • 下载文件:从 FTP 服务器检索文件内容

  • 上传文件:创建新文件或更新现有文件

  • 创建目录:在 FTP 服务器上创建新文件夹

  • 删除文件/目录:移除文件或目录

Related MCP server: MCP SSH Server

安装

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 mcp-server-ftp:

npx -y @smithery/cli install @alxspiker/mcp-server-ftp --client claude

先决条件

  • Node.js 16 或更高版本

  • Claude for Desktop(或其他兼容 MCP 的客户端)

从源码构建

Linux/macOS

# Clone the repository
git clone https://github.com/alxspiker/mcp-server-ftp.git
cd mcp-server-ftp

# Install dependencies
npm install

# Build the project
npm run build

Windows

# Clone the repository
git clone https://github.com/alxspiker/mcp-server-ftp.git
cd mcp-server-ftp

# Run the Windows build helper script
build-windows.bat

build-windows.bat 脚本负责在 Windows 系统上安装依赖项并进行构建,如果 TypeScript 编译器出现问题,它还提供回退选项。

配置

要将此服务器与 Claude for Desktop 一起使用,请将其添加到您的配置文件中:

MacOS/Linux

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "ftp-server": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-ftp/build/index.js"],
      "env": {
        "FTP_HOST": "ftp.example.com",
        "FTP_PORT": "21",
        "FTP_USER": "your-username",
        "FTP_PASSWORD": "your-password",
        "FTP_SECURE": "false"
      }
    }
  }
}

Windows

编辑 %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "ftp-server": {
      "command": "node",
      "args": ["C:\\path\\to\\mcp-server-ftp\\build\\index.js"],
      "env": {
        "FTP_HOST": "ftp.example.com",
        "FTP_PORT": "21",
        "FTP_USER": "your-username",
        "FTP_PASSWORD": "your-password",
        "FTP_SECURE": "false"
      }
    }
  }
}

Windows 构建问题排查

如果您在 Windows 上遇到构建问题:

  1. 使用提供的 build-windows.bat 脚本,它处理了常见的构建问题

  2. 确保已正确安装 Node.js 和 npm

  3. 尝试直接运行 TypeScript 编译器:npx tsc

  4. 如果仍然有问题,您可以通过运行以下命令使用 build 目录中的预编译文件:

    node path\to\mcp-server-ftp\build\index.js

配置选项

环境变量

描述

默认值

FTP_HOST

FTP 服务器主机名或 IP 地址

localhost

FTP_PORT

FTP 服务器端口

21

FTP_USER

FTP 用户名(支持加密)

anonymous

FTP_PASSWORD

FTP 密码(支持加密)

(空字符串)

FTP_SECURE

使用安全 FTP (FTPS),当 FTP_PROTOCOL=sftp 时忽略

false

FTP_PROTOCOL

使用的协议:ftpsftp

ftp

FTP_PRIVATE_KEY_PATH

SFTP 的 SSH 私钥路径 (例如 ~/.ssh/id_ed25519)

(自动检测)

FTP_PASSPHRASE

SSH 私钥的密码短语(支持加密)

(空字符串)

FTP_ENCRYPTION_KEY

用于解密凭据的 64 字符十六进制 AES-256 密钥

(已禁用)

SSH / SFTP 支持

除了普通的 FTP 和 FTPS 外,该服务器还支持 SFTP(SSH 文件传输协议),它通过加密的 SSH 连接运行,与 FTPS 无关。

设置 FTP_PROTOCOL=sftp 可将服务器切换到 SFTP 模式。默认端口将更改为 22

身份验证

SFTP 支持两种自动选择的身份验证方法:

  • 私钥 — 如果找到密钥(见下文),则将其用于身份验证。如果密钥受密码短语保护,则使用 FTP_PASSPHRASE 解密密钥。

  • 密码 — 如果未找到密钥,则使用 FTP_PASSWORD 进行密码身份验证。

密钥发现

服务器按以下顺序查找私钥:

  1. FTP_PRIVATE_KEY_PATH 中的路径(如果已设置)

  2. ~/.ssh/id_ed25519

  3. ~/.ssh/id_rsa

  4. ~/.ssh/id_ecdsa

配置示例

{
  "mcpServers": {
    "ftp-server": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-ftp/build/index.js"],
      "env": {
        "FTP_HOST": "sftp.example.com",
        "FTP_PORT": "22",
        "FTP_PROTOCOL": "sftp",
        "FTP_USER": "your-username",
        "FTP_PRIVATE_KEY_PATH": "~/.ssh/id_ed25519",
        "FTP_PASSPHRASE": "your-key-passphrase"
      }
    }
  }
}

FTP_PASSPHRASEFTP_USER 都支持 enc: 加密格式 — 请参阅 凭据加密

凭据加密

在 Claude 配置文件中存储明文密码存在安全风险。服务器支持对 FTP_USERFTP_PASSWORD 进行 AES-256-GCM 加密,因此配置文件中仅包含密文。

1. 生成加密密钥

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

请妥善保管此密钥 — 像对待主密码一样对待它。

2. 加密凭据值

npm run build
FTP_ENCRYPTION_KEY=<your-64-char-hex-key> npm run encrypt-env -- <plaintext-value>

输出是一个格式为 enc:<iv_hex>:<tag_hex>:<ciphertext_hex> 的自包含加密字符串。

3. 在配置中使用加密值

FTP_ENCRYPTION_KEY 与加密后的凭据一起设置。不以 enc: 开头的值将被视为明文,因此您可以选择性地进行加密。

{
  "mcpServers": {
    "ftp-server": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-ftp/build/index.js"],
      "env": {
        "FTP_HOST": "ftp.example.com",
        "FTP_PORT": "21",
        "FTP_USER": "enc:aabbcc...:ddeeff...:112233...",
        "FTP_PASSWORD": "enc:aabbcc...:ddeeff...:112233...",
        "FTP_SECURE": "false",
        "FTP_ENCRYPTION_KEY": "<your-64-char-hex-key>"
      }
    }
  }
}

使用方法

配置并重启 Claude for Desktop 后,您可以使用自然语言执行 FTP 操作:

  • "列出我 FTP 服务器上 /public 目录中的文件"

  • "从 FTP 服务器下载文件 /data/report.txt"

  • "将此文本作为名为 notes.txt 的文件上传到 FTP 服务器"

  • "在 FTP 服务器上创建一个名为 'backups' 的新目录"

  • "从 FTP 服务器删除文件 obsolete.txt"

  • "从 FTP 服务器移除空目录 /old-project"

可用工具

工具名称

描述

list-directory

列出 FTP 目录的内容

download-file

从 FTP 服务器下载文件

upload-file

上传文件到 FTP 服务器

create-directory

在 FTP 服务器上创建新目录

delete-file

从 FTP 服务器删除文件

delete-directory

从 FTP 服务器删除目录

安全注意事项

  • 使用 凭据加密 功能,避免在配置文件中存储明文密码。

  • 尽可能优先使用 SFTP (FTP_PROTOCOL=sftp) 而非普通 FTP 或 FTPS — 它使用 SSH 且不需要证书管理。

  • 如果您的服务器支持 FTPS 但无法使用 SFTP,请考虑通过设置 FTP_SECURE=true 来使用 FTPS(安全 FTP)。

  • 服务器会在您系统的临时目录中为上传和下载创建临时文件。

许可证

MIT

Install Server
A
license - permissive license
A
quality
A
maintenance

Maintenance

Maintainers
Response time
1wRelease cycle
3Releases (12mo)
Commit activity

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables SSH remote access to servers through Claude, allowing users to execute commands, transfer files via SFTP, and manage multiple remote connections using natural language.
    12
    8
    MIT
  • A
    license
    -
    quality
    -
    maintenance
    Connects Claude to remote servers via SSH to execute commands, manage files, and browse directories. It allows users to add, edit, and switch between multiple server configurations through natural language conversations.

View all related MCP servers

Related MCP Connectors

  • Connect Claude to Fathom meeting recordings, transcripts, and summaries

  • Read, edit, publish, and preview your pepita websites from Claude.

  • Upload, edit, compress, protect, redact, and compare PDFs with KDAN PDF in Claude and ChatGPT.

View all MCP Connectors

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