这是一个用于自动初始化和管理VPS的模型上下文协议(MCP)服务器。该工具基于SSH自动化设置新的VPS实例,包括常见的服务和CI/CD流水线。
# 克隆仓库
git clone <repository-url>
cd mcp-vps-initialize
# 安装依赖
npm install
# 构建项目
npm run build
# 启动服务器
npm start
# 在开发模式下运行
npm run dev
# 检查代码
npm run lint
npm run lint:fix
# 格式化代码
npm run format
npm run format:check
通过SSH使用密码或私钥认证连接到VPS。
参数:
host(必需):VPS IP地址或主机名username(必需):SSH用户名port(可选):SSH端口(默认:22)password(可选):SSH密码privateKeyPath(可选):私钥文件路径passphrase(可选):私钥密码短语示例:
{
"host": "192.168.1.100",
"username": "root",
"password": "your-password"
}
初始化一个新的VPS,进行系统更新并安装可选服务。
参数:
services(可选):指定要安装的服务的对象
nodejs(布尔值):安装Node.js LTSpm2(布尔值):安装PM2进程管理器rust(布尔值):安装Rust工具链nginx(布尔值):安装和配置Nginxredis(布尔值):安装和配置Redis示例:
{
"services": {
"nodejs": true,
"pm2": true,
"nginx": true,
"redis": false
}
}
配置Nginx,包括域名、反向代理和SSL证书。
参数:
domain(必需):网站的域名port(必需):后端代理请求的端口ssl(可选):启用Certbot的SSL(默认:true)示例:
{
"domain": "example.com",
"port": 3000,
"ssl": true
}
设置GitHub CI/CD,包括部署密钥和自动化工作流。
参数:
repoUrl(必需):GitHub仓库URLdeployPath(必需):服务器上的部署路径示例:
{
"repoUrl": "https://github.com/username/repo.git",
"deployPath": "/opt/deployments/myapp"
}
在已连接的VPS上执行任意命令。
参数:
command(必需):要执行的命令示例:
{
"command": "systemctl status nginx"
}
连接到VPS:
{
"tool": "ssh_connect",
"args": {
"host": "your-vps-ip",
"username": "root",
"password": "your-password"
}
}
初始化VPS:
{
"tool": "vps_initialize",
"args": {
"services": {
"nodejs": true,
"pm2": true,
"nginx": true
}
}
}
配置Nginx:
{
"tool": "nginx_setup",
"args": {
"domain": "yourdomain.com",
"port": 3000,
"ssl": true
}
}
配置CI/CD:
{
"tool": "github_cicd_setup",
"args": {
"repoUrl": "https://github.com/username/repo.git",
"deployPath": "/opt/deployments/myapp"
}
}
运行github_cicd_setup工具后,您将收到:
.github/workflows/deploy.yml生成的工作流将:
日志写入:
logs/combined.log:所有日志级别logs/error.log:仅错误日志日志级别:error,warn,info,debug
服务器可以通过环境变量进行配置:
LOG_LEVEL:设置日志级别(默认:'info')PORT:服务器端口(如果独立运行)SSH连接失败
SSL证书问题
服务安装失败
启用调试日志:
LOG_LEVEL=debug npm start
MIT许可证 - 详情见LICENSE文件。