UNPKG

@genxis/whmrockstar

Version:

šŸŽø GenXis WHMRockStar - AI-powered multi-server WHM/cPanel management via Model Context Protocol (MCP). Enhanced with proper MCP stdio protocol support and multi-server management.

484 lines (362 loc) • 14.3 kB
# šŸŽø GenXis WHMRockStar v2.1 [![npm version](https://badge.fury.io/js/@genxis%2Fwhmrockstar.svg)](https://badge.fury.io/js/@genxis%2Fwhmrockstar) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Node.js Version](https://img.shields.io/badge/node-%3E%3D16.0.0-brightgreen)](https://nodejs.org/) **AI-powered multi-server WHM/cPanel management via Model Context Protocol (MCP)** Transform your dedicated LAMP server management with AI assistance. Now with SSH integration for full root access, automated key deployment, and complete system control. ## šŸš€ What's New in v2.1 ### v2.1.0 - SSH Integration & Root Access - šŸš€ **SSH Integration**: Full root-level SSH access via automated key deployment - šŸ” **Automated SSH Setup**: Uses WHM API to install SSH keys - no manual configuration - šŸ’» **System Management**: Execute any command, restart services, check system health - šŸ”§ **Direct File Access**: Edit system files including /etc/, /var/log/, Apache configs - šŸ“Š **System Monitoring**: Check disk space, memory usage, service status ### v2.0.0 - MCP Protocol & Multi-Server - āœ… **Proper MCP Protocol**: Full stdio-based MCP implementation for seamless integration - āœ… **Multi-Server Support**: Manage multiple WHM servers from a single interface - āœ… **Enhanced Server Context**: Clear server identification in all operations - āœ… **Improved Error Handling**: Better error messages and debugging - āœ… **Backward Compatibility**: Legacy configurations automatically migrated ## šŸš€ Quick Start ### One-Line Installation ```bash npx @genxis/whmrockstar setup ``` That's it! The setup wizard will guide you through configuration and automatically integrate with your IDE. ### Manual Installation ```bash npm install -g @genxis/whmrockstar genxis-whm setup ``` ## šŸ“‹ Prerequisites - **Dedicated Server(s)** with LAMP stack - **WHM/cPanel** with root access - **Node.js** 16.0.0 or higher - **WHM API Token(s)** (generated in WHM) ## āš ļø Security Notice - **NEVER commit API tokens to version control** - **Rotate API tokens regularly** for security - **Use environment variables or secure config files** for production - API tokens are stored locally in `~/.genxis-whmrockstar/servers.json` ## šŸ”§ Multi-Server Configuration ### Adding Your First Server ```bash genxis-whm setup ``` ### Adding Additional Servers ```bash genxis-whm add-server ``` ### Managing Servers ```bash # List all configured servers genxis-whm list-servers # Test all server connections genxis-whm test-all # Test specific server genxis-whm test server1 # Show server configuration genxis-whm config server1 # Remove a server genxis-whm remove-server server1 ``` ## šŸŽÆ Features - šŸ”‘ **Secure WHM API Integration** - Full WHM/cPanel management via API - 🌐 **Multi-Server Support** - Manage multiple WHM servers from one MCP instance - šŸ“ **File Management** - CRUD operations on server files via cPanel API - šŸ” **Secure Token Management** - Support for daily API token rotation - šŸ“Š **Account Management** - Create, list, suspend, unsuspend, and terminate accounts - šŸ“ˆ **Resource Monitoring** - Check disk usage, bandwidth, and account limits - šŸ› ļø **Configuration Checks** - Find and fix .htaccess and PHP configuration issues - ⚔ **DNS Management** - Add, modify, and remove DNS zones and records - šŸ“¦ **Package Management** - Create and manage hosting packages - šŸ”„ **Backup Operations** - Create and restore account backups - šŸŽÆ **Interactive CLI** - Easy setup and server management commands - šŸ“ **Audit Logging** - Track all operations for security and debugging - šŸš€ **SSH Integration** - Full root-level SSH access via automated key deployment - šŸ’» **System Management** - Restart services, check system health, execute commands - šŸ”§ **Direct File Access** - Edit system files including /etc/, /var/log/ via SSH ### Core WHM/cPanel Operations - **Account Management**: Create, list, suspend, unsuspend, terminate cPanel accounts - **Domain Management**: Add, remove, list domains and subdomains - **Server Monitoring**: Real-time server status, load, memory, and service monitoring - **Service Control**: Restart Apache, MySQL, Nginx, and other services - **Update Management**: Check for and install server updates ### AI Integration - **Natural Language Commands**: "List accounts on server1" or "Create account on production server" - **Intelligent Server Selection**: AI understands server context and suggests appropriate servers - **Enhanced Error Handling**: Clear error messages with server context - **Batch Operations**: Process multiple accounts across multiple servers ### IDE Integration - **VS Code**: Full integration via MCP protocol (Roo-Cline, Claude) - **Windsurf**: Native support with real-time updates - **Claude Desktop**: Direct AI assistance for server management - **JetBrains**: Plugin-ready architecture ## šŸ“– Usage Examples ### Basic Commands ```javascript // After setup, use natural language in your AI assistant: "List all servers" "List all cPanel accounts on server1" "Create a new account for johndoe.com on production server" "Check server load on all servers" "Restart Apache service on server2" "Suspend account 'spammer' on server1 for abuse" ``` ### Multi-Server Operations ```javascript // Server-specific operations "Show me all accounts on my production server" "What's the status of my development server?" "Create a test account on staging server" // Cross-server operations "Compare account counts across all servers" "Show server load for all configured servers" ``` ### Programmatic Usage ```javascript const WHMRockStarMCPServer = require('@genxis/whmrockstar'); // The MCP server automatically handles multi-server configurations const server = new WHMRockStarMCPServer(); await server.start(); // All operations include server context in responses ``` ## šŸ› ļø Available Tools ### Server Management - `whm_list_servers` - List all configured WHM servers ### SSH Operations (v2.1+) - `ssh_setup` - Install SSH keys via WHM API (one-time setup) - `ssh_command` - Execute any shell command as root - `ssh_file_read` - Read any system file - `ssh_file_write` - Write to any system file - `ssh_service` - Manage systemd services (restart/stop/start/status) - `ssh_system_check` - Check disk, memory, Apache config, error logs ### Account Management - `whm_list_accounts` - List all WHM accounts (with server context) - `whm_create_account` - Create new cPanel account - `whm_account_summary` - Get detailed account information - `whm_suspend_account` - Suspend account with reason - `whm_unsuspend_account` - Reactivate suspended account - `whm_terminate_account` - Permanently remove account (with confirmation) ### Server Monitoring - `whm_server_status` - Get server status and statistics - `whm_server_load` - Monitor server load averages - `whm_service_status` - Check status of all services - `whm_restart_service` - Restart specific services ### Domain Management - `whm_list_domains` - List domains for account All tools support optional `serverId` parameter. If only one server is configured, it's used automatically. ## šŸ”’ Security ### Best Practices - **API Token Security**: Tokens are stored locally and never transmitted to third parties - **HTTPS Only**: All WHM communications use HTTPS - **Local Processing**: All operations run locally on your machine - **No Data Collection**: GenXis doesn't collect or store your server data - **Server Isolation**: Each server configuration is isolated and secure ### Multi-Server Token Management ```bash # Test connections for all servers genxis-whm test-all # View server configurations (tokens are masked) genxis-whm config # Update specific server genxis-whm remove-server old-server genxis-whm add-server # Add updated configuration ``` ## šŸ“ File Structure ``` ~/.genxis-whmrockstar/ ā”œā”€ā”€ servers.json # Multi-server configuration (v2.0) ā”œā”€ā”€ config.json # Legacy single server config (auto-migrated) └── logs/ # Operation logs └── whm-operations.log ``` ### Multi-Server Configuration Format ```json { "version": "2.0", "servers": { "production": { "name": "Production Server", "server": "192.168.1.100", "apiToken": "your-token", "port": "2087", "username": "root", "enabled": true }, "staging": { "name": "Staging Server", "server": "192.168.1.101", "apiToken": "your-token", "port": "2087", "username": "root", "enabled": true } } } ``` ## šŸ”§ Advanced Configuration ### MCP Settings (Auto-Generated) ```json { "mcpServers": { "genxis-whm": { "command": "node", "args": ["path/to/mcp-server.js"], "disabled": false, "alwaysAllow": [], "disabledTools": [] } } } ``` ### Environment Variables (Legacy Support) ```bash # Single server via environment (auto-migrated to multi-server config) export WHM_SERVER="your-server-ip" export WHM_API_TOKEN="your-api-token" export WHM_PORT="2087" export WHM_SERVER_ID="env-server" export WHM_SERVER_NAME="Environment Server" ``` ## 🚨 Troubleshooting ### Common Issues **No Servers Configured** ```bash # Add your first server genxis-whm setup # Or add additional servers genxis-whm add-server ``` **Connection Failed** ```bash # Test specific server genxis-whm test server1 # Test all servers genxis-whm test-all # Check server configuration genxis-whm config server1 ``` **MCP Not Working in IDE** ```bash # Regenerate MCP configuration genxis-whm setup --force # Check MCP server status genxis-whm start ``` **Server Context Issues** ```bash # List available servers genxis-whm list-servers # Ensure server IDs are unique and descriptive genxis-whm config ``` ### Debug Mode ```bash # Enable verbose logging export LOG_LEVEL=debug genxis-whm start # View logs genxis-whm logs # Test with detailed output genxis-whm test-all ``` ## šŸ†™ Migration from v1.0 v2.0 automatically migrates v1.0 configurations: 1. **Legacy config.json** → Migrated to multi-server format 2. **Environment variables** → Added as server configuration 3. **MCP settings** → Updated to use new stdio protocol No manual migration required! ## šŸ“š API Reference ### Tool Parameters All tools support these common parameters: | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `serverId` | string | No* | Server ID (auto-selected if only one server) | *Required only when multiple servers are configured ### Server Context in Responses All tool responses include server context: ```json { "server": { "id": "production", "name": "Production Server", "address": "192.168.1.100" }, "operation": "list_accounts", "result": "<omitted for brevity>", "timestamp": "2025-01-01T00:00:00.000Z" } ``` ## šŸ¤ Contributing We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details. ### Development Setup ```bash git clone https://github.com/genxis/genxis-whmrockstar.git cd genxis-whmrockstar npm install # Test the MCP server npm run start # Test CLI commands npm run setup ``` ## šŸ“„ License MIT License - see [LICENSE](LICENSE) file for details. ## šŸ†˜ Support - **Documentation**: [https://docs.genxis.com/whmrockstar](https://docs.genxis.com/whmrockstar) - **Issues**: [GitHub Issues](https://github.com/genxis/genxis-whmrockstar/issues) - **Email**: support@genxis.com - **Community**: [Discord](https://discord.gg/genxis) ## šŸ·ļø Version History ### v2.0.0 (Current) - āœ… **BREAKING**: Proper MCP stdio protocol implementation - āœ… **NEW**: Multi-server support with server context - āœ… **NEW**: Enhanced CLI with server management commands - āœ… **NEW**: Automatic migration from v1.0 configurations - āœ… **NEW**: Improved error handling and debugging - āœ… **NEW**: Server-aware tool responses - āœ… **IMPROVED**: Better IDE integration compatibility ### v1.0.0 (Legacy) - āœ… Initial release - āœ… Basic WHM/cPanel integration - āœ… HTTP/SSE-based MCP protocol - āœ… Single server support - āœ… Basic IDE integration --- **Made with ā¤ļø by [GenXis](https://genxis.com)** *Transform your multi-server management with AI-powered automation* ## šŸ”’ Security and Reliability (v2.1 updates) From this release: - TLS verification is ON by default. If you use a self-signed certificate during migration/testing, you can explicitly opt out per server by setting `verifyTLS: false` in `%USERPROFILE%\.genxis-whmrockstar\servers.json`. Prefer installing a valid cert or providing a custom CA instead of disabling verification. - Optional custom CA: Provide a path to a CA PEM via `caPath` in the server config to keep verification enabled while trusting your own CA. - Built-in retries: Transient network errors and 5xx/429 responses are retried with exponential backoff (defaults: 3 retries, starting at ~300ms). You can tune with `retries` and `retryDelayMs` per server. - Audit logging: MCP tool calls write a redacted JSONL entry to `%USERPROFILE%\.genxis-whmrockstar\audit.log` including tool name, serverId, outcome, and a digest of params (no raw secrets). ### Example servers.json ```json { "servers": { "prod-1": { "server": "your-whm-server.com", "port": "2087", "username": "root", "apiToken": "<ROOT_SCOPED_WHM_API_TOKEN>", "name": "WHM Prod 1", "timeout": 45000, "verifyTLS": true, "caPath": "C:\\Users\\Administrator\\Desktop\\certs\\my-ca.pem", "retries": 3, "retryDelayMs": 300 } } } ``` Notes: - Keep `servers.json` permission-restricted to your Windows user (NTFS ACLs). - Rotate tokens periodically. Avoid committing tokens to version control. - If you must disable TLS verification (not recommended), set `verifyTLS: false` only temporarily. ### Audited tools - whm_list_servers - whm_list_accounts - whm_restart_service - whm_call_api (covers full-access operations) You can open `%USERPROFILE%\.genxis-whmrockstar\audit.log` to review actions by timestamp.