mcp-cpanel-api
v1.0.2
Published
MCP server for cPanel UAPI — manage email, domains, databases, files, Git, SSL, DNS, security via Claude
Maintainers
Readme
MCP-CPANEL-API
A TypeScript Model Context Protocol (MCP) server for the cPanel UAPI. Lets Claude (and any MCP client) manage cPanel hosting accounts directly — email, domains, databases, files, Git, SSL, DNS, security, and more.
Features
152 tools across 8 modules:
| Module | Tools | |--------|-------| | Email | Accounts, passwords, quotas, forwarders, catch-all, autoresponders, mailing lists, SpamAssassin, filters, greylisting | | File Manager | List, read, write, delete, rename, copy, move, mkdir, chmod, compress, extract, empty trash, search | | Git | Create/clone/delete repos, deploy, deployment logs, SSH known hosts | | Domains | Main/addon/parked/subdomains, redirects, directory indexes, password-protected directories | | Database | MySQL + PostgreSQL — databases, users, privileges, remote hosts, repair | | Security | IP blocker, hotlink protection, ModSecurity, SSH key management, two-factor auth | | DNS | Zone records — list, add, edit, delete, reset | | Server | FTP, SSL + AutoSSL, Cron, Backup/restore, Stats, Bandwidth, PHP versions/ini, MIME types, Logs, WordPress (WP Toolkit), API tokens |
Requirements
- Node.js 18+
- cPanel account with API token access
- cPanel & WHM version 82+
Installation
From npm
npm install -g mcp-cpanel-apiFrom source
git clone https://github.com/imtaqin/MCP-CPANEL-API.git
cd MCP-CPANEL-API
npm install
npm run buildConfiguration
Set environment variables:
| Variable | Required | Description |
|----------|----------|-------------|
| CPANEL_HOST | ✅ | cPanel server hostname or IP |
| CPANEL_USER | ✅ | cPanel username |
| CPANEL_TOKEN | ✅ | cPanel API token |
| CPANEL_PORT | ❌ | Port (default: 2083) |
Create a cPanel API token
In cPanel: Security → Manage API Tokens → Create
Or via API:
curl -H 'Authorization: cpanel USER:EXISTING_TOKEN' \
'https://your-server.com:2083/execute/Tokens/create_full_access?name=mcp-token'Claude Desktop Setup
Add to ~/Library/Application\ Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"cpanel": {
"command": "npx",
"args": ["-y", "mcp-cpanel-api"],
"env": {
"CPANEL_HOST": "your-server.com",
"CPANEL_USER": "your-username",
"CPANEL_TOKEN": "YOUR_API_TOKEN_HERE",
"CPANEL_PORT": "2083"
}
}
}
}If installed globally or from source:
{
"mcpServers": {
"cpanel": {
"command": "mcp-cpanel-api",
"env": {
"CPANEL_HOST": "your-server.com",
"CPANEL_USER": "your-username",
"CPANEL_TOKEN": "YOUR_API_TOKEN_HERE"
}
}
}
}VS Code / Cursor / Windsurf
Add to your MCP settings:
{
"mcp": {
"servers": {
"cpanel": {
"command": "npx",
"args": ["-y", "mcp-cpanel-api"],
"env": {
"CPANEL_HOST": "your-server.com",
"CPANEL_USER": "your-username",
"CPANEL_TOKEN": "YOUR_API_TOKEN_HERE"
}
}
}
}
}Example Usage
Once connected, ask Claude:
- "List all email accounts on example.com"
- "Create a MySQL database called myapp and a user with full privileges"
- "Clone the repo https://github.com/me/myapp.git to /home/user/myapp"
- "Show disk usage for the account"
- "Add a DNS TXT record for SPF on example.com"
- "Block the IP 192.168.1.100"
- "Create a cron job to run /home/user/backup.sh every day at 2am"
- "Show the last 100 lines of the Apache error log"
- "Install the SSL certificate from Let's Encrypt for mysite.com"
Tool Reference
| Tool | Description |
|------|-------------|
| email_list_accounts | List email accounts for a domain |
| email_add_account | Create email account |
| email_delete_account | Delete email account |
| email_change_password | Change email password |
| email_set_quota | Set mailbox quota |
| email_get_disk_usage | Get mailbox disk usage |
| email_list_forwarders | List forwarders |
| email_add_forwarder | Create forwarder |
| email_delete_forwarder | Delete forwarder |
| email_get_default_address | Get catch-all address |
| email_set_default_address | Set catch-all address |
| email_list_autoresponders | List autoresponders |
| email_add_autoresponder | Create autoresponder |
| email_delete_autoresponder | Delete autoresponder |
| email_list_mailing_lists | List mailing lists |
| email_add_mailing_list | Create mailing list |
| email_delete_mailing_list | Delete mailing list |
| email_spam_status | Get SpamAssassin status |
| email_spam_enable | Enable SpamAssassin |
| email_spam_disable | Disable SpamAssassin |
| email_spam_enable_autodelete | Enable spam auto-delete |
| email_spam_disable_autodelete | Disable spam auto-delete |
| email_list_filters | List email filters |
| email_greylisting_status | Get greylisting config |
File Manager
| Tool | Description |
|------|-------------|
| files_list_directory | List directory contents |
| files_get_info | Get file/directory metadata |
| files_read | Read file content |
| files_write | Write/create file |
| files_delete | Delete files or directories |
| files_rename | Rename file or directory |
| files_copy | Copy files |
| files_move | Move files |
| files_mkdir | Create directory |
| files_chmod | Change permissions |
| files_compress | Compress to archive |
| files_extract | Extract archive |
| files_empty_trash | Empty trash |
| files_get_disk_usage | Account disk usage |
| files_search | Search files by name |
Git
| Tool | Description |
|------|-------------|
| git_list_repos | List all repositories |
| git_get_repo | Get repository details |
| git_create_repo | Create local repository |
| git_clone_repo | Clone remote repository |
| git_delete_repo | Delete repository |
| git_update_repo | Update repository settings |
| git_deploy | Trigger deployment |
| git_get_deployment_log | Get deployment history |
| git_list_known_hosts | List SSH known hosts |
| git_fetch_known_host_key | Fetch SSH host key |
Domains
| Tool | Description |
|------|-------------|
| domains_list | List all domains |
| domains_get_info | Get domain info |
| addon_domains_list | List addon domains |
| addon_domains_add | Add addon domain |
| addon_domains_delete | Delete addon domain |
| parked_domains_list | List parked domains |
| parked_domains_add | Park domain |
| parked_domains_delete | Unpark domain |
| subdomains_list | List subdomains |
| subdomains_add | Create subdomain |
| subdomains_delete | Delete subdomain |
| redirects_list | List redirects |
| redirects_add | Add redirect |
| redirects_delete | Delete redirect |
| directory_index_get | Get directory index setting |
| directory_index_set | Set directory index |
| directory_privacy_list | List protected directories |
| directory_privacy_enable | Enable directory protection |
| directory_privacy_disable | Disable directory protection |
| directory_privacy_add_user | Add protected dir user |
| directory_privacy_delete_user | Remove protected dir user |
Database
| Tool | Description |
|------|-------------|
| mysql_list_databases | List MySQL databases |
| mysql_create_database | Create MySQL database |
| mysql_delete_database | Delete MySQL database |
| mysql_list_users | List MySQL users |
| mysql_create_user | Create MySQL user |
| mysql_delete_user | Delete MySQL user |
| mysql_change_password | Change MySQL user password |
| mysql_set_privileges | Grant privileges |
| mysql_revoke_privileges | Revoke privileges |
| mysql_list_privileges | List user privileges |
| mysql_get_server_info | Get MySQL server info |
| mysql_check_database | Check database |
| mysql_repair_database | Repair database |
| mysql_list_remote_hosts | List remote MySQL hosts |
| mysql_add_remote_host | Add remote MySQL host |
| mysql_delete_remote_host | Delete remote MySQL host |
| postgres_list_databases | List PostgreSQL databases |
| postgres_create_database | Create PostgreSQL database |
| postgres_delete_database | Delete PostgreSQL database |
| postgres_list_users | List PostgreSQL users |
| postgres_create_user | Create PostgreSQL user |
| postgres_delete_user | Delete PostgreSQL user |
| postgres_set_privileges | Grant PostgreSQL privileges |
Security
| Tool | Description |
|------|-------------|
| security_list_blocked_ips | List blocked IPs |
| security_block_ip | Block IP or range |
| security_unblock_ip | Unblock IP |
| security_hotlink_status | Get hotlink protection status |
| security_hotlink_enable | Enable hotlink protection |
| security_hotlink_disable | Disable hotlink protection |
| security_modsec_list_rules | List ModSecurity rules |
| security_modsec_status | Get ModSecurity status |
| security_ssh_list_keys | List SSH keys |
| security_ssh_generate_key | Generate SSH key pair |
| security_ssh_import_key | Import SSH public key |
| security_ssh_delete_key | Delete SSH key |
| security_ssh_authorize_key | Authorize SSH key |
| security_ssh_deauthorize_key | Deauthorize SSH key |
| security_2fa_status | Get 2FA status |
| security_2fa_generate_secret | Generate 2FA TOTP secret |
| security_2fa_disable | Disable 2FA |
DNS / FTP / SSL / Cron / Backup / Stats / PHP / Logs
See server.ts for: ftp_*, dns_*, ssl_*, cron_*, backup_*, account_*, php_*, mime_*, logs_*, wordpress_*, tokens_*.
Architecture
src/
├── index.ts # MCP server entry point
├── cpanel-client.ts # cPanel UAPI HTTP client
├── utils.ts # Shared helpers
└── tools/
├── email.ts # Email tools (25)
├── filemanager.ts # File manager tools (15)
├── git.ts # Git/VersionControl tools (10)
├── domains.ts # Domain tools (21)
├── database.ts # MySQL + PostgreSQL tools (23)
├── security.ts # Security tools (17)
└── server.ts # FTP/DNS/SSL/Cron/etc. (41)Auth: Every request uses Authorization: cpanel username:TOKEN header over HTTPS.
Base URL: https://{CPANEL_HOST}:{CPANEL_PORT}/execute/{Module}/{function}
Development
npm run dev # Run with tsx (no build needed)
npm run build # Compile to dist/
npm start # Run compiled dist/Publishing to npm
npm run build
npm publishLicense
MIT
