ftp-mcp 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ftpconfig.example +48 -0
- package/README.md +717 -0
- package/index.js +1274 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
# ftp-mcp
|
|
2
|
+
|
|
3
|
+
MCP server providing enhanced FTP/SFTP operations with smart sync, search, and direct file access.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Deployment Presets** - Save complete deployment workflows, run with one command
|
|
8
|
+
- 🔄 **Smart Sync** - Only transfer changed files between local and remote
|
|
9
|
+
- 🛡️ **Git-Aware** - Automatically respects `.gitignore` and `.ftpignore` patterns
|
|
10
|
+
- 🔍 **Search & Tree** - Find files by pattern, view entire directory structures
|
|
11
|
+
- 📝 **Direct Access** - Read/write file contents without downloading
|
|
12
|
+
- 📦 **Batch Operations** - Upload/download multiple files at once
|
|
13
|
+
- 🔐 **Multi-Profile** - Support for multiple FTP servers via `.ftpconfig`
|
|
14
|
+
- ⚡ **FTP & SFTP** - Automatic protocol detection
|
|
15
|
+
- 🎯 **Metadata Operations** - Check existence, get stats, manage permissions
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Install & Initialise
|
|
20
|
+
|
|
21
|
+
Run this **in your project directory** to scaffold the config files:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx ftp-mcp --init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This creates `.ftpconfig` and `.ftpconfig.example` in your current directory. Then install globally so your MCP client can always find the server:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g ftp-mcp
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 2. Configure Credentials
|
|
34
|
+
|
|
35
|
+
**Option A: Environment Variables**
|
|
36
|
+
|
|
37
|
+
**Required:**
|
|
38
|
+
```bash
|
|
39
|
+
# Windows
|
|
40
|
+
setx FTPMCP_HOST "ftp.example.com"
|
|
41
|
+
setx FTPMCP_USER "username"
|
|
42
|
+
setx FTPMCP_PASSWORD "password"
|
|
43
|
+
|
|
44
|
+
# Linux/Mac
|
|
45
|
+
export FTPMCP_HOST="ftp.example.com"
|
|
46
|
+
export FTPMCP_USER="username"
|
|
47
|
+
export FTPMCP_PASSWORD="password"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Optional:**
|
|
51
|
+
```bash
|
|
52
|
+
# Windows
|
|
53
|
+
setx FTPMCP_PORT "21" # Custom port (defaults: 21 for FTP, 22 for SFTP)
|
|
54
|
+
|
|
55
|
+
# Linux/Mac
|
|
56
|
+
export FTPMCP_PORT="21" # Custom port (defaults: 21 for FTP, 22 for SFTP)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Variable Reference:**
|
|
60
|
+
- `FTPMCP_HOST` *(required)* - FTP server hostname (e.g., `ftp.example.com` or `sftp://sftp.example.com`)
|
|
61
|
+
- `FTPMCP_USER` *(required)* - Username for authentication
|
|
62
|
+
- `FTPMCP_PASSWORD` *(required)* - Password for authentication
|
|
63
|
+
- `FTPMCP_PORT` *(optional)* - Custom port number (defaults: 21 for FTP, 22 for SFTP)
|
|
64
|
+
|
|
65
|
+
**Option B: Project Config File (Recommended)**
|
|
66
|
+
|
|
67
|
+
Create `.ftpconfig` in your project directory:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"production": {
|
|
72
|
+
"host": "ftp.example.com",
|
|
73
|
+
"user": "prod-user",
|
|
74
|
+
"password": "your-password",
|
|
75
|
+
"port": 21,
|
|
76
|
+
"secure": false
|
|
77
|
+
},
|
|
78
|
+
"staging": {
|
|
79
|
+
"host": "sftp://staging.example.com",
|
|
80
|
+
"user": "staging-user",
|
|
81
|
+
"password": "your-password",
|
|
82
|
+
"port": 22
|
|
83
|
+
},
|
|
84
|
+
"default": {
|
|
85
|
+
"host": "ftp.mysite.com",
|
|
86
|
+
"user": "default-user",
|
|
87
|
+
"password": "your-password"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The server will check for `.ftpconfig` first, then fall back to environment variables.
|
|
93
|
+
|
|
94
|
+
**Add Deployment Presets (Optional but Recommended):**
|
|
95
|
+
|
|
96
|
+
In the same `.ftpconfig` file, add a `deployments` section to save complete deployment workflows:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"production": {
|
|
101
|
+
"host": "ftp.example.com",
|
|
102
|
+
"user": "prod-user",
|
|
103
|
+
"password": "your-password"
|
|
104
|
+
},
|
|
105
|
+
"deployments": {
|
|
106
|
+
"deploy-frontend": {
|
|
107
|
+
"profile": "production",
|
|
108
|
+
"local": "./dist",
|
|
109
|
+
"remote": "/public_html",
|
|
110
|
+
"description": "Deploy frontend build to production",
|
|
111
|
+
"exclude": [
|
|
112
|
+
"*.map",
|
|
113
|
+
"*.test.js",
|
|
114
|
+
"test/**"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"deploy-api": {
|
|
118
|
+
"profile": "production",
|
|
119
|
+
"local": "./api/build",
|
|
120
|
+
"remote": "/api",
|
|
121
|
+
"description": "Deploy API to production"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Then simply say: **"Deploy frontend"** or **"Run deploy-api"** in Amp!
|
|
128
|
+
|
|
129
|
+
### 3. Add to Amp Code
|
|
130
|
+
|
|
131
|
+
Open **Settings → MCP Servers**, click **Add Server**:
|
|
132
|
+
|
|
133
|
+
- **Server Name:** `FTP` (or any name you prefer)
|
|
134
|
+
- **Command or URL:** `ftp-mcp-server`
|
|
135
|
+
- **Arguments:** (leave empty)
|
|
136
|
+
- **Environment Variables:** (leave empty if using system env vars)
|
|
137
|
+
|
|
138
|
+
Click **Update Server** and restart Amp.
|
|
139
|
+
|
|
140
|
+
## Deployment Presets
|
|
141
|
+
|
|
142
|
+
Deployment presets allow you to save complete deployment workflows and run them with a single command. Perfect for frequent deployments to production, staging, or development environments.
|
|
143
|
+
|
|
144
|
+
### Setting Up Deployment Presets
|
|
145
|
+
|
|
146
|
+
Add a `deployments` section to your `.ftpconfig`:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"production": { "host": "...", "user": "...", "password": "..." },
|
|
151
|
+
"staging": { "host": "...", "user": "...", "password": "..." },
|
|
152
|
+
"deployments": {
|
|
153
|
+
"deploy-frontend": {
|
|
154
|
+
"profile": "production",
|
|
155
|
+
"local": "./dist",
|
|
156
|
+
"remote": "/public_html",
|
|
157
|
+
"description": "Deploy frontend build to production",
|
|
158
|
+
"exclude": ["*.map", "test/**"]
|
|
159
|
+
},
|
|
160
|
+
"deploy-staging": {
|
|
161
|
+
"profile": "staging",
|
|
162
|
+
"local": "./dist",
|
|
163
|
+
"remote": "/www/staging",
|
|
164
|
+
"description": "Deploy to staging environment"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Deployment Configuration Options
|
|
171
|
+
|
|
172
|
+
Each deployment preset can include:
|
|
173
|
+
|
|
174
|
+
- **`profile`** *(required)* - Which FTP profile to use (must exist in the same .ftpconfig)
|
|
175
|
+
- **`local`** *(required)* - Local directory to deploy (relative or absolute path)
|
|
176
|
+
- **`remote`** *(required)* - Remote destination path on the server
|
|
177
|
+
- **`description`** *(optional)* - Human-readable description of what this deployment does
|
|
178
|
+
- **`exclude`** *(optional)* - Array of additional patterns to exclude (on top of default ignores)
|
|
179
|
+
|
|
180
|
+
### Using Deployment Presets
|
|
181
|
+
|
|
182
|
+
Once configured, deployments are incredibly simple:
|
|
183
|
+
|
|
184
|
+
**In Amp, just say:**
|
|
185
|
+
```
|
|
186
|
+
"Deploy frontend"
|
|
187
|
+
"Run deploy-staging"
|
|
188
|
+
"Execute deploy-api"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Or use the tools directly:**
|
|
192
|
+
- `ftp_list_deployments` - See all available deployment presets
|
|
193
|
+
- `ftp_deploy` - Run a specific deployment by name
|
|
194
|
+
|
|
195
|
+
### Example Output
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
Deployment "deploy-frontend" complete:
|
|
199
|
+
Deploy frontend build to production
|
|
200
|
+
|
|
201
|
+
Profile: production
|
|
202
|
+
Local: ./dist
|
|
203
|
+
Remote: /public_html
|
|
204
|
+
|
|
205
|
+
Uploaded: 23
|
|
206
|
+
Skipped: 5
|
|
207
|
+
Ignored: 47
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Benefits of Deployment Presets
|
|
211
|
+
|
|
212
|
+
✅ **One-Command Deployment** - No need to specify paths, profiles, or exclusions every time
|
|
213
|
+
✅ **Consistent Deployments** - Same configuration used every time, no human error
|
|
214
|
+
✅ **Multiple Environments** - Easily switch between prod, staging, dev
|
|
215
|
+
✅ **Team Sharing** - Commit `.ftpconfig.example` to share deployment workflows
|
|
216
|
+
✅ **Additional Exclusions** - Exclude deployment-specific files (like source maps)
|
|
217
|
+
|
|
218
|
+
### Real-World Examples
|
|
219
|
+
|
|
220
|
+
**Frontend Build Deployment:**
|
|
221
|
+
```json
|
|
222
|
+
"deploy-production": {
|
|
223
|
+
"profile": "production",
|
|
224
|
+
"local": "./build",
|
|
225
|
+
"remote": "/public_html",
|
|
226
|
+
"description": "Deploy React production build",
|
|
227
|
+
"exclude": ["*.map", "*.md"]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**WordPress Theme:**
|
|
232
|
+
```json
|
|
233
|
+
"deploy-theme": {
|
|
234
|
+
"profile": "production",
|
|
235
|
+
"local": "./wp-content/themes/mytheme",
|
|
236
|
+
"remote": "/wp-content/themes/mytheme",
|
|
237
|
+
"description": "Deploy WordPress theme to production"
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**API Backend:**
|
|
242
|
+
```json
|
|
243
|
+
"deploy-api": {
|
|
244
|
+
"profile": "production",
|
|
245
|
+
"local": "./api/dist",
|
|
246
|
+
"remote": "/api/v1",
|
|
247
|
+
"description": "Deploy Node.js API to production",
|
|
248
|
+
"exclude": ["*.test.js", "docs/**"]
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Multi-Environment Setup:**
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"production": { "host": "ftp.mysite.com", "user": "prod", "password": "..." },
|
|
256
|
+
"staging": { "host": "ftp.staging.mysite.com", "user": "staging", "password": "..." },
|
|
257
|
+
"deployments": {
|
|
258
|
+
"deploy-prod": {
|
|
259
|
+
"profile": "production",
|
|
260
|
+
"local": "./dist",
|
|
261
|
+
"remote": "/public_html"
|
|
262
|
+
},
|
|
263
|
+
"deploy-staging": {
|
|
264
|
+
"profile": "staging",
|
|
265
|
+
"local": "./dist",
|
|
266
|
+
"remote": "/www"
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Complete Tool Reference
|
|
275
|
+
|
|
276
|
+
### Connection Management
|
|
277
|
+
|
|
278
|
+
#### `ftp_connect`
|
|
279
|
+
Switch between named FTP profiles from your `.ftpconfig` file or force environment variables.
|
|
280
|
+
|
|
281
|
+
**Parameters:**
|
|
282
|
+
- `profile` (optional): Name of profile from `.ftpconfig` (e.g., "production", "staging")
|
|
283
|
+
- `useEnv` (optional): Set to `true` to force use of environment variables
|
|
284
|
+
|
|
285
|
+
**Example use cases:**
|
|
286
|
+
- "Connect to my production FTP"
|
|
287
|
+
- "Switch to staging FTP server"
|
|
288
|
+
- "Use environment variables for FTP connection"
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
### File Content Operations
|
|
293
|
+
|
|
294
|
+
#### `ftp_get_contents`
|
|
295
|
+
Read file content directly from the server without downloading to disk. Perfect for viewing config files, reading logs, or checking file contents quickly.
|
|
296
|
+
|
|
297
|
+
**Parameters:**
|
|
298
|
+
- `path`: Remote file path to read
|
|
299
|
+
|
|
300
|
+
**Example use cases:**
|
|
301
|
+
- "Read the contents of config.php"
|
|
302
|
+
- "Show me what's in .htaccess"
|
|
303
|
+
- "Check the error log on the server"
|
|
304
|
+
- Viewing configuration files before editing
|
|
305
|
+
- Reading small text files for quick inspection
|
|
306
|
+
|
|
307
|
+
#### `ftp_put_contents`
|
|
308
|
+
Write content directly to a remote file without needing a local file. Great for creating new files or updating existing ones with generated content.
|
|
309
|
+
|
|
310
|
+
**Parameters:**
|
|
311
|
+
- `path`: Remote file path to write
|
|
312
|
+
- `content`: Content to write to the file
|
|
313
|
+
|
|
314
|
+
**Example use cases:**
|
|
315
|
+
- "Update config.php with new database credentials"
|
|
316
|
+
- "Create a new .htaccess file with these rules"
|
|
317
|
+
- "Write this JSON data to settings.json on the server"
|
|
318
|
+
- Updating configuration files programmatically
|
|
319
|
+
- Creating files from generated content
|
|
320
|
+
- Quick fixes to remote files
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### Metadata & File Information
|
|
325
|
+
|
|
326
|
+
#### `ftp_stat`
|
|
327
|
+
Get detailed metadata about a file including size, modification date, and permissions. Useful for checking file info before downloading or comparing versions.
|
|
328
|
+
|
|
329
|
+
**Parameters:**
|
|
330
|
+
- `path`: Remote file path
|
|
331
|
+
|
|
332
|
+
**Returns:**
|
|
333
|
+
- File size in bytes
|
|
334
|
+
- Last modified timestamp
|
|
335
|
+
- Whether it's a directory or file
|
|
336
|
+
- Permissions (SFTP only)
|
|
337
|
+
|
|
338
|
+
**Example use cases:**
|
|
339
|
+
- "Get file stats for index.html"
|
|
340
|
+
- "When was config.php last modified?"
|
|
341
|
+
- "How large is backup.sql?"
|
|
342
|
+
- Checking file modification dates
|
|
343
|
+
- Verifying file sizes before downloading
|
|
344
|
+
- Auditing file changes
|
|
345
|
+
|
|
346
|
+
#### `ftp_exists`
|
|
347
|
+
Check if a file or folder exists on the remote server before attempting operations. Prevents errors and allows conditional logic.
|
|
348
|
+
|
|
349
|
+
**Parameters:**
|
|
350
|
+
- `path`: Remote path to check
|
|
351
|
+
|
|
352
|
+
**Returns:** `true` or `false`
|
|
353
|
+
|
|
354
|
+
**Example use cases:**
|
|
355
|
+
- "Check if backup.sql exists before downloading"
|
|
356
|
+
- "Does the uploads directory exist?"
|
|
357
|
+
- "Verify config.php is on the server"
|
|
358
|
+
- Conditional file operations
|
|
359
|
+
- Validating paths before upload/download
|
|
360
|
+
- Checking if backups exist
|
|
361
|
+
|
|
362
|
+
#### `ftp_disk_space` *(SFTP only)*
|
|
363
|
+
Check available disk space on the remote server. Useful before uploading large files or monitoring server capacity.
|
|
364
|
+
|
|
365
|
+
**Parameters:**
|
|
366
|
+
- `path` (optional): Remote path to check (defaults to current directory)
|
|
367
|
+
|
|
368
|
+
**Returns:**
|
|
369
|
+
- Total disk space
|
|
370
|
+
- Free space
|
|
371
|
+
- Available space
|
|
372
|
+
- Used space
|
|
373
|
+
|
|
374
|
+
**Example use cases:**
|
|
375
|
+
- "Check available disk space on the server"
|
|
376
|
+
- "How much free space is left?"
|
|
377
|
+
- Before uploading large files or backups
|
|
378
|
+
- Server capacity monitoring
|
|
379
|
+
- Ensuring sufficient space for operations
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
### Directory Operations
|
|
384
|
+
|
|
385
|
+
#### `ftp_list`
|
|
386
|
+
List all files and directories in a specific path. Shows file sizes and types (file vs directory).
|
|
387
|
+
|
|
388
|
+
**Parameters:**
|
|
389
|
+
- `path` (optional): Remote directory path (defaults to current directory ".")
|
|
390
|
+
|
|
391
|
+
**Example use cases:**
|
|
392
|
+
- "List all files in /public_html"
|
|
393
|
+
- "Show me what's in the uploads folder"
|
|
394
|
+
- "What files are in the root directory?"
|
|
395
|
+
- Browsing directory contents
|
|
396
|
+
- Finding specific files
|
|
397
|
+
- Auditing uploaded files
|
|
398
|
+
|
|
399
|
+
#### `ftp_tree`
|
|
400
|
+
Get a complete recursive directory tree showing the entire folder structure at once. Visualizes nested directories and files with emoji icons.
|
|
401
|
+
|
|
402
|
+
**Parameters:**
|
|
403
|
+
- `path` (optional): Remote path to start from (defaults to ".")
|
|
404
|
+
- `maxDepth` (optional): Maximum recursion depth (defaults to 10)
|
|
405
|
+
|
|
406
|
+
**Example use cases:**
|
|
407
|
+
- "Show me the complete file tree of /public_html"
|
|
408
|
+
- "What's the directory structure of my website?"
|
|
409
|
+
- "Display all files and folders recursively"
|
|
410
|
+
- Understanding project structure
|
|
411
|
+
- Finding deeply nested files
|
|
412
|
+
- Complete site audits
|
|
413
|
+
|
|
414
|
+
#### `ftp_search`
|
|
415
|
+
Find files by name pattern using wildcards. Search recursively through directories to locate specific files.
|
|
416
|
+
|
|
417
|
+
**Parameters:**
|
|
418
|
+
- `pattern`: Search pattern (supports wildcards like `*.js`, `config.*`, `*backup*`)
|
|
419
|
+
- `path` (optional): Remote directory to search in (defaults to ".")
|
|
420
|
+
|
|
421
|
+
**Example use cases:**
|
|
422
|
+
- "Find all .js files on the server"
|
|
423
|
+
- "Search for files named config.* in uploads"
|
|
424
|
+
- "Locate all PHP files containing 'admin' in the name"
|
|
425
|
+
- Finding configuration files
|
|
426
|
+
- Locating log files
|
|
427
|
+
- Searching for specific file types
|
|
428
|
+
|
|
429
|
+
#### `ftp_mkdir`
|
|
430
|
+
Create a new directory on the remote server. Creates parent directories automatically if they don't exist.
|
|
431
|
+
|
|
432
|
+
**Parameters:**
|
|
433
|
+
- `path`: Remote directory path to create
|
|
434
|
+
|
|
435
|
+
**Example use cases:**
|
|
436
|
+
- "Create a new directory called backups"
|
|
437
|
+
- "Make a folder /uploads/2025"
|
|
438
|
+
- Creating organized folder structures
|
|
439
|
+
- Setting up new project directories
|
|
440
|
+
- Organizing uploads by date/category
|
|
441
|
+
|
|
442
|
+
#### `ftp_rmdir`
|
|
443
|
+
Remove a directory from the remote server. Can delete recursively including all contents.
|
|
444
|
+
|
|
445
|
+
**Parameters:**
|
|
446
|
+
- `path`: Remote directory path to remove
|
|
447
|
+
- `recursive` (optional): Remove directory and all contents recursively
|
|
448
|
+
|
|
449
|
+
**Example use cases:**
|
|
450
|
+
- "Delete the old-files directory"
|
|
451
|
+
- "Remove /temp recursively"
|
|
452
|
+
- Cleaning up old directories
|
|
453
|
+
- Removing test folders
|
|
454
|
+
- Deleting empty directories
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
### File Transfer
|
|
459
|
+
|
|
460
|
+
#### `ftp_upload`
|
|
461
|
+
Upload a single local file to the remote server.
|
|
462
|
+
|
|
463
|
+
**Parameters:**
|
|
464
|
+
- `localPath`: Local file path to upload
|
|
465
|
+
- `remotePath`: Remote destination path
|
|
466
|
+
|
|
467
|
+
**Example use cases:**
|
|
468
|
+
- "Upload index.html to /public_html/"
|
|
469
|
+
- "Send config.php to the server"
|
|
470
|
+
- Deploying updated files
|
|
471
|
+
- Uploading new assets
|
|
472
|
+
- Pushing configuration changes
|
|
473
|
+
|
|
474
|
+
#### `ftp_download`
|
|
475
|
+
Download a single file from the remote server to your local machine.
|
|
476
|
+
|
|
477
|
+
**Parameters:**
|
|
478
|
+
- `remotePath`: Remote file path to download
|
|
479
|
+
- `localPath`: Local destination path
|
|
480
|
+
|
|
481
|
+
**Example use cases:**
|
|
482
|
+
- "Download backup.sql from the server"
|
|
483
|
+
- "Get a copy of the config file"
|
|
484
|
+
- Retrieving backups
|
|
485
|
+
- Downloading logs for analysis
|
|
486
|
+
- Getting current configuration files
|
|
487
|
+
|
|
488
|
+
#### `ftp_batch_upload`
|
|
489
|
+
Upload multiple files at once in a single operation. Much faster than uploading files one by one.
|
|
490
|
+
|
|
491
|
+
**Parameters:**
|
|
492
|
+
- `files`: Array of objects with `localPath` and `remotePath`
|
|
493
|
+
|
|
494
|
+
**Example:**
|
|
495
|
+
```json
|
|
496
|
+
{
|
|
497
|
+
"files": [
|
|
498
|
+
{"localPath": "./dist/index.html", "remotePath": "/public_html/index.html"},
|
|
499
|
+
{"localPath": "./dist/styles.css", "remotePath": "/public_html/styles.css"},
|
|
500
|
+
{"localPath": "./dist/app.js", "remotePath": "/public_html/app.js"}
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
**Example use cases:**
|
|
506
|
+
- "Upload all files from my dist folder"
|
|
507
|
+
- "Batch upload these 10 images"
|
|
508
|
+
- Deploying multiple files at once
|
|
509
|
+
- Uploading build artifacts
|
|
510
|
+
- Mass file migrations
|
|
511
|
+
|
|
512
|
+
#### `ftp_batch_download`
|
|
513
|
+
Download multiple files at once in a single operation.
|
|
514
|
+
|
|
515
|
+
**Parameters:**
|
|
516
|
+
- `files`: Array of objects with `remotePath` and `localPath`
|
|
517
|
+
|
|
518
|
+
**Example use cases:**
|
|
519
|
+
- "Download all config files from the server"
|
|
520
|
+
- "Get all log files from /logs"
|
|
521
|
+
- Backing up multiple files
|
|
522
|
+
- Downloading project files
|
|
523
|
+
- Retrieving related files together
|
|
524
|
+
|
|
525
|
+
#### `ftp_sync`
|
|
526
|
+
Smart synchronization between local and remote directories. Only transfers files that have changed based on modification time. Incredibly efficient for deploying updates.
|
|
527
|
+
|
|
528
|
+
**Parameters:**
|
|
529
|
+
- `localPath`: Local directory path
|
|
530
|
+
- `remotePath`: Remote directory path
|
|
531
|
+
- `direction` (optional): "upload", "download", or "both" (defaults to "upload")
|
|
532
|
+
|
|
533
|
+
**Example use cases:**
|
|
534
|
+
- "Sync my local dist folder to /public_html"
|
|
535
|
+
- "Upload only changed files to the server"
|
|
536
|
+
- "Download updates from the server"
|
|
537
|
+
- Efficient deployments
|
|
538
|
+
- Incremental backups
|
|
539
|
+
- Two-way synchronization
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
### File Management
|
|
544
|
+
|
|
545
|
+
#### `ftp_delete`
|
|
546
|
+
Delete a file from the remote server.
|
|
547
|
+
|
|
548
|
+
**Parameters:**
|
|
549
|
+
- `path`: Remote file path to delete
|
|
550
|
+
|
|
551
|
+
**Example use cases:**
|
|
552
|
+
- "Delete old-backup.sql from the server"
|
|
553
|
+
- "Remove temp-file.txt"
|
|
554
|
+
- Cleaning up old files
|
|
555
|
+
- Removing temporary files
|
|
556
|
+
- Deleting outdated backups
|
|
557
|
+
|
|
558
|
+
#### `ftp_copy` *(SFTP only)*
|
|
559
|
+
Duplicate a file on the server without downloading/re-uploading. Creates backups or copies efficiently.
|
|
560
|
+
|
|
561
|
+
**Parameters:**
|
|
562
|
+
- `sourcePath`: Source file path
|
|
563
|
+
- `destPath`: Destination file path
|
|
564
|
+
|
|
565
|
+
**Example use cases:**
|
|
566
|
+
- "Copy config.php to config.backup.php"
|
|
567
|
+
- "Duplicate index.html to index.old.html"
|
|
568
|
+
- Creating backups before editing
|
|
569
|
+
- Duplicating templates
|
|
570
|
+
- Versioning files on server
|
|
571
|
+
|
|
572
|
+
#### `ftp_rename`
|
|
573
|
+
Rename or move a file on the remote server.
|
|
574
|
+
|
|
575
|
+
**Parameters:**
|
|
576
|
+
- `oldPath`: Current file path
|
|
577
|
+
- `newPath`: New file path
|
|
578
|
+
|
|
579
|
+
**Example use cases:**
|
|
580
|
+
- "Rename old.txt to new.txt"
|
|
581
|
+
- "Move file.php from /temp to /public_html"
|
|
582
|
+
- Organizing files
|
|
583
|
+
- Renaming for clarity
|
|
584
|
+
- Moving files between directories
|
|
585
|
+
|
|
586
|
+
#### `ftp_chmod` *(SFTP only)*
|
|
587
|
+
Change file permissions on the remote server using octal notation.
|
|
588
|
+
|
|
589
|
+
**Parameters:**
|
|
590
|
+
- `path`: Remote file path
|
|
591
|
+
- `mode`: Permission mode in octal (e.g., "755", "644", "777")
|
|
592
|
+
|
|
593
|
+
**Common modes:**
|
|
594
|
+
- `644` - Files: Owner read/write, others read only
|
|
595
|
+
- `755` - Directories/Scripts: Owner all, others read/execute
|
|
596
|
+
- `600` - Private files: Owner read/write only
|
|
597
|
+
- `777` - Full permissions (use with caution)
|
|
598
|
+
|
|
599
|
+
**Example use cases:**
|
|
600
|
+
- "Set permissions on script.sh to 755"
|
|
601
|
+
- "Make upload.php executable"
|
|
602
|
+
- "Change config.php to 600 for security"
|
|
603
|
+
- Securing configuration files
|
|
604
|
+
- Making scripts executable
|
|
605
|
+
- Fixing permission issues
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## Real-World Usage Scenarios
|
|
610
|
+
|
|
611
|
+
### Deploying a Website
|
|
612
|
+
```
|
|
613
|
+
"Sync my local dist folder to /public_html"
|
|
614
|
+
"Check if index.html exists on the server"
|
|
615
|
+
"Get file stats for all PHP files"
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
### Managing Configuration
|
|
619
|
+
```
|
|
620
|
+
"Read the contents of config.php"
|
|
621
|
+
"Copy config.php to config.backup.php"
|
|
622
|
+
"Update config.php with new database credentials"
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
### File Maintenance
|
|
626
|
+
```
|
|
627
|
+
"Find all .log files on the server"
|
|
628
|
+
"Delete all files matching temp-*"
|
|
629
|
+
"Create a backups directory"
|
|
630
|
+
"Set permissions on uploads folder to 755"
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
### Monitoring & Auditing
|
|
634
|
+
```
|
|
635
|
+
"Show me the complete file tree"
|
|
636
|
+
"Check disk space on the server"
|
|
637
|
+
"When was .htaccess last modified?"
|
|
638
|
+
"List all files in uploads larger than 1MB"
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
## Development
|
|
642
|
+
|
|
643
|
+
Clone and install locally:
|
|
644
|
+
|
|
645
|
+
```bash
|
|
646
|
+
git clone https://github.com/Kynlos/ftp-mcp.git
|
|
647
|
+
cd ftp-mcp
|
|
648
|
+
npm install
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
## Protocol Detection
|
|
652
|
+
|
|
653
|
+
ftp-mcp automatically detects the protocol based on your hostname:
|
|
654
|
+
- `ftp.example.com` → Uses FTP on port 21
|
|
655
|
+
- `sftp://example.com` → Uses SFTP on port 22
|
|
656
|
+
- Custom ports can be specified via `FTPMCP_PORT` or in `.ftpconfig`
|
|
657
|
+
|
|
658
|
+
## Git-Aware File Filtering
|
|
659
|
+
|
|
660
|
+
ftp-mcp automatically ignores files that shouldn't be deployed to production:
|
|
661
|
+
|
|
662
|
+
### Default Ignore Patterns
|
|
663
|
+
Always ignored by default:
|
|
664
|
+
- `node_modules/`
|
|
665
|
+
- `.git/`
|
|
666
|
+
- `.env` and `.env.*`
|
|
667
|
+
- `*.log` files
|
|
668
|
+
- `.DS_Store`, `Thumbs.db`
|
|
669
|
+
- IDE folders (`.vscode/`, `.idea/`)
|
|
670
|
+
- Temporary files (`*.swp`, `*~`)
|
|
671
|
+
- `.ftpconfig`
|
|
672
|
+
- Cache and coverage directories
|
|
673
|
+
|
|
674
|
+
### .gitignore Support
|
|
675
|
+
ftp-mcp automatically reads and respects your `.gitignore` file. Any patterns you've added to `.gitignore` will be honored during sync operations.
|
|
676
|
+
|
|
677
|
+
### .ftpignore Support
|
|
678
|
+
Create a `.ftpignore` file in your project root for FTP-specific ignore patterns:
|
|
679
|
+
|
|
680
|
+
```
|
|
681
|
+
# .ftpignore example
|
|
682
|
+
*.md
|
|
683
|
+
docs/**
|
|
684
|
+
tests/**
|
|
685
|
+
*.test.js
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
**Priority Order:**
|
|
689
|
+
1. Default patterns (always applied)
|
|
690
|
+
2. `.gitignore` patterns (if file exists)
|
|
691
|
+
3. `.ftpignore` patterns (if file exists)
|
|
692
|
+
|
|
693
|
+
**Example sync output:**
|
|
694
|
+
```
|
|
695
|
+
Sync complete:
|
|
696
|
+
Uploaded: 15
|
|
697
|
+
Downloaded: 0
|
|
698
|
+
Skipped: 3
|
|
699
|
+
Ignored: 47 ← Files filtered by ignore patterns
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
## Security Notes
|
|
703
|
+
|
|
704
|
+
- Never commit `.ftpconfig` files containing passwords to version control
|
|
705
|
+
- Use environment variables for CI/CD pipelines
|
|
706
|
+
- Consider using SSH keys with SFTP for enhanced security
|
|
707
|
+
- Set restrictive permissions (600/644) on sensitive files
|
|
708
|
+
- The `.ftpconfig` file is included in `.gitignore` by default
|
|
709
|
+
- Sensitive files like `.env` are automatically ignored during sync
|
|
710
|
+
|
|
711
|
+
## License
|
|
712
|
+
|
|
713
|
+
MIT
|
|
714
|
+
|
|
715
|
+
---
|
|
716
|
+
|
|
717
|
+
**Author:** [Kynlo Akari](https://github.com/Kynlos/)
|