usage.md•3.68 kB
# Usage Examples
## Using the MCP Server
### 1. Start the MCP Server
```bash
npm start
```
### 2. Connect via MCP Client
Example tool calls from an MCP client:
#### Connect to VPS
```json
{
"name": "ssh_connect",
"arguments": {
"host": "192.168.1.100",
"username": "root",
"password": "your-secure-password"
}
}
```
Or with private key:
```json
{
"name": "ssh_connect",
"arguments": {
"host": "192.168.1.100",
"username": "root",
"privateKeyPath": "/path/to/your/private/key",
"passphrase": "optional-passphrase"
}
}
```
#### Initialize VPS with Services
```json
{
"name": "vps_initialize",
"arguments": {
"services": {
"nodejs": true,
"pm2": true,
"nginx": true,
"redis": false,
"rust": false
}
}
}
```
#### Setup Nginx with Domain and SSL
```json
{
"name": "nginx_setup",
"arguments": {
"domain": "example.com",
"port": 3000,
"ssl": true
}
}
```
#### Setup GitHub CI/CD
```json
{
"name": "github_cicd_setup",
"arguments": {
"repoUrl": "https://github.com/username/my-app.git",
"deployPath": "/opt/deployments/my-app"
}
}
```
#### Execute Custom Commands
```json
{
"name": "execute_command",
"arguments": {
"command": "systemctl status nginx"
}
}
```
## Using the CLI
### Interactive Setup Wizard
```bash
npm run cli interactive
```
### Test SSH Connection
```bash
npm run cli connect --host 192.168.1.100 --username root --password your-password
```
### Build and Install CLI Globally
```bash
npm run build
npm install -g .
mcp-vps-init interactive
```
## Full Setup Workflow
Here's a complete example of setting up a VPS:
1. **Connect to VPS**
2. **Initialize with Node.js, PM2, and Nginx**
3. **Configure Nginx for your domain**
4. **Setup GitHub CI/CD**
```json
[
{
"name": "ssh_connect",
"arguments": {
"host": "your-vps-ip",
"username": "root",
"password": "your-password"
}
},
{
"name": "vps_initialize",
"arguments": {
"services": {
"nodejs": true,
"pm2": true,
"nginx": true,
"redis": false,
"rust": false
}
}
},
{
"name": "nginx_setup",
"arguments": {
"domain": "yourdomain.com",
"port": 3000,
"ssl": true
}
},
{
"name": "github_cicd_setup",
"arguments": {
"repoUrl": "https://github.com/yourusername/your-app.git",
"deployPath": "/opt/deployments/your-app"
}
}
]
```
## Post-Setup Instructions
After running the GitHub CI/CD setup, you'll receive instructions like:
1. **Add the deploy key to GitHub**
2. **Add secrets to GitHub Actions**
3. **Create the workflow file**
4. **Push your code to trigger deployment**
The server will provide specific instructions with the actual keys and secrets to use.
## Environment Variables
You can configure the server with these environment variables:
```bash
export LOG_LEVEL=debug # Set log level (error, warn, info, debug)
npm start
```
## Troubleshooting
### Common Issues
1. **SSH Connection Failed**
- Check VPS IP and credentials
- Ensure SSH service is running on the VPS
- Verify firewall settings
2. **SSL Certificate Issues**
- Ensure domain DNS points to VPS IP
- Check that ports 80 and 443 are open
- Verify email address is valid
3. **Service Installation Failed**
- Check internet connectivity on VPS
- Ensure VPS has enough disk space
- Review error logs for specific issues
### Debug Mode
For detailed logging:
```bash
LOG_LEVEL=debug npm start
```
### Logs
Check the log files:
- `logs/combined.log` - All logs
- `logs/error.log` - Error logs only