用于FTP/SSH的MCP服务器
此MCP服务器允许直接从Cursor AI连接并管理远程服务器上的文件,简化WordPress托管和其他远程服务器的管理。
功能
- 连接到FTP、SFTP和SSH服务器
- 列出远程文件和目录
- 上传和下载文件
- 创建、删除和重命名文件及目录
- 读取和写入文件内容
- 支持多条同时连接
安装
- 确保已安装Node.js(v14+)
- 克隆此仓库或复制MCP文件夹
- 安装依赖项:
cd MCP
npm install
在Cursor中的使用
Cursor的配置
.cursor/mcp.json
文件已包含并配置完成,Cursor应自动识别该MCP服务器。
启动服务器
有两种方式可以启动MCP服务器:
- stdio模式(推荐用于与Cursor一起使用):
npm start
- HTTP模式(适用于开发或其他工具):
npm run start:http
在Cursor中的示例使用
以下是MCP服务器在Cursor中使用的示例:
// 连接到FTP服务器
connect(type="ftp", host="meu-servidor.com", port=21, username="usuario", password="senha")
// 连接到SFTP/SSH服务器
connect(type="sftp", host="meu-servidor.com", port=22, username="usuario", password="senha")
// 列出远程目录中的文件
list_directory(connectionId="conn_id_retornado", path="/caminho/remoto")
// 上传文件到服务器
upload_file(connectionId="conn_id_retornado", localPath="/caminho/local/arquivo.txt", remotePath="/caminho/remoto/arquivo.txt")
// 下载远程文件
download_file(connectionId="conn_id_retornado", remotePath="/caminho/remoto/arquivo.txt", localPath="/caminho/local/arquivo.txt")
// 读取文件内容
read_file(connectionId="conn_id_retornado", path="/caminho/remoto/arquivo.txt")
// 写入文件内容
write_file(connectionId="conn_id_retornado", path="/caminho/remoto/arquivo.txt", content="Novo conteúdo do arquivo")
// 完成后断开连接
disconnect(connectionId="conn_id_retornado")
可用工具
工具 |
描述 |
connect |
连接到FTP、SFTP或SSH服务器 |
list_directory |
列出远程指定路径中的文件和目录 |
download_file |
从远程服务器下载文件 |
upload_file |
将文件上传到远程服务器 |
delete_file |
删除远程服务器上的文件 |
create_directory |
创建远程服务器上的新目录 |
remove_directory |
删除远程服务器上的目录 |
rename |
在远程服务器上重命名文件或目录 |
read_file |
读取远程服务器上文件的内容 |
write_file |
向远程服务器上的文件写入内容 |
disconnect |
关闭与远程服务器的连接 |
安全性
- 密码和私钥仅用于身份验证,不会被永久存储
- 所有连接均在会话期间管理,并在完成后关闭
- 建议优先使用私钥进行身份验证而非密码
故障排除
- 如果无法连接,请检查网络设置和远程服务器状态
- 确保使用的协议(ftp、sftp、ssh)与远程服务器配置一致
- 验证提供的凭据是否正确
许可证
本项目遵循MIT许可证,具体内容如下:
MIT License
版权所有 (c) [年份] [持有者姓名]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.