
ftp-mcp
io.github.jwjp/ftp-mcp
Guarded FTP, FTPS, and SFTP transfers for AI coding: list, download, preview, and verified upload
Documentation
FTP Workspace MCP
A local stdio MCP server for AI coding work on projects reachable through FTP or SFTP. Explicit and implicit FTPS are also supported. It works with any project language or framework and exposes five file-level tools: remote_list, remote_compare, remote_download, remote_preview_upload, and remote_upload. Two more, remote_preview_delete and remote_delete, appear only when REMOTE_ALLOW_DELETE=true.
The server has no recursive sync, directory deletion, or shell execution tool. Deleting single files is off by default. In version 0.2, the tool names changed from ftp_* to remote_* to reflect SFTP support.
Requirements
- Node.js 22.12 or newer
- FTP, SFTP, or FTPS access to the project
- An MCP client that can start a local stdio server
Install
Install the public @jwjp/ftp-mcp package globally. Its executable is ftp-workspace-mcp, which avoids a command name collision with the existing unscoped ftp-mcp package:
npm install -g @jwjp/ftp-mcp
The package is also listed in the official MCP Registry as io.github.jwjp/ftp-mcp. Clients that install from the registry read the configuration variables from that entry.
Recent npm versions may report that install scripts for ssh2 and cpu-features were blocked. Those scripts only build optional native speedups; SFTP works without them, so you can leave them blocked.
Or run it from a GitHub checkout:
git clone https://github.com/jwjp/ftp-mcp.git
cd ftp-mcp
npm ci
The MCP examples below use the GitHub checkout. After a global npm install, set the MCP command to ftp-workspace-mcp and omit the script path and node argument.
Set the following variables in the environment that launches the MCP server. Keep passwords, private keys, and passphrases out of the project, chat, Git, CLAUDE.md, and shared MCP configuration. .env.example is a reference only; this server does not load .env files. An empty or whitespace-only value counts as unset, so an unresolved ${NAME} reference falls back to the former FTP_* name or the default instead of overriding it.
| Variable | Meaning |
|---|---|
REMOTE_PROTOCOL | ftp, sftp, ftps, or ftps-implicit; set explicitly |
REMOTE_HOST | Remote server hostname, without a URL scheme |
REMOTE_USER | Remote username |
REMOTE_PASSWORD | FTP/FTPS password, or SFTP password if not using a private key |
REMOTE_ROOT | Absolute remote project directory, for example /site |
LOCAL_ROOT | Existing absolute local project directory |
REMOTE_PORT | Optional; defaults to 21 for FTP/explicit FTPS, 22 for SFTP, 990 for implicit FTPS |
SFTP_HOST_KEY_SHA256 | Required for SFTP; trusted SSH host key fingerprint in SHA256:... format |
SFTP_PRIVATE_KEY_FILE | Optional SFTP private key file path outside LOCAL_ROOT; use instead of a password |
SFTP_PASSPHRASE | Optional passphrase for an encrypted SFTP private key |
SFTP_TIMEOUT_MS | Optional SFTP timeout in milliseconds (default 30000) for connecting, for each remote request, and for a download or upload that makes no progress |
REMOTE_EXCLUDE | Optional comma-separated additional names or relative paths, such as uploads,logs,cache |
REMOTE_MAX_FILE_BYTES | Optional per-file limit; default 10 MiB, maximum 100 MiB |
REMOTE_IDLE_TIMEOUT_MS | Optional; how long an unused remote connection stays open for reuse, in milliseconds (default 30000; 0 connects for every tool call) |
REMOTE_ALLOW_DELETE | Optional; true adds the single-file delete tools (default false) |
SFTP is SSH File Transfer Protocol, not FTP over TLS. For SFTP, get the SSH host key fingerprint from your hosting provider or another trusted channel before connecting. The server rejects a mismatched host key. FTP sends credentials in plaintext; use SFTP or FTPS if available. The server prints a warning to stderr when it starts with plain FTP. FTPS certificate verification remains enabled.
The former FTP_* variables still work for existing FTP/FTPS configurations. A missing REMOTE_PROTOCOL follows the old FTP_SECURE setting (true → ftps, false → ftp, implicit → ftps-implicit). If neither is set, the server uses ftps and prints a warning to stderr at startup. New configurations should use the REMOTE_* names and explicitly set the protocol.
The built-in exclusion list blocks these names anywhere in the path: version control (.git, .hg), .env and .env.*, vendor, node_modules, credential files (.ssh, .netrc, .git-credentials, .htpasswd, .npmrc, .pypirc, .pgpass), and agent, editor, or MCP configuration (.mcp.json, .claude, .codex, .cursor, .gemini, .vscode). Configuration is excluded because a downloaded file could make a local agent or editor run commands, for example through an MCP server definition, a task that runs when the folder opens, or a Mercurial hook. Credential files are excluded so an upload cannot publish a token. There is no setting to allow a built-in exclusion. Extra entries match a name segment or an exact relative path and its descendants, case-insensitively. Review exclusions for each project. Install dependencies or build generated files locally when appropriate.
VS Code with GitHub Copilot
Use Chat: Open Customizations → MCP Servers → Add Server → Command (stdio) → Global → Copilot Global, or edit your personal ~/.copilot/mcp-config.json. Current VS Code Copilot uses mcpServers in this personal file; .vscode/mcp.json is the older editor-managed format. See the VS Code MCP configuration reference.
Example personal configuration for SFTP (replace the paths and set the referenced user environment variables):
{
"mcpServers": {
"remote-workspace": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/ftp-mcp/src/server.js"],
"env": {
"REMOTE_PROTOCOL": "sftp",
"REMOTE_HOST": "${MY_REMOTE_HOST}",
"REMOTE_USER": "${MY_REMOTE_USER}",
"REMOTE_PASSWORD": "${MY_REMOTE_PASSWORD}",
"REMOTE_ROOT": "/site",
"LOCAL_ROOT": "/absolute/path/to/my-project",
"SFTP_HOST_KEY_SHA256": "${MY_SFTP_HOST_KEY_SHA256}"
},
"tools": ["*"]
}
}
}
The ${NAME} syntax is resolved by the Copilot harness. For key authentication, replace REMOTE_PASSWORD with SFTP_PRIVATE_KEY_FILE (and SFTP_PASSPHRASE if needed). For FTP, set REMOTE_PROTOCOL to ftp, omit SFTP_HOST_KEY_SHA256, and provide REMOTE_PASSWORD. On Windows, use absolute paths with JSON-escaped backslashes or forward slashes.
Claude Code
Claude Code can launch this same stdio server. Set the environment variables from the table above in the environment that starts Claude Code. From the local project directory you want to edit, register the server at local scope:
claude mcp add --scope local --transport stdio remote-workspace -- node /absolute/path/to/ftp-mcp/src/server.js
claude mcp get remote-workspace
On Windows, use a path such as C:/path/to/ftp-mcp/src/server.js. Local scope keeps the definition private to that project. Do not pass passwords through --env in a shell command, because shell history and MCP configuration may retain them. Restart Claude Code after changing user environment variables. Run /mcp to check the connection. See the Claude Code MCP documentation.
For a team-shared setup, Claude Code also reads .mcp.json in the project root. Use environment-variable references such as ${REMOTE_PASSWORD} and never commit a literal password. This server excludes .mcp.json from transfers by default.
Codex
The Codex desktop app, CLI, and IDE extension share MCP settings. Add the server through Settings → MCP servers → Add server → STDIO, or add this entry to your personal ~/.codex/config.toml (on Windows, %USERPROFILE%\.codex\config.toml):
[mcp_servers.remote_workspace]
command = "node"
args = ["C:/absolute/path/to/ftp-mcp/src/server.js"]
env_vars = ["REMOTE_PROTOCOL", "REMOTE_HOST", "REMOTE_USER", "REMOTE_PASSWORD", "REMOTE_ROOT", "LOCAL_ROOT", "REMOTE_PORT", "SFTP_HOST_KEY_SHA256", "SFTP_PRIVATE_KEY_FILE", "SFTP_PASSPHRASE", "SFTP_TIMEOUT_MS", "REMOTE_EXCLUDE", "REMOTE_MAX_FILE_BYTES", "REMOTE_IDLE_TIMEOUT_MS", "REMOTE_ALLOW_DELETE"]
Replace the script path and set the required variables locally before starting Codex. env_vars forwards named values without storing them in TOML. Restart Codex after changing configuration. codex mcp list or /mcp shows the server. The same entry may instead go in a trusted project's .codex/config.toml. See the Codex MCP guide.
File workflow
remote_list({"path":""}), then list only relevant subdirectories. Each page returns up to 200 allowed entries sorted by name, with case-sensitive ordering. Whentruncatedistrue, passnextCursorascursorwith the samepathto get the next page. Each page reads the current directory, so files added or renamed at or before the cursor may be missed.remote_download({"path":"src/example.php"}). If a local copy differs, the tool returns its SHA-256; compare it before replacing it withexpectedLocalSha256.- Edit and test locally.
remote_preview_upload({"path":"src/example.php"}). Review the path and both hashes. It returns anuploadTokenwhen content differs.createDirectorieslists remote parent directories that do not exist yet; the upload creates them.remote_upload({"path":"src/example.php","uploadToken":"..."})within ten minutes. A changed local or remote file invalidates the preview, and so does a listed directory that someone else created in the meantime. The result lists anycreatedDirectories.
Each tool declares an output schema and returns its result as structuredContent, with the same JSON in a text block for clients that read only text. A listed size is null when the server's listing gives none.
Upload tokens are single-use and held only in the MCP process. Restarting it requires a fresh preview. Uploads first create the directories the preview listed, one at a time, outermost first. If the upload then fails before the file is renamed into place, the server removes those directories again, innermost first. It removes only empty directories, so files another writer added are kept, and it reports any directory it could not remove. Uploads then check the remote listing against the preview, so a file that appeared, disappeared, or changed size stops the upload before any bytes are sent. They then write a temporary remote file, verify it by SHA-256, compare the remote target with the preview by SHA-256 again, and rename the temporary file into place. After the rename, the listing must show a file of the uploaded size. For FTP replacement, the old file is moved to a backup name because some servers refuse to rename over an existing file. If the final rename fails, the server checks whether the target is absent before attempting to restore the backup. If it cannot confirm the result, it reports the target and backup paths for inspection. The server also keeps the FTP backup until it verifies the final file and reports the backup location if verification or cleanup fails. For SFTP replacement, the server must support the posix-rename@openssh.com extension.
Each MCP process keeps one remote connection and runs one tool call on it at a time. A connection unused for REMOTE_IDLE_TIMEOUT_MS is closed, and an idle connection is checked (FTP NOOP, or an SFTP directory query) before reuse, so one the server has dropped is replaced. A check that gets no answer within 5 seconds, as happens when a firewall drops an idle connection silently, also leads to a new connection. A failed tool call closes its connection, and the next call reconnects. Each MCP process runs one upload or download at a time. Other MCP processes, editors, and remote writers can still change files between verification and rename. FTP replacement has a brief interval when the target name is absent. A replacement keeps the permission bits of the file it replaces: the server copies them to the temporary file before the rename. SFTP reads and sets them directly. FTP reads them from a Unix-style listing and sets them with SITE CHMOD; a server that lists no permissions, such as most Windows servers, is left alone. If the server refuses the change, the upload still completes and its result carries a warning with the previous mode. Ownership is not preserved. An interruption can leave a temporary or backup file. Use a separate deployment or backup process when interruption cannot be tolerated.
Comparing a directory
Call remote_compare({"path":"src"}). It compares one local directory with its remote counterpart, one level deep, and gives each entry a status:
localOnlyorremoteOnlytypeDiffers: a file on one side, a directory on the otherboth: a directory on both sidessizeDiffers, orsizeUnknownwhen the listing gives no sizesameSize
With "hash":true, up to 20 same-size files per page are read on both sides and marked same or differs. hashLimited says some were not checked. Pages and cursor work as in remote_list. It changes nothing.
Deleting a remote file
With REMOTE_ALLOW_DELETE=true, the server also offers:
remote_preview_delete({"path":"src/old.php"})hashes the remote file and returns adeleteToken. It deletes nothing.remote_delete({"path":"src/old.php","deleteToken":"..."})within ten minutes. The file is read again, and it is deleted only if its SHA-256 still matches the preview. The listing must then no longer show it.
Only regular files within REMOTE_MAX_FILE_BYTES can be deleted. Directories, symlinks, and excluded paths cannot. Tokens are single-use, and the local copy is never touched. The server's instructions tell the agent to delete only when the user asked for it, but an agent can still call the tools on its own. Turn deletion on only for projects where a lost remote file can be restored, and leave it off otherwise. Another writer can change the file between the final check and the deletion.
Boundaries
- Paths stay beneath fixed local and remote roots. Parent traversal, absolute paths, control characters, excluded entries, and discovered symlinks are rejected. Colons and trailing dots are rejected everywhere, and reserved device names such as
NULorcon.phpon Windows, so Windows aliases (.env::$DATA,.mcp.json.) cannot reach an excluded file. Existing local paths are also checked under their resolved name, which catches 8.3 short names such asNODE_M~1. - Each read and upload is limited by
REMOTE_MAX_FILE_BYTES. Reads stop when the limit is exceeded, even if the server reports an incorrect size. File data is hashed and transferred in chunks. The server rejects a transfer that ends before the file size reported by the directory listing. - An SFTP connection or request that exceeds
SFTP_TIMEOUT_MS, or a transfer that moves no data for that long, closes its connection. A large file that keeps transferring is not cut off. If a rename times out, inspect the remote target before retrying because the server may have completed the rename. - Remote symlink detection depends on the server listing and cannot prevent a server-side path change between validation and transfer.
- The MCP tools exclude their reserved temporary and backup names. Configure access to these files separately if the remote directory is served over HTTP.
- On Unix-like systems, new downloads are created with owner-only permissions, and replacing an existing file preserves its read, write, and execute permission bits.
- Unexpected transport errors return only an error code to the MCP client, such as
550orECONNREFUSED. The full message goes to stderr, the client's server log, with the configured password and passphrase redacted. - No remote credentials or project files are stored in this repository. Previews stream file contents to compute hashes. Downloads stream to a temporary file beside the local target before renaming it. Uploads stream to a temporary file beside the remote target and may briefly create a backup on FTP replacement. Cleanup is attempted after failure, but a connection loss can prevent it.
Development
npm test
npm audit --omit=dev
Tests cover path restrictions, FTP and SFTP transport behavior, upload previews, and legacy and current MCP stdio handshakes. The integration suite starts temporary loopback servers and checks downloads, verified replacements, and server identity validation through the stdio MCP tools. Run it with Python 3.14 and Node.js on your PATH:
python -m pip install -r integration/requirements.txt
python integration/run.py
To test an npm tarball locally, run npm pack and pass the printed filename to python integration/run.py --package <filename>. The integration suite installs the tarball in a temporary directory and starts the installed ftp-workspace-mcp command.
To release, bump the version in package.json and package-lock.json through a pull request, then publish a GitHub release tagged v<version> on the merge commit. The Publish workflow checks the tag, runs the tests, and verifies transfers through the installed CLI. It publishes the verified tarball through npm trusted publishing.
Test against your own server before relying on a production upload. Contributions are welcome under the MIT license.
@jwjp/ftp-mcpnpm install @jwjp/ftp-mcp