devops-whc 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_MCP_USAGE.md +394 -0
- package/LICENSE +15 -0
- package/README.md +208 -0
- package/WHC_MCP_REQUIREMENTS.md +112 -0
- package/dist/audit/audit-logger.js +57 -0
- package/dist/clients/ssh-client.js +199 -0
- package/dist/clients/whc-uapi-client.js +178 -0
- package/dist/clients/wpcli-client.js +125 -0
- package/dist/config/env.js +132 -0
- package/dist/contracts/deployment.js +2 -0
- package/dist/contracts/envelope.js +2 -0
- package/dist/dispatcher/tool-dispatcher.js +145 -0
- package/dist/handlers/whc-check-health.js +131 -0
- package/dist/handlers/whc-db-backup.js +111 -0
- package/dist/handlers/whc-deploy.js +381 -0
- package/dist/handlers/whc-get-logs.js +108 -0
- package/dist/handlers/whc-pipeline-status.js +96 -0
- package/dist/handlers/whc-prepare.js +127 -0
- package/dist/handlers/whc-rollback.js +141 -0
- package/dist/handlers/whc-setup-remote.js +262 -0
- package/dist/handlers/whc-ssh-exec.js +138 -0
- package/dist/handlers/whc-verify.js +304 -0
- package/dist/idempotency/store.js +13 -0
- package/dist/index.js +109 -0
- package/dist/policy/policy-engine.js +41 -0
- package/dist/probes/connectivity.js +41 -0
- package/dist/registry/tool-registry.js +69 -0
- package/dist/schemas/whc-check-health.js +55 -0
- package/dist/schemas/whc-db-backup.js +29 -0
- package/dist/schemas/whc-deploy.js +66 -0
- package/dist/schemas/whc-get-logs.js +25 -0
- package/dist/schemas/whc-pipeline-status.js +24 -0
- package/dist/schemas/whc-prepare.js +29 -0
- package/dist/schemas/whc-rollback.js +58 -0
- package/dist/schemas/whc-setup-remote.js +60 -0
- package/dist/schemas/whc-ssh-exec.js +117 -0
- package/dist/schemas/whc-verify.js +28 -0
- package/dist/server-entry.js +8 -0
- package/dist/server.js +381 -0
- package/dist/services/deploy-runtime-ops.js +104 -0
- package/dist/services/deployment-locks.js +34 -0
- package/dist/state/workspace-state.js +201 -0
- package/package.json +48 -0
- package/scripts/prepare-first-time.cjs +75 -0
- package/scripts/start-mcp.cjs +42 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# WHC MCP Agent Usage Guide
|
|
2
|
+
|
|
3
|
+
This guide is for AI agents and operators who need predictable, safe usage of the WHC MCP server.
|
|
4
|
+
|
|
5
|
+
## 1. Goal
|
|
6
|
+
|
|
7
|
+
Use WHC MCP to run a safe release flow:
|
|
8
|
+
|
|
9
|
+
1. Initialize workspace state (`whc_prepare`).
|
|
10
|
+
2. Validate connectivity and environment.
|
|
11
|
+
3. Deploy to staging first.
|
|
12
|
+
4. Run technical verify (`whc_verify`) and smoke gate.
|
|
13
|
+
5. Promote to live only if staging passes.
|
|
14
|
+
|
|
15
|
+
## 2. Runtime Model
|
|
16
|
+
|
|
17
|
+
The server supports two workflow modes:
|
|
18
|
+
|
|
19
|
+
1. `managed_clone_sync`
|
|
20
|
+
2. `git_controlled`
|
|
21
|
+
|
|
22
|
+
Most WHC managed WordPress flows use `managed_clone_sync`.
|
|
23
|
+
|
|
24
|
+
If server env sets `WHC_WORKFLOW_MODE=managed_clone_sync`, treat staging as managed-only.
|
|
25
|
+
Do not call `git_controlled` for staging in that mode.
|
|
26
|
+
|
|
27
|
+
## 2.2 MCP Registration Standard
|
|
28
|
+
|
|
29
|
+
Use one of these two registration patterns and keep them consistent with README.
|
|
30
|
+
|
|
31
|
+
Published package (`npx`) recommended for most users:
|
|
32
|
+
|
|
33
|
+
```jsonc
|
|
34
|
+
{
|
|
35
|
+
"servers": {
|
|
36
|
+
"whc-mcp": {
|
|
37
|
+
"type": "stdio",
|
|
38
|
+
"command": "npx",
|
|
39
|
+
"args": ["-y", "devops-whc", "--serve"],
|
|
40
|
+
"env": {
|
|
41
|
+
"WHC_ENV_FILE": "${workspaceFolder}/.env",
|
|
42
|
+
"WHC_LOCAL_PROJECT_ROOT": "${workspaceFolder}",
|
|
43
|
+
"WHC_STATE_ROOT": ".mcp/whc-mcp",
|
|
44
|
+
"WHC_MCP_INSTANCE_NAME": "whc-mcp"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Local clone (`start-mcp.cjs`) for contributors:
|
|
52
|
+
|
|
53
|
+
```jsonc
|
|
54
|
+
{
|
|
55
|
+
"servers": {
|
|
56
|
+
"whc-mcp": {
|
|
57
|
+
"type": "stdio",
|
|
58
|
+
"command": "node",
|
|
59
|
+
"args": ["./scripts/start-mcp.cjs"],
|
|
60
|
+
"cwd": "${workspaceFolder}",
|
|
61
|
+
"env": {
|
|
62
|
+
"WHC_ENV_FILE": "${workspaceFolder}/.env",
|
|
63
|
+
"WHC_LOCAL_PROJECT_ROOT": "${workspaceFolder}",
|
|
64
|
+
"WHC_STATE_ROOT": ".mcp/whc-mcp",
|
|
65
|
+
"WHC_MCP_INSTANCE_NAME": "whc-mcp"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Quick CLI checks:
|
|
73
|
+
|
|
74
|
+
```powershell
|
|
75
|
+
npx -y devops-whc --help
|
|
76
|
+
npx -y devops-whc --version
|
|
77
|
+
npx -y devops-whc --probe
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 2.3 Publish Package Boundary
|
|
81
|
+
|
|
82
|
+
Release artifacts are published from `packages/devops-whc`, not from repository root.
|
|
83
|
+
|
|
84
|
+
Release commands:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
npm run pack:check
|
|
88
|
+
npm --prefix packages/devops-whc publish
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`npm run pack:check` will run publish preparation and package dry-run against the subpackage.
|
|
92
|
+
|
|
93
|
+
## 2.1 Why `whc_setup_remote` Exists
|
|
94
|
+
|
|
95
|
+
`whc_setup_remote` does not deploy application code.
|
|
96
|
+
|
|
97
|
+
It only prepares the remote Git endpoint on cPanel (repository root + SSH hint) so local source can be pushed.
|
|
98
|
+
|
|
99
|
+
Think of it as wiring transport, not shipping release.
|
|
100
|
+
|
|
101
|
+
After `whc_setup_remote`, a manual or automated `git push` from local source is still required, then `whc_deploy` triggers deployment tasks.
|
|
102
|
+
|
|
103
|
+
## 3. Required Context Before Any Write
|
|
104
|
+
|
|
105
|
+
Always collect these first:
|
|
106
|
+
|
|
107
|
+
1. Active workflow mode.
|
|
108
|
+
2. Target environment (`staging` or `live`).
|
|
109
|
+
3. Direction (for managed clone/sync):
|
|
110
|
+
- `live_to_staging`
|
|
111
|
+
- `staging_to_live`
|
|
112
|
+
4. Sync scope:
|
|
113
|
+
- `files`
|
|
114
|
+
- `database`
|
|
115
|
+
- `everything`
|
|
116
|
+
5. Whether `dry_run` and `confirmed` are required by policy.
|
|
117
|
+
6. For `git_controlled`, ensure `repository_root` belongs to current `WHC_USER` home path (`/home/<WHC_USER>/...`).
|
|
118
|
+
|
|
119
|
+
## 3.1 Manual vs Agent Responsibilities
|
|
120
|
+
|
|
121
|
+
User/operator must do manually (once per environment):
|
|
122
|
+
1. Create/rotate WHC API token and place in env (`WHC_API_TOKEN`).
|
|
123
|
+
2. Add SSH public key to correct cPanel account.
|
|
124
|
+
3. Confirm host/path ownership and account scope.
|
|
125
|
+
|
|
126
|
+
Agent can automate repeatedly:
|
|
127
|
+
1. Validate context and run dry-run checks.
|
|
128
|
+
2. Create/list repository via `whc_setup_remote`.
|
|
129
|
+
3. Trigger deployment via `whc_deploy`.
|
|
130
|
+
4. Execute safe runtime probes and logs/health collection.
|
|
131
|
+
|
|
132
|
+
Hybrid step:
|
|
133
|
+
1. `git push` may be run by agent from local terminal when keys/permissions are ready; otherwise operator performs push manually.
|
|
134
|
+
|
|
135
|
+
## 4. Safety Rules
|
|
136
|
+
|
|
137
|
+
1. Never promote live directly without staging verification.
|
|
138
|
+
2. For `staging_to_live` with `database` or `everything`, provide backup reference unless emergency override is explicitly approved.
|
|
139
|
+
3. Prefer `dry_run=true` before state-changing requests.
|
|
140
|
+
4. Always set `confirmed=true` when the policy requires explicit confirmation.
|
|
141
|
+
|
|
142
|
+
## 5. Tool Order (Recommended)
|
|
143
|
+
|
|
144
|
+
1. `whc_prepare` to initialize hidden state and readiness checks.
|
|
145
|
+
2. `whc_check_health` for target status and capability baseline.
|
|
146
|
+
3. `whc_get_logs` for pre-deploy signal.
|
|
147
|
+
4. `whc_deploy` with `dry_run=true`.
|
|
148
|
+
5. `whc_deploy` real execution after dry-run passes.
|
|
149
|
+
6. `whc_verify` to produce technical verify report.
|
|
150
|
+
7. Run smoke checks outside or via allowed tool path.
|
|
151
|
+
8. If staging passes, run promote flow for live with explicit direction and backup policy.
|
|
152
|
+
|
|
153
|
+
## 6.4 Rollback (Level D) Contract
|
|
154
|
+
|
|
155
|
+
Use rollback only when verify and policy conditions are satisfied.
|
|
156
|
+
|
|
157
|
+
Mandatory gates:
|
|
158
|
+
1. `dry_run=true` for preview.
|
|
159
|
+
2. `confirmed=true` for execution.
|
|
160
|
+
3. Verify-chain report from `whc_verify` with `final_status=PASS`.
|
|
161
|
+
|
|
162
|
+
Example rollback preview payload:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"dry_run": true,
|
|
167
|
+
"confirmed": true,
|
|
168
|
+
"payload": {
|
|
169
|
+
"target_environment": "live",
|
|
170
|
+
"rollback_mode": "git_branch",
|
|
171
|
+
"rollback_branch": "rollback/main",
|
|
172
|
+
"reason": "production incident mitigation",
|
|
173
|
+
"verify_release_id": "rel-2026-06-10-01"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 6. Canonical Payloads
|
|
179
|
+
|
|
180
|
+
### 6.1 Staging dry-run (managed clone/sync refresh)
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"dry_run": true,
|
|
185
|
+
"confirmed": true,
|
|
186
|
+
"payload": {
|
|
187
|
+
"workflow_mode": "managed_clone_sync",
|
|
188
|
+
"target_environment": "staging",
|
|
189
|
+
"release_intent": "refresh",
|
|
190
|
+
"pipeline_id": "P3D",
|
|
191
|
+
"source_profile": {
|
|
192
|
+
"source_kind": "full_site",
|
|
193
|
+
"deploy_unit": "raw_source"
|
|
194
|
+
},
|
|
195
|
+
"direction": "live_to_staging",
|
|
196
|
+
"sync_scope": "files",
|
|
197
|
+
"verify_after_deploy": true,
|
|
198
|
+
"auto_rollback_on_verify_failure": false
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 6.2 Staging real refresh sync (managed clone/sync)
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"confirmed": true,
|
|
208
|
+
"payload": {
|
|
209
|
+
"workflow_mode": "managed_clone_sync",
|
|
210
|
+
"target_environment": "staging",
|
|
211
|
+
"release_intent": "refresh",
|
|
212
|
+
"pipeline_id": "P3D",
|
|
213
|
+
"source_profile": {
|
|
214
|
+
"source_kind": "full_site",
|
|
215
|
+
"deploy_unit": "raw_source"
|
|
216
|
+
},
|
|
217
|
+
"direction": "live_to_staging",
|
|
218
|
+
"sync_scope": "files",
|
|
219
|
+
"verify_after_deploy": true,
|
|
220
|
+
"auto_rollback_on_verify_failure": false
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 6.3 Live promote (higher risk)
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"confirmed": true,
|
|
230
|
+
"payload": {
|
|
231
|
+
"workflow_mode": "managed_clone_sync",
|
|
232
|
+
"target_environment": "live",
|
|
233
|
+
"release_intent": "promote",
|
|
234
|
+
"pipeline_id": "P3D",
|
|
235
|
+
"source_profile": {
|
|
236
|
+
"source_kind": "full_site",
|
|
237
|
+
"deploy_unit": "raw_source"
|
|
238
|
+
},
|
|
239
|
+
"direction": "staging_to_live",
|
|
240
|
+
"sync_scope": "files",
|
|
241
|
+
"verify_after_deploy": true,
|
|
242
|
+
"auto_rollback_on_verify_failure": true
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## 7. Smoke Gate Expectations
|
|
248
|
+
|
|
249
|
+
Before live promote, ensure AC-critical smoke is green on staging.
|
|
250
|
+
|
|
251
|
+
Suggested minimum:
|
|
252
|
+
|
|
253
|
+
1. Account page reachable.
|
|
254
|
+
2. Required API namespace/routes reachable.
|
|
255
|
+
3. Pricing visibility behavior by auth state.
|
|
256
|
+
4. Checkout fee messaging baseline.
|
|
257
|
+
|
|
258
|
+
If preconditions fail (plugin/page/routes absent), gate must be `HOLD`.
|
|
259
|
+
|
|
260
|
+
## 7.1 Pipeline Mindset Guard
|
|
261
|
+
|
|
262
|
+
Treat these as two different operations:
|
|
263
|
+
|
|
264
|
+
1. Environment refresh:
|
|
265
|
+
- `workflow_mode=managed_clone_sync`
|
|
266
|
+
- `direction=live_to_staging`
|
|
267
|
+
- `release_intent=refresh`
|
|
268
|
+
2. Release deploy to staging:
|
|
269
|
+
- Use release candidate source (typically `git_controlled`), not live mirror sync.
|
|
270
|
+
- Use `repository_root` under `/home/<WHC_USER>/...`; cross-account paths are blocked by policy.
|
|
271
|
+
|
|
272
|
+
Policy note:
|
|
273
|
+
|
|
274
|
+
1. `managed_clone_sync + live_to_staging + release_intent=deploy` is blocked by policy because it causes release-testing ambiguity.
|
|
275
|
+
|
|
276
|
+
## 8. Troubleshooting
|
|
277
|
+
|
|
278
|
+
### 8.1 Startup auth errors with SSH key path
|
|
279
|
+
|
|
280
|
+
Symptom:
|
|
281
|
+
|
|
282
|
+
1. `AUTH_ERROR` or `ENOENT` for key file while path appears valid.
|
|
283
|
+
|
|
284
|
+
Checks:
|
|
285
|
+
|
|
286
|
+
1. Confirm `WHC_ENV_FILE` points to the intended env file.
|
|
287
|
+
2. Confirm the MCP process has reloaded after env edits.
|
|
288
|
+
3. Avoid malformed quoting in key path values.
|
|
289
|
+
|
|
290
|
+
### 8.2 Deploy validation errors in managed mode
|
|
291
|
+
|
|
292
|
+
If request fails with missing direction, ensure payload includes:
|
|
293
|
+
|
|
294
|
+
1. `direction`
|
|
295
|
+
2. `sync_scope`
|
|
296
|
+
|
|
297
|
+
## 9. One-Line Operator Playbook
|
|
298
|
+
|
|
299
|
+
1. Health check -> logs -> staging dry-run -> staging deploy -> smoke gate -> decide promote/hold.
|
|
300
|
+
|
|
301
|
+
## 10. Flow Log Read Guide (For Agent Responses)
|
|
302
|
+
|
|
303
|
+
### 10.1 Log path
|
|
304
|
+
|
|
305
|
+
1. Default path: `.mcp/whc-mcp/logs/flow-events.jsonl`
|
|
306
|
+
2. Custom path (optional): set `WHC_FLOW_LOG_PATH` in env
|
|
307
|
+
|
|
308
|
+
### 10.2 Read latest entries (PowerShell)
|
|
309
|
+
|
|
310
|
+
```powershell
|
|
311
|
+
Get-Content .mcp/whc-mcp/logs/flow-events.jsonl -Tail 20
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
If custom path is configured:
|
|
315
|
+
|
|
316
|
+
```powershell
|
|
317
|
+
Get-Content $env:WHC_FLOW_LOG_PATH -Tail 20
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Filter only deploy events:
|
|
321
|
+
|
|
322
|
+
```powershell
|
|
323
|
+
Get-Content .mcp/whc-mcp/logs/flow-events.jsonl -Tail 200 |
|
|
324
|
+
ForEach-Object { $_ | ConvertFrom-Json } |
|
|
325
|
+
Where-Object { $_.tool -eq 'whc_deploy' } |
|
|
326
|
+
Select-Object -Last 10
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### 10.3 Response format requirement
|
|
330
|
+
|
|
331
|
+
When responding after any write tool run, agent should include:
|
|
332
|
+
|
|
333
|
+
1. `action_id`
|
|
334
|
+
2. `tool`
|
|
335
|
+
3. `status` (`success` or `failure`)
|
|
336
|
+
4. `request_id` (if available)
|
|
337
|
+
5. `pipeline_id`
|
|
338
|
+
6. `target_environment`
|
|
339
|
+
7. `release_intent`
|
|
340
|
+
8. Log path used
|
|
341
|
+
|
|
342
|
+
Minimal response snippet:
|
|
343
|
+
|
|
344
|
+
```text
|
|
345
|
+
Flow log:
|
|
346
|
+
- path: .mcp/whc-mcp/logs/flow-events.jsonl
|
|
347
|
+
- action_id: <value>
|
|
348
|
+
- tool: whc_deploy
|
|
349
|
+
- status: success|failure
|
|
350
|
+
- request_id: <value>
|
|
351
|
+
- pipeline_id: <value>
|
|
352
|
+
- target_environment: staging|live
|
|
353
|
+
- release_intent: deploy|refresh|promote|migrate|recover
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## 10.4 First-Time Prepare (No Manual Template Filling)
|
|
357
|
+
|
|
358
|
+
For local clone workflows, run once per workspace:
|
|
359
|
+
|
|
360
|
+
```powershell
|
|
361
|
+
npm run mcp:prepare
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
For npm-package workflows, call `whc_prepare` once from the MCP client after the server starts.
|
|
365
|
+
|
|
366
|
+
This initializes hidden management paths automatically:
|
|
367
|
+
1. `.mcp/whc-mcp/state/pipeline-status.json`
|
|
368
|
+
2. `.mcp/whc-mcp/state/releases/`
|
|
369
|
+
3. `.mcp/whc-mcp/state/reports/`
|
|
370
|
+
4. `.mcp/whc-mcp/logs/`
|
|
371
|
+
|
|
372
|
+
It also ensures `.mcp/` is ignored by git.
|
|
373
|
+
|
|
374
|
+
## 10.5 Automatic State Tracking
|
|
375
|
+
|
|
376
|
+
For every write tool run, MCP now auto-updates:
|
|
377
|
+
1. `.mcp/whc-mcp/state/pipeline-status.json` (started/completed/status/next step/error)
|
|
378
|
+
2. `.mcp/whc-mcp/state/releases/<request_id>.auto-manifest.json` (tool metadata + git changed files snapshot)
|
|
379
|
+
|
|
380
|
+
No manual template authoring is required for normal DevOps runs.
|
|
381
|
+
|
|
382
|
+
## 11. Pipeline Progress Tracking (What To Read)
|
|
383
|
+
|
|
384
|
+
For `whc_deploy` and `whc_setup_remote`, read these response fields first:
|
|
385
|
+
1. `data.pipeline_status`
|
|
386
|
+
- `full_pass` or `pass_partial`
|
|
387
|
+
2. `data.phase_coverage`
|
|
388
|
+
- `code_state`, `runtime_state`, `data_state`, `deployment_state`
|
|
389
|
+
3. `data.process_tracking` (setup_remote)
|
|
390
|
+
- `stage`, `status`, `next_step`, `manual_actions`
|
|
391
|
+
|
|
392
|
+
Decision rule:
|
|
393
|
+
1. If `pipeline_status=pass_partial`, do not claim end-to-end release completion.
|
|
394
|
+
2. Follow `next_step` and unresolved `manual_actions` before moving to next gate.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# devops-whc
|
|
2
|
+
|
|
3
|
+
WHC cPanel MCP server for deploy, verify, rollback, logs, backup, and health flows.
|
|
4
|
+
|
|
5
|
+
Current release: 1.0.1
|
|
6
|
+
|
|
7
|
+
## Publish Package Layout
|
|
8
|
+
|
|
9
|
+
Npm release artifacts are now isolated in a dedicated package folder:
|
|
10
|
+
|
|
11
|
+
- `packages/devops-whc`
|
|
12
|
+
|
|
13
|
+
The repository root is the development workspace. The publish package is prepared by syncing built/runtime files into `packages/devops-whc` before packing or publishing.
|
|
14
|
+
|
|
15
|
+
## What this is
|
|
16
|
+
|
|
17
|
+
This package exposes an MCP server that VS Code Copilot or any MCP client can launch over stdio. It is designed for WHC cPanel projects and keeps the local workflow, target environment, and safety rules explicit.
|
|
18
|
+
|
|
19
|
+
The server supports both usage patterns:
|
|
20
|
+
|
|
21
|
+
1. Run from a local clone while developing.
|
|
22
|
+
2. Install from npm and launch with `npx` or a global install.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
### From a clone
|
|
27
|
+
|
|
28
|
+
```powershell
|
|
29
|
+
npm install
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### From npm
|
|
34
|
+
|
|
35
|
+
```powershell
|
|
36
|
+
npx -y devops-whc --help
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or install globally:
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
npm install -g devops-whc
|
|
43
|
+
whc-mcp --help
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
1. Copy `.env.example` to `.env`.
|
|
49
|
+
2. Fill in the required WHC credentials and target paths.
|
|
50
|
+
3. Run `npm run mcp:prepare` once per workspace.
|
|
51
|
+
4. Start the server with `npm run serve` for local development, or `npx -y devops-whc --serve` after npm install.
|
|
52
|
+
|
|
53
|
+
If you are using VS Code Copilot MCP, point the server command to the published package or to the local `start-mcp.cjs` helper.
|
|
54
|
+
|
|
55
|
+
## VS Code MCP Config
|
|
56
|
+
|
|
57
|
+
Published-package example:
|
|
58
|
+
|
|
59
|
+
```jsonc
|
|
60
|
+
{
|
|
61
|
+
"servers": {
|
|
62
|
+
"whc-mcp": {
|
|
63
|
+
"type": "stdio",
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "devops-whc", "--serve"],
|
|
66
|
+
"env": {
|
|
67
|
+
"WHC_ENV_FILE": "${workspaceFolder}/.env",
|
|
68
|
+
"WHC_LOCAL_PROJECT_ROOT": "${workspaceFolder}",
|
|
69
|
+
"WHC_STATE_ROOT": ".mcp/whc-mcp",
|
|
70
|
+
"WHC_MCP_INSTANCE_NAME": "whc-mcp"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Local-source example:
|
|
78
|
+
|
|
79
|
+
```jsonc
|
|
80
|
+
{
|
|
81
|
+
"servers": {
|
|
82
|
+
"whc-mcp": {
|
|
83
|
+
"type": "stdio",
|
|
84
|
+
"command": "node",
|
|
85
|
+
"args": ["./scripts/start-mcp.cjs"],
|
|
86
|
+
"cwd": "${workspaceFolder}",
|
|
87
|
+
"env": {
|
|
88
|
+
"WHC_ENV_FILE": "${workspaceFolder}/.env",
|
|
89
|
+
"WHC_LOCAL_PROJECT_ROOT": "${workspaceFolder}",
|
|
90
|
+
"WHC_STATE_ROOT": ".mcp/whc-mcp",
|
|
91
|
+
"WHC_MCP_INSTANCE_NAME": "whc-mcp"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## CLI Commands
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
whc-mcp --serve
|
|
102
|
+
whc-mcp --probe
|
|
103
|
+
whc-mcp --check-health
|
|
104
|
+
whc-mcp --help
|
|
105
|
+
whc-mcp --version
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If you are using the npm package directly, the same commands work through `npx`:
|
|
109
|
+
|
|
110
|
+
```powershell
|
|
111
|
+
npx -y devops-whc --serve
|
|
112
|
+
npx -y devops-whc --probe
|
|
113
|
+
npx -y devops-whc --check-health
|
|
114
|
+
npx -y devops-whc --help
|
|
115
|
+
npx -y devops-whc --version
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Required Environment Variables
|
|
119
|
+
|
|
120
|
+
Set these in your local `.env` file:
|
|
121
|
+
|
|
122
|
+
- `WHC_API_TOKEN`
|
|
123
|
+
- `WHC_USER`
|
|
124
|
+
- `WHC_HOST`
|
|
125
|
+
- `WHC_PROD_SSH_HOST`
|
|
126
|
+
- `WHC_PROD_SSH_USERNAME`
|
|
127
|
+
- `WHC_PROD_SSH_PRIVATE_KEY_PATH`
|
|
128
|
+
|
|
129
|
+
## Optional Environment Variables
|
|
130
|
+
|
|
131
|
+
- `WHC_WORKFLOW_MODE`
|
|
132
|
+
- `WHC_PRIMARY_DOMAIN`
|
|
133
|
+
- `WHC_TESTING_DOMAIN`
|
|
134
|
+
- `WHC_STAGING_DOMAIN`
|
|
135
|
+
- `WHC_PROD_PATH`
|
|
136
|
+
- `WHC_STAGING_PATH`
|
|
137
|
+
- `WHC_REQUIRE_STAGING_CONFIRM`
|
|
138
|
+
- `WHC_WARN_DYNAMIC_DATA_SYNC`
|
|
139
|
+
- `WHC_ENFORCE_STAGING_FIRST`
|
|
140
|
+
- `WHC_ALLOW_STAGING_GIT_CONTROLLED`
|
|
141
|
+
- `WHC_STAGING_SSH_HOST`
|
|
142
|
+
- `WHC_STAGING_SSH_PORT`
|
|
143
|
+
- `WHC_STAGING_SSH_USERNAME`
|
|
144
|
+
- `WHC_STAGING_SSH_PRIVATE_KEY_PATH`
|
|
145
|
+
- `WHC_STAGING_SSH_PASSWORD`
|
|
146
|
+
- `WHC_STAGING_SSH_HOSTKEY`
|
|
147
|
+
- `WHC_LOCAL_PROJECT_ROOT`
|
|
148
|
+
- `WHC_LOCAL_APP_PATH`
|
|
149
|
+
- `WHC_SOURCE_KIND`
|
|
150
|
+
- `WHC_DEPLOY_UNIT`
|
|
151
|
+
- `WHC_BUILD_COMMAND`
|
|
152
|
+
- `WHC_BUILD_ARTIFACT_PATH`
|
|
153
|
+
- `WHC_DEFAULT_RELEASE_INTENT`
|
|
154
|
+
- `WHC_API_TIMEOUT_MS`
|
|
155
|
+
- `WHC_SSH_TIMEOUT_MS`
|
|
156
|
+
- `WHC_FLOW_LOG_PATH`
|
|
157
|
+
- `WHC_STATE_ROOT`
|
|
158
|
+
|
|
159
|
+
## Practical Examples
|
|
160
|
+
|
|
161
|
+
### 1) Check connectivity before deploy
|
|
162
|
+
|
|
163
|
+
```powershell
|
|
164
|
+
npx -y devops-whc --probe
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This checks the UAPI, SSH, and WP-CLI connectivity signals before a deploy run.
|
|
168
|
+
|
|
169
|
+
### 2) Run a health check
|
|
170
|
+
|
|
171
|
+
```powershell
|
|
172
|
+
npx -y devops-whc --check-health
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Use this to inspect disk, SSL, load, and capability state.
|
|
176
|
+
|
|
177
|
+
### 3) Start the MCP server in VS Code
|
|
178
|
+
|
|
179
|
+
Once the MCP config is in place, Copilot can launch the server and call tools such as `whc_prepare`, `whc_deploy`, `whc_verify`, and `whc_rollback`.
|
|
180
|
+
|
|
181
|
+
### 4) Prepare workspace state once
|
|
182
|
+
|
|
183
|
+
```powershell
|
|
184
|
+
npm run mcp:prepare
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
This initializes the hidden project state under `.mcp/whc-mcp` and ensures the workspace ignores local management files.
|
|
188
|
+
|
|
189
|
+
## Safety Notes
|
|
190
|
+
|
|
191
|
+
1. Never commit `.env` or `.vscode/whc.env`.
|
|
192
|
+
2. Keep secrets in your local workspace only.
|
|
193
|
+
3. The npm tarball is limited to the published files list and does not include local env files.
|
|
194
|
+
4. For staging-to-live or database-changing operations, follow the tool safety prompts and confirm the release intent.
|
|
195
|
+
|
|
196
|
+
## Publish Checklist
|
|
197
|
+
|
|
198
|
+
1. `npm run test`
|
|
199
|
+
2. `npm run pack:check`
|
|
200
|
+
3. `npm --prefix packages/devops-whc publish`
|
|
201
|
+
|
|
202
|
+
Notes:
|
|
203
|
+
1. `npm run pack:check` automatically runs publish preparation and packs from `packages/devops-whc`.
|
|
204
|
+
2. Do not publish from the repository root package.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
ISC
|