cPanel MCP Server
# cPanel MCP Server & AI State-Space Deployment Planner
[](https://modelcontextprotocol.io)
[](#mcp-server-capabilities)
[](#mcp-resources--prompts)
[](#mcp-resources--prompts)
[](LICENSE)
A full-stack **Model Context Protocol (MCP)** server and **AI State-Space Planning Engine** for automating cPanel Web Hosting operations, comparing classical & informed graph search algorithms (**BFS**, **DFS**, **UCS / UFS**, **A\***), and visualizing live search traces through a monochrome **React + Tailwind CSS v4 + shadcn/ui** dashboard.
---
## Group Members & Contributors
This project is a collaborative group project by:
- **Akash Jamali** — [@akashjamali](https://github.com/akashjamali)
- **Abdul Basit** — [@b4sit](https://github.com/b4sit)
- **Ali Nawaz** — [@mr-ans-2006](https://github.com/mr-ans-2006)
- **Basit Ali Shah** — [@ItsBasitAliShah](https://github.com/ItsBasitAliShah)
---
## Overview
The system combines two tightly integrated layers:
1. **cPanel MCP Server (`220` Tools, `3` Resources, `7` Prompts)**
Exposes cPanel UAPI & WHM-compatible workflows over stdio MCP so AI assistants can inspect and manage files, MySQL/PostgreSQL databases, email accounts, DNS zones, SSL certificates, domains, Node.js/Python/Laravel/WordPress runtimes, Git repositories, backups, and security policies.
2. **AI State-Space Deployment Planner (`src/planner/`) + Visualization Dashboard (`frontend/`)**
Models hosting provisioning and recovery as a deterministic state-space search problem over **12 state variables**, **16 operators** across **9 disjoint partitions**, and **5 deployment/recovery goals**, allowing direct side-by-side comparison of **BFS**, **DFS**, **UCS (UFS)**, and **A\*** using an admissible, consistent heuristic `h(s)`.
---
## AI Problem Formulation & Search Algorithms
### State-Space Representation
Each search node tracks a structured 12-variable `CpanelPlanningState` plus resource load context (`cpuPercent`, `memoryPercent`, `inodesUsedPercent`):
- **Infrastructure & Domain**: `domainReady`, `docrootValid`, `dnsConfigured`, `sslMode`
- **Application Lifecycle**: `runtimeConfigured`, `codeDeployed`, `depsInstalled`, `envConfigured`, `schedulerActive`
- **Database & Security**: `dbCreated`, `dbUserGranted`, `permsHardened`
### Operators, Partitions & Goals
- **16 Operators across 9 Disjoint Partitions**: Each transition encodes preconditions, effects, and load-aware step cost (`computeOperatorCost`).
- **5 Predefined Goals**:
- `provision_laravel`
- `provision_nodejs`
- `provision_python`
- `provision_static_site`
- `repair_https_and_db`
### Implemented Search Algorithms
| Algorithm | Strategy | Optimal Cost | Notes |
| :--- | :--- | :--- | :--- |
| **BFS** (`bfs`) | Breadth-First Search | Step-count optimal | Guarantees minimum step count, high frontier expansion |
| **DFS** (`dfs`) | Depth-First Search | No | Cycle-safe with configurable `maxDepth` |
| **UCS / UFS** (`ucs` / `ufs`) | Uniform Cost Search | Yes | Expands lowest cumulative path cost `g(n)` first |
| **A\*** (`astar`) | Informed Search | Yes | Minimizes `f(n) = g(n) + h(n)` via disjoint-partition admissible heuristic |
### Observed Benchmark (`provision_laravel` on `clean_account`)
Verified via MCP `compare_search_algorithms`:
| Algorithm | Plan Steps | Total Cost `g(n)` | Nodes Expanded |
| :--- | :---: | :---: | :---: |
| **BFS** | 9 | 31 | 1,065 |
| **DFS** | 12 | 23 | 12 |
| **UCS (UFS)** | 11 | 22 | 861 |
| **A\*** | 11 | 22 | **11** (`-98.72%` vs UCS) |
---
## Monochrome Planner UI & Local API Server
A local HTTP API server (`src/ui-server.ts`) binds to `127.0.0.1:3001` and serves the built `frontend/dist` bundle alongside dry-run/read-only planning endpoints:
- `GET /api/health` — Check local UI server & frontend build status
- `GET /api/state-space` — Inspect problem states, 16 operators, and goal definitions (offline/no cPanel calls)
- `GET /api/observe` — Observe initial hosting state (4 dry-run presets or explicit live cPanel read-only check)
- `POST /api/plan` — Run a single algorithm (`bfs`, `dfs`, `ucs`/`ufs`, `astar`) with step-by-step `exploredTrace`
- `POST /api/compare` — Benchmark all 4 algorithms side by side
### Frontend Stack (`frontend/`)
- **Vite `8.4.0`** + **React `19.3.1`** (JavaScript)
- **Tailwind CSS v4** (`@tailwindcss/vite`) + **lucide-react**
- **12 shadcn/ui Components** (`button`, `badge`, `card`, `input`, `label`, `select`, `separator`, `switch`, `checkbox`, `tabs`, `table`, `progress`) styled with a strict `0px`-radius monochrome Light/Dark palette (`frontend/src/index.css`)
- Starts disconnected from live cPanel on initial load (`frontend/src/App.jsx`) for safe offline/dry-run experimentation
---
## Architecture
```text
MyMCP/
├── src/
│ ├── index.ts # MCP stdio server entrypoint (registers 33 modules / 220 tools)
│ ├── ui-server.ts # Localhost API & static UI server (127.0.0.1:3001)
│ ├── cpanel-api.ts # HTTPS cPanel UAPI client with HTTP 429 Retry-After backoff
│ ├── setup.ts # Interactive setup wizard (`npm run setup`)
│ ├── resources.ts # 3 MCP resources
│ ├── prompts.ts # 7 MCP workflow prompts
│ ├── planner/
│ │ ├── types.ts # State, operator, goal, trace, and benchmark types
│ │ ├── domain.ts # 12 state variables, 16 operators, 9 partitions, admissible h(s)
│ │ ├── algorithms.ts # BFS, DFS, UCS/UFS, and A* implementations
│ │ └── observe.ts # Live & dry-run initial state observation
│ └── tools/ # 33 MCP tool modules (auth, password reset, files, db, email, dns, ssl, planner, etc.)
├── frontend/ # Vite + React + Tailwind CSS v4 + shadcn/ui dashboard
├── test/
│ ├── security-regression.test.mjs
│ ├── mcp-protocol.test.mjs
│ ├── planner.test.mjs
│ ├── password-reset.test.mjs
│ └── ui-server.test.mjs
├── SKILL.md # Mandatory AI agent safety & execution guardrails
├── .env.example # Configuration template (never commit real secrets)
└── package.json
```
---
## MCP Server Capabilities
### Registered Surface (`220` Tools Across `33` Modules)
- **AI State-Space Planning (`src/tools/planner.ts`)**: `describe_cpanel_state_space`, `observe_cpanel_state`, `plan_cpanel_workflow`, `compare_search_algorithms`
- **Authentication, Account & Password Reset (`src/tools/auth.ts`, `src/tools/password-reset.ts`)**: `login_cpanel`, `get_login_status`, `logout_cpanel`, `verify_cpanel_connection`, `reset_cpanel_password`, `reset_password`, `get_account_info`, `get_server_info`, API token & SSH key management
- **Files & Backups**: Directory listing, read/create/edit/delete, compression/extraction, permissions, Base64 upload, full/home/DB/email backups
- **Databases**: MySQL & PostgreSQL databases, users, privileges, check/repair
- **Email & Deliverability**: Email accounts, forwarders, autoresponders, filters, DKIM/SPF/PTR validation, SpamAssassin, greylisting
- **Domains, DNS & SSL**: Subdomains, addon/parked domains, redirects, DNS records, DNSSEC, SSL certificates & AutoSSL
- **App Hosting & CI/CD**: WordPress, Node.js, Python, Passenger, Laravel, Git repositories, GitHub sync/webhooks/Actions, cron jobs
- **Security & Telemetry**: IP blocker, directory privacy, ModSecurity, hotlink protection, 2FA, ClamAV virus scan, error logs, resource usage
### MCP Resources & Prompts
- **3 Resources (`src/resources.ts`)**:
- `cpanel://system/disk-usage`
- `cpanel://server/info`
- `cpanel://account/summary`
- **7 Prompts (`src/prompts.ts`)**:
- `troubleshoot_domain`
- `hosting_security_audit`
- `deploy_new_site`
- `setup_github_cpanel_cicd`
- `setup_nodejs_app_workflow`
- `setup_python_app_workflow`
- `setup_laravel_app_workflow`
---
## Quick Start
### 1. Install & Build
```bash
git clone <repository-url>
cd MyMCP
npm install
npm run build
```
### 2. Configure Credentials (Optional for Offline Planning)
Run the interactive setup wizard or copy `.env.example` to `.env`:
```bash
npm run setup
```
Supported connection methods:
- **Environment variables**: `CPANEL_HOST`, `CPANEL_USERNAME`, `CPANEL_API_TOKEN` (never committed to git)
- **Runtime MCP login**: `login_cpanel` normalizes copied `/cpsess...` URLs automatically and persists session config outside the repo (`~/.cpanel-mcp/config.json`)
### 3. Start the AI Planner Dashboard
Serve the built frontend and planner API at `http://127.0.0.1:3001`:
```bash
npm run ui
```
Or run the frontend dev server with API proxy (after installing frontend dependencies):
```bash
cd frontend
npm install
npm run dev
```
### 4. Connect to an MCP Client
Add the built server to your MCP client configuration (such as `mcp_config.json`):
```json
{
"mcpServers": {
"cpanel": {
"command": "node",
"args": ["/absolute/path/to/MyMCP/build/index.js"]
}
}
}
```
---
## Security & Safety Guardrails
- **Operational Guardrails (`SKILL.md`)**: Requires path validation, strict credential scoping, explicit user confirmation for destructive operations (deleting databases, emails, files, or domains), and dry-run planning prior to live infrastructure mutation.
- **Transport & Rate-Limit Resilience (`src/cpanel-api.ts`)**: Enforces HTTPS cPanel UAPI requests, sanitizes HTML rate-limit responses, and automatically retries `HTTP 429` responses honoring `Retry-After` headers.
- **Local-Only Dashboard Binding**: `src/ui-server.ts` binds exclusively to `127.0.0.1:3001` with read-only observation and dry-run planning endpoints.
---
## Testing & Verification
Run the root TypeScript build and Node test suite (`24` tests across `test/security-regression.test.mjs`, `test/mcp-protocol.test.mjs`, `test/planner.test.mjs`, `test/password-reset.test.mjs`, and `test/ui-server.test.mjs`):
```bash
npm test
```
Run frontend linting and production bundle build:
```bash
cd frontend
npm run lint
npm run build
```
---
## License
This project is licensed under the [MIT License](LICENSE).
TDQS
Scored across 220 tools
The 220-tool surface contains many overlapping or near-duplicate operations, such as reset_password vs. reset_cpanel_password/change_email_password/change_ftp_password, setup_nodejs_app vs. register_passenger_app, and list_domains/list_addon_domains/list_parked_domains/list_subdomains. While many tools target distinct resources, the sheer volume and layered abstractions create unclear boundaries for an agent choosing among similar actions.
Nearly all tools use a consistent snake_case verb_noun pattern (list_*, get_*, create_*, delete_*, enable_*, disable_*, validate_*). Even the more specialized planning and provisioning tools follow readable verb-first naming without mixing conventions.
220 tools is an extreme over-expansion for a cPanel server, far beyond a well-scoped set. Many operations are duplicated across generic and specialized tools, making the surface unwieldy despite broad domain coverage.
The tool set covers most cPanel domains comprehensively: files, DNS, SSL, email, databases, FTP, cron, security, domains, Node/Python/Laravel hosting, and backups. Minor gaps exist, such as directory-privacy user removal and some email routing configuration, but core lifecycle operations are broadly present.