cpanel-mcp

cpanel-mcp

A comprehensive MCP server for managing cPanel web hosting accounts via UAPI, enabling file, database, email, domain, cron, backup, and system monitoring operations.

Category
访问服务器

README

cPanel MCP Server

MIT License TypeScript Node.js

A comprehensive Model Context Protocol (MCP) server for managing cPanel web hosting accounts. This server provides tools to interact with cPanel's UAPI (Unified API) for common hosting management tasks, enabling seamless integration with AI assistants and automation workflows.

🚀 Features

  • File Management: Browse, list, and manage files through cPanel's File Manager
  • Database Operations: Create, delete, and list MySQL databases
  • Email Management: Manage email accounts with full CRUD operations
  • Domain Information: Retrieve domain and subdomain details
  • Cron Job Management: Schedule and manage automated tasks
  • System Monitoring: Monitor disk usage and account statistics
  • Backup Operations: Create and manage account backups
  • Secure Authentication: Support for both API tokens and password authentication

📋 Prerequisites

  • Node.js 18.0.0 or higher
  • A cPanel hosting account with API access
  • Either a cPanel password or API token for authentication

🛠️ Installation

Option 1: Clone and Build

git clone https://github.com/ringo380/cpanel-mcp.git
cd cpanel-mcp
npm install
npm run build

Option 2: Direct Installation

npm install -g cpanel-mcp

⚙️ Configuration

Environment Setup

  1. Copy the example environment file:
cp .env.example .env
  1. Configure your cPanel credentials in .env:
# Required: cPanel server details
CPANEL_HOSTNAME=your-cpanel-hostname.com
CPANEL_USERNAME=your-cpanel-username

# Authentication (choose one method)
CPANEL_API_TOKEN=your-api-token-here
# OR
CPANEL_PASSWORD=your-cpanel-password

# Optional: Connection settings
CPANEL_PORT=2083
CPANEL_SSL=true

Generating a cPanel API Token (Recommended)

  1. Log into your cPanel account
  2. Navigate to Security → Manage API Tokens
  3. Click Create Token
  4. Give it a descriptive name and set permissions
  5. Copy the generated token to your .env file

🚀 Usage

Starting the Server

npm start

The server will start and listen for MCP connections via stdio.

Integration with Claude Desktop

Add the server to your Claude Desktop configuration:

{
  "mcpServers": {
    "cpanel": {
      "command": "node",
      "args": ["/path/to/cpanel-mcp/dist/index.js"],
      "env": {
        "CPANEL_HOSTNAME": "your-hostname.com",
        "CPANEL_USERNAME": "your-username",
        "CPANEL_API_TOKEN": "your-token"
      }
    }
  }
}

🛠️ Available Tools

File Management

  • list_files - List files and directories in specified path
    {
      "name": "list_files",
      "arguments": {
        "path": "/public_html"
      }
    }
    

Database Management

  • list_databases - List all MySQL databases
  • create_database - Create a new MySQL database
  • delete_database - Delete an existing database

Email Management

  • list_email_accounts - List all email accounts (optionally filter by domain)
  • create_email_account - Create a new email account
  • delete_email_account - Delete an email account

Domain Operations

  • list_domains - List all domains and subdomains

Cron Job Management

  • list_cron_jobs - List all scheduled cron jobs
  • add_cron_job - Schedule a new cron job
  • delete_cron_job - Remove a cron job

System Information

  • get_disk_usage - Get detailed disk usage statistics

Backup Operations

  • create_backup - Create a full account backup
  • list_backups - List available backups

💡 Examples

Creating a Database and Email Account

// Create a new database
await callTool("create_database", {
  name: "myapp_db"
});

// Create an email account with 500MB quota
await callTool("create_email_account", {
  email: "support@mydomain.com",
  password: "secure_password_123",
  quota: 500
});

Managing Cron Jobs

// Add a daily backup cron job
await callTool("add_cron_job", {
  minute: "0",
  hour: "2",
  day: "*",
  month: "*",
  weekday: "*",
  command: "/usr/local/bin/backup_script.sh"
});

🔒 Security Considerations

  • Use API Tokens: Prefer API tokens over passwords for better security
  • Environment Variables: Never commit credentials to version control
  • Limited Scope: The server only exposes safe, account-level operations
  • HTTPS: Always use SSL/TLS connections to cPanel (enabled by default)

🧪 Development

Setup Development Environment

git clone https://github.com/ringo380/cpanel-mcp.git
cd cpanel-mcp
npm install
cp .env.example .env
# Edit .env with your test cPanel credentials

Development Commands

npm run dev        # Start in watch mode
npm run build      # Build TypeScript to JavaScript
npm run lint       # Run ESLint
npm run typecheck  # Run TypeScript type checking

Testing

npm test           # Run test suite
npm run test:watch # Run tests in watch mode

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Quick Start for Contributors

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Ensure tests pass: npm test
  5. Commit with conventional commits: git commit -m "feat: add amazing feature"
  6. Push to your fork and submit a pull request

📚 API Reference

cPanel UAPI Modules Used

  • Fileman: File management operations
  • Mysql: Database operations
  • Email: Email account management
  • DomainInfo: Domain information
  • Cron: Cron job management
  • StatsBar: Usage statistics
  • Backup: Backup operations

For detailed cPanel UAPI documentation, visit: cPanel UAPI Documentation

🐛 Troubleshooting

Common Issues

Connection Failed

  • Verify CPANEL_HOSTNAME is correct and accessible
  • Check that the specified port is open (default: 2083 for HTTPS)
  • Ensure SSL setting matches your cPanel configuration

Authentication Failed

  • Verify username and password/API token are correct
  • Check that API access is enabled for your account
  • Ensure API token has sufficient permissions

Tool Execution Errors

  • Check cPanel error logs for detailed error messages
  • Verify you have necessary permissions for the operation
  • Ensure target resources (databases, emails, etc.) exist

Debug Mode

Enable debug logging by setting:

DEBUG=cpanel-mcp:*

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support


Star ⭐ this repository if you find it helpful!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选