| name | file-transfer |
|---|---|
| description | 启动临时 Web 服务器,在远程服务器和本地 PC 之间传输文件。触发词:传文件、发文件、上传、下载、共享文件、file transfer、send file。 |
启动一个临时 Web 服务器,让用户通过浏览器在远程服务器和本地 PC 之间上传/下载文件。
- 判断模式: 用户需要上传、下载还是双向?
- 启动服务: 运行 Python 脚本
- 给出链接: 将 URL 发送给用户,在浏览器中打开
| Mode | Flag | Description |
|---|---|---|
| Upload only | --mode upload-only |
仅允许从 PC 上传到服务器 |
| Download only | --mode download-only |
仅允许从服务器下载到 PC |
| Both | --mode both (default) |
双向传输 |
python3 .claude/skills/file-transfer/scripts/file_transfer_server.py \
--path /target/directory \
--mode both \
--port 32800 \
--password 1234 \
--timeout 1800Parameters:
| Param | Default | Description |
|---|---|---|
--path |
(required) | 共享目录路径 |
--mode |
both |
upload-only / download-only / both |
--port |
random 32768-33768 | 监听端口 |
--bind |
0.0.0.0 |
绑定地址 |
--password |
none | 4 位数字密码 |
--timeout |
1800 |
自动关闭秒数(0 = 不超时) |
启动后输出 JSON:
{
"status": "running",
"url": "http://x.x.x.x:32800/aB3xK9mP_qR7wZ2y",
"token": "aB3xK9mP_qR7wZ2y",
"pid": 12345,
"mode": "both",
"path": "/target/directory",
"timeout_seconds": 1800
}kill <pid>服务收到信号后会等待进行中的传输完成再关闭。
- URL Token: 22 字符随机 token,保证链接不可猜测
- 可选密码: 4 位数字 PIN,每 IP 限 5 次错误尝试
- 路径遍历防护: 所有文件访问受限于
--path目录 - 危险目录拦截:
/,/root,/home,/etc等系统目录禁止共享 - 自动超时: 默认 30 分钟后自动关闭
- 优雅关闭: 超时后允许进行中的传输完成
User: 帮我把文件传到服务器上
Agent steps:
1. Ask user for target directory (or use current working dir)
2. Run the server script in background:
python3 .claude/skills/file-transfer/scripts/file_transfer_server.py --path /path/to/dir --mode upload-only
3. Parse JSON output, provide URL to user
4. User opens URL in browser and uploads files
5. When done, kill the process by PID