@daileyos/mcp-server 1.21.2 → 1.21.4
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/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +23 -2
- package/dist/api.js.map +1 -1
- package/dist/index.js +24 -17
- package/dist/index.js.map +1 -1
- package/dist/tools/accounts.js +1 -1
- package/dist/tools/accounts.js.map +1 -1
- package/dist/tools/ai.d.ts.map +1 -1
- package/dist/tools/ai.js +7 -1
- package/dist/tools/ai.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +25 -6
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/backups.d.ts.map +1 -1
- package/dist/tools/backups.js +3 -1
- package/dist/tools/backups.js.map +1 -1
- package/dist/tools/build-logs.d.ts.map +1 -1
- package/dist/tools/build-logs.js +3 -1
- package/dist/tools/build-logs.js.map +1 -1
- package/dist/tools/credentials-reveal.d.ts.map +1 -1
- package/dist/tools/credentials-reveal.js +3 -1
- package/dist/tools/credentials-reveal.js.map +1 -1
- package/dist/tools/dailey-images.js +3 -3
- package/dist/tools/dailey-images.js.map +1 -1
- package/dist/tools/db-migrate.js +5 -5
- package/dist/tools/db-migrate.js.map +1 -1
- package/dist/tools/db.d.ts.map +1 -1
- package/dist/tools/db.js +17 -1
- package/dist/tools/db.js.map +1 -1
- package/dist/tools/deploy-status.d.ts.map +1 -1
- package/dist/tools/deploy-status.js +3 -1
- package/dist/tools/deploy-status.js.map +1 -1
- package/dist/tools/deploy.d.ts.map +1 -1
- package/dist/tools/deploy.js +9 -1
- package/dist/tools/deploy.js.map +1 -1
- package/dist/tools/domains.d.ts.map +1 -1
- package/dist/tools/domains.js +3 -1
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/email.d.ts.map +1 -1
- package/dist/tools/email.js +7 -1
- package/dist/tools/email.js.map +1 -1
- package/dist/tools/env.d.ts.map +1 -1
- package/dist/tools/env.js +5 -1
- package/dist/tools/env.js.map +1 -1
- package/dist/tools/environments.js +3 -3
- package/dist/tools/environments.js.map +1 -1
- package/dist/tools/exec-run.d.ts.map +1 -1
- package/dist/tools/exec-run.js +7 -1
- package/dist/tools/exec-run.js.map +1 -1
- package/dist/tools/images.d.ts.map +1 -1
- package/dist/tools/images.js +5 -1
- package/dist/tools/images.js.map +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/lifecycle.js +5 -1
- package/dist/tools/lifecycle.js.map +1 -1
- package/dist/tools/links.d.ts.map +1 -1
- package/dist/tools/links.js +3 -1
- package/dist/tools/links.js.map +1 -1
- package/dist/tools/platform.d.ts.map +1 -1
- package/dist/tools/platform.js +3 -1
- package/dist/tools/platform.js.map +1 -1
- package/dist/tools/processes.d.ts.map +1 -1
- package/dist/tools/processes.js +11 -1
- package/dist/tools/processes.js.map +1 -1
- package/dist/tools/projects.d.ts.map +1 -1
- package/dist/tools/projects.js +36 -12
- package/dist/tools/projects.js.map +1 -1
- package/dist/tools/resource-config.d.ts.map +1 -1
- package/dist/tools/resource-config.js +3 -1
- package/dist/tools/resource-config.js.map +1 -1
- package/dist/tools/scale.d.ts.map +1 -1
- package/dist/tools/scale.js +3 -1
- package/dist/tools/scale.js.map +1 -1
- package/dist/tools/storage.d.ts.map +1 -1
- package/dist/tools/storage.js +11 -1
- package/dist/tools/storage.js.map +1 -1
- package/dist/tools/support.d.ts.map +1 -1
- package/dist/tools/support.js +3 -1
- package/dist/tools/support.js.map +1 -1
- package/dist/tools/usage.d.ts.map +1 -1
- package/dist/tools/usage.js +3 -1
- package/dist/tools/usage.js.map +1 -1
- package/dist/tools/wordpress-import.d.ts.map +1 -1
- package/dist/tools/wordpress-import.js +3 -1
- package/dist/tools/wordpress-import.js.map +1 -1
- package/dist/tools/wordpress-migrate.d.ts.map +1 -1
- package/dist/tools/wordpress-migrate.js +3 -1
- package/dist/tools/wordpress-migrate.js.map +1 -1
- package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
- package/dist/tools/wordpress-snapshot.js +9 -1
- package/dist/tools/wordpress-snapshot.js.map +1 -1
- package/package.json +4 -1
- package/.dockerignore +0 -6
- package/.github/workflows/publish.yml +0 -120
- package/Dockerfile +0 -19
- package/claude-config.json +0 -13
- package/docs/superpowers/plans/2026-08-09-remote-mcp-endpoint.md +0 -663
- package/docs/superpowers/specs/2026-08-09-remote-mcp-endpoint-design.md +0 -66
- package/src/api.ts +0 -263
- package/src/context.ts +0 -12
- package/src/http.ts +0 -160
- package/src/index.ts +0 -94
- package/src/server.ts +0 -188
- package/src/tools/accounts.ts +0 -119
- package/src/tools/addons.ts +0 -124
- package/src/tools/admin.ts +0 -42
- package/src/tools/ai.ts +0 -83
- package/src/tools/analyze.ts +0 -108
- package/src/tools/auth.ts +0 -177
- package/src/tools/backups.ts +0 -84
- package/src/tools/billing.ts +0 -34
- package/src/tools/build-logs.ts +0 -65
- package/src/tools/bundle.ts +0 -129
- package/src/tools/cli.ts +0 -76
- package/src/tools/credentials-reveal.ts +0 -64
- package/src/tools/credits.ts +0 -97
- package/src/tools/dailey-images.ts +0 -151
- package/src/tools/db-migrate.ts +0 -211
- package/src/tools/db.ts +0 -391
- package/src/tools/deploy-status.ts +0 -247
- package/src/tools/deploy.ts +0 -101
- package/src/tools/diagnose.ts +0 -567
- package/src/tools/domains.ts +0 -156
- package/src/tools/email.ts +0 -101
- package/src/tools/env.ts +0 -205
- package/src/tools/environments.ts +0 -138
- package/src/tools/exec-run.ts +0 -91
- package/src/tools/images.ts +0 -221
- package/src/tools/lifecycle.ts +0 -75
- package/src/tools/links.ts +0 -69
- package/src/tools/platform.ts +0 -209
- package/src/tools/processes.ts +0 -182
- package/src/tools/project-transfer.ts +0 -129
- package/src/tools/projects.ts +0 -287
- package/src/tools/resource-config.ts +0 -84
- package/src/tools/scale.ts +0 -33
- package/src/tools/storage.ts +0 -281
- package/src/tools/support.ts +0 -42
- package/src/tools/usage.ts +0 -128
- package/src/tools/wordpress-import.ts +0 -174
- package/src/tools/wordpress-live-edit.ts +0 -250
- package/src/tools/wordpress-migrate.ts +0 -104
- package/src/tools/wordpress-snapshot.ts +0 -225
- package/src/tools/wordpress-targeting.ts +0 -188
- package/src/upload.ts +0 -35
- package/src/version.ts +0 -70
- package/test/context.test.ts +0 -36
- package/test/http.test.ts +0 -103
- package/test/server-surface.test.ts +0 -36
- package/test/use-account-sticky.test.ts +0 -28
- package/test/wordpress-import.test.ts +0 -223
- package/test/wordpress-live-edit.test.ts +0 -159
- package/test/wordpress-targeting.test.ts +0 -162
- package/tests/dailey-images.test.mjs +0 -156
- package/tests/environments.test.mjs +0 -230
- package/tests/mcp-protocol-smoke.mjs +0 -149
- package/tests/new-tools-smoke.mjs +0 -217
- package/tests/pack1-mcp-preflight.test.mjs +0 -184
- package/tests/pack6-smoke.mjs +0 -222
- package/tests/wp-snapshot-labels.test.mjs +0 -21
- package/tests/wp-snapshot.test.mjs +0 -261
- package/tsconfig.json +0 -19
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import {
|
|
4
|
-
apiRequest,
|
|
5
|
-
formatError,
|
|
6
|
-
textResult,
|
|
7
|
-
getActiveAccount,
|
|
8
|
-
setActiveAccount,
|
|
9
|
-
} from '../api.js';
|
|
10
|
-
|
|
11
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
-
// WordPress "live-edit" tools — thin MCP wrappers over the tenant-scoped
|
|
13
|
-
// customer-api live-edit routes (paired PR customer-api#18). Everything here
|
|
14
|
-
// lives under POST /projects/:id/wp/{files,media,cli}/…
|
|
15
|
-
//
|
|
16
|
-
// SAFETY MODEL (two-phase confirm). The mutating server routes are two-phase:
|
|
17
|
-
// 1. Request WITHOUT confirm_token → the server returns a PREVIEW:
|
|
18
|
-
// { preview:true, confirm_token, identity:{project_id,slug,domain,env,
|
|
19
|
-
// db_name,namespace}, change }
|
|
20
|
-
// It does NOT mutate. The `identity` echo tells you exactly which
|
|
21
|
-
// domain / database / environment you are about to touch.
|
|
22
|
-
// 2. Request WITH that confirm_token → the server executes (snapshot-first).
|
|
23
|
-
//
|
|
24
|
-
// These tools NEVER fabricate or auto-pass a confirm_token. The token must come
|
|
25
|
-
// back from a real server preview; the tool only relays it on the second call.
|
|
26
|
-
// The model is instructed (in each description) to show the preview to the user
|
|
27
|
-
// and confirm the target before re-calling with the token.
|
|
28
|
-
//
|
|
29
|
-
// NOTE: these consume customer-api#18's routes and 404 until that PR is deployed
|
|
30
|
-
// (both merge in the same change window).
|
|
31
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
32
|
-
|
|
33
|
-
// The targeting identity the server echoes on a preview so the model/user can
|
|
34
|
-
// confirm the exact site before a mutation proceeds.
|
|
35
|
-
interface Identity {
|
|
36
|
-
project_id?: string;
|
|
37
|
-
slug?: string;
|
|
38
|
-
domain?: string;
|
|
39
|
-
env?: string;
|
|
40
|
-
db_name?: string;
|
|
41
|
-
namespace?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// A two-phase preview envelope (no mutation happened yet).
|
|
45
|
-
interface PreviewEnvelope {
|
|
46
|
-
preview: true;
|
|
47
|
-
confirm_token: string;
|
|
48
|
-
identity?: Identity;
|
|
49
|
-
change?: unknown;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function isPreview(data: unknown): data is PreviewEnvelope {
|
|
53
|
-
return typeof data === 'object' && data !== null && (data as { preview?: unknown }).preview === true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// If the caller passed an explicit `account`, adopt it as the acting-as target
|
|
57
|
-
// for this session (same mechanism as dailey_use_account — sends X-Dailey-Account
|
|
58
|
-
// on every subsequent request). Returns the EFFECTIVE account so every tool
|
|
59
|
-
// result can surface it and targeting is never ambiguous.
|
|
60
|
-
function scopeAccount(account?: string): string | null {
|
|
61
|
-
if (account && account.trim()) {
|
|
62
|
-
setActiveAccount(account.trim());
|
|
63
|
-
}
|
|
64
|
-
return getActiveAccount() ?? null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Render a two-phase preview prominently: the identity echo (domain/db/env) plus
|
|
68
|
-
// the pending change and the confirm_token to relay back verbatim.
|
|
69
|
-
function renderPreview(activeAccount: string | null, env: PreviewEnvelope, toolHint: string): string {
|
|
70
|
-
const id = env.identity ?? {};
|
|
71
|
-
const lines: string[] = [
|
|
72
|
-
'PREVIEW ONLY — nothing has changed yet. Confirm the target below, then re-call to execute.',
|
|
73
|
-
'',
|
|
74
|
-
`Active account: ${activeAccount ?? 'self'}`,
|
|
75
|
-
`Domain: ${id.domain ?? '(unknown)'}`,
|
|
76
|
-
`Database: ${id.db_name ?? '(unknown)'}`,
|
|
77
|
-
`Environment: ${id.env ?? '(unknown)'}`,
|
|
78
|
-
`Project: ${id.project_id ?? '(unknown)'}${id.slug ? ` (${id.slug})` : ''}`,
|
|
79
|
-
`Namespace: ${id.namespace ?? '(unknown)'}`,
|
|
80
|
-
'',
|
|
81
|
-
'Pending change:',
|
|
82
|
-
JSON.stringify(env.change ?? {}, null, 2),
|
|
83
|
-
'',
|
|
84
|
-
`confirm_token: ${env.confirm_token}`,
|
|
85
|
-
'',
|
|
86
|
-
toolHint,
|
|
87
|
-
'Do NOT invent a confirm_token — only relay the exact one above, and only after the user confirms this is the right site.',
|
|
88
|
-
];
|
|
89
|
-
return lines.join('\n');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Merge the effective account (and any identity echo the server included) onto a
|
|
93
|
-
// non-preview result so every result surfaces which account/site was acted on.
|
|
94
|
-
function renderResult(activeAccount: string | null, data: unknown): string {
|
|
95
|
-
const base: Record<string, unknown> = { active_account: activeAccount ?? 'self' };
|
|
96
|
-
if (typeof data === 'object' && data !== null) {
|
|
97
|
-
Object.assign(base, data as Record<string, unknown>);
|
|
98
|
-
} else {
|
|
99
|
-
base.result = data;
|
|
100
|
-
}
|
|
101
|
-
return JSON.stringify(base, null, 2);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function registerWordPressLiveEditTools(server: McpServer) {
|
|
105
|
-
// ── Tool 1 — files: list / read / write / delete ─────────────────────────
|
|
106
|
-
server.tool(
|
|
107
|
-
'dailey_wp_files',
|
|
108
|
-
[
|
|
109
|
-
'Browse and edit the files of a live WordPress site (wp-content: themes, plugins, uploads).',
|
|
110
|
-
'action="list" (path optional) and action="read" (path required) run immediately and are read-only.',
|
|
111
|
-
'action="write" (path + content, optional encoding "utf8"|"base64") and action="delete" (path) are MUTATING and two-phase:',
|
|
112
|
-
' 1) Call WITHOUT confirm_token first — the server returns a PREVIEW that echoes the target domain, db_name, env, and the exact change (it does NOT modify anything).',
|
|
113
|
-
' 2) SHOW that preview to the user, confirm it is the right site, then call AGAIN with the SAME args plus the confirm_token returned by the preview to execute (the server takes a snapshot first).',
|
|
114
|
-
'Never fabricate a confirm_token — only relay the one a real preview returned. Every result surfaces the active_account and, on mutations, the identity echo (domain/db/env).',
|
|
115
|
-
'Consumes customer-api#18 routes; 404s until that ships (same change window).',
|
|
116
|
-
].join('\n'),
|
|
117
|
-
{
|
|
118
|
-
project: z.string().describe('The WordPress project — its id (or slug/ref the server can resolve)'),
|
|
119
|
-
action: z.enum(['list', 'read', 'write', 'delete']).describe('list (read-only), read (read-only), write (mutating, two-phase), delete (mutating, two-phase)'),
|
|
120
|
-
path: z.string().optional().describe('Path within wp-content. Optional for list (defaults to root); required for read/write/delete.'),
|
|
121
|
-
content: z.string().optional().describe('File content for action="write" (interpret per `encoding`).'),
|
|
122
|
-
encoding: z.enum(['utf8', 'base64']).optional().describe('Encoding of `content` for write; defaults to utf8.'),
|
|
123
|
-
confirm_token: z.string().optional().describe('Two-phase confirm token for write/delete. Omit on the first call to get the preview; on the second call pass the exact token the preview returned. Never fabricate one.'),
|
|
124
|
-
account: z.string().optional().describe('Acting-as target: slug or id of a managed account (must be in your fleet from dailey_accounts). Scopes this and subsequent calls, like dailey_use_account.'),
|
|
125
|
-
},
|
|
126
|
-
async ({ project, action, path, content, encoding, confirm_token, account }) => {
|
|
127
|
-
const activeAccount = scopeAccount(account);
|
|
128
|
-
const base = `/projects/${encodeURIComponent(project)}/wp/files`;
|
|
129
|
-
|
|
130
|
-
if (action === 'list') {
|
|
131
|
-
const res = await apiRequest('POST', `${base}/list`, path ? { path } : {});
|
|
132
|
-
if (!res.ok) return textResult(formatError(res));
|
|
133
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (action === 'read') {
|
|
137
|
-
if (!path) return textResult('action="read" requires `path`.');
|
|
138
|
-
const res = await apiRequest('POST', `${base}/read`, { path });
|
|
139
|
-
if (!res.ok) return textResult(formatError(res));
|
|
140
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (action === 'write') {
|
|
144
|
-
if (!path) return textResult('action="write" requires `path`.');
|
|
145
|
-
if (content == null) return textResult('action="write" requires `content`.');
|
|
146
|
-
const body: Record<string, unknown> = { path, content };
|
|
147
|
-
if (encoding) body.encoding = encoding;
|
|
148
|
-
if (confirm_token) body.confirm_token = confirm_token;
|
|
149
|
-
const res = await apiRequest('POST', `${base}/write`, body);
|
|
150
|
-
if (!res.ok) return textResult(formatError(res));
|
|
151
|
-
if (isPreview(res.data)) {
|
|
152
|
-
return textResult(renderPreview(activeAccount, res.data, 'To write this file, re-call dailey_wp_files with the same project/path/content and this confirm_token.'));
|
|
153
|
-
}
|
|
154
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// action === 'delete'
|
|
158
|
-
if (!path) return textResult('action="delete" requires `path`.');
|
|
159
|
-
const body: Record<string, unknown> = { path };
|
|
160
|
-
if (confirm_token) body.confirm_token = confirm_token;
|
|
161
|
-
const res = await apiRequest('POST', `${base}/delete`, body);
|
|
162
|
-
if (!res.ok) return textResult(formatError(res));
|
|
163
|
-
if (isPreview(res.data)) {
|
|
164
|
-
return textResult(renderPreview(activeAccount, res.data, 'To delete this file, re-call dailey_wp_files with the same project/path and this confirm_token.'));
|
|
165
|
-
}
|
|
166
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
167
|
-
},
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
// ── Tool 2 — media: list / upload ────────────────────────────────────────
|
|
171
|
-
server.tool(
|
|
172
|
-
'dailey_wp_media',
|
|
173
|
-
[
|
|
174
|
-
'List or upload media in a live WordPress site\'s uploads directory.',
|
|
175
|
-
'action="list" (path optional) runs immediately and is read-only.',
|
|
176
|
-
'action="upload" (filename + content_base64, optional import to register it in the WP media library) is MUTATING and two-phase:',
|
|
177
|
-
' 1) Call WITHOUT confirm_token first — the server returns a PREVIEW echoing the target domain, db_name, env and the pending change (nothing is written yet).',
|
|
178
|
-
' 2) SHOW the preview, confirm the site, then call AGAIN with the same args plus the returned confirm_token to execute (snapshot-first).',
|
|
179
|
-
'Never fabricate a confirm_token — only relay one a real preview returned. Every result surfaces the active_account and, on mutations, the identity echo.',
|
|
180
|
-
'Consumes customer-api#18 routes; 404s until that ships (same change window).',
|
|
181
|
-
].join('\n'),
|
|
182
|
-
{
|
|
183
|
-
project: z.string().describe('The WordPress project — its id (or slug/ref the server can resolve)'),
|
|
184
|
-
action: z.enum(['list', 'upload']).describe('list (read-only) or upload (mutating, two-phase)'),
|
|
185
|
-
path: z.string().optional().describe('Subpath within uploads for action="list" (defaults to root).'),
|
|
186
|
-
filename: z.string().optional().describe('Destination filename for action="upload".'),
|
|
187
|
-
content_base64: z.string().optional().describe('Base64-encoded file bytes for action="upload".'),
|
|
188
|
-
import: z.boolean().optional().describe('If true, register the uploaded file in the WordPress media library (not just drop it on disk).'),
|
|
189
|
-
confirm_token: z.string().optional().describe('Two-phase confirm token for upload. Omit on the first call to get the preview; pass the exact token the preview returned on the second call. Never fabricate one.'),
|
|
190
|
-
account: z.string().optional().describe('Acting-as target: slug or id of a managed account (must be in your fleet). Scopes this and subsequent calls, like dailey_use_account.'),
|
|
191
|
-
},
|
|
192
|
-
async ({ project, action, path, filename, content_base64, import: importFlag, confirm_token, account }) => {
|
|
193
|
-
const activeAccount = scopeAccount(account);
|
|
194
|
-
const base = `/projects/${encodeURIComponent(project)}/wp/media`;
|
|
195
|
-
|
|
196
|
-
if (action === 'list') {
|
|
197
|
-
const res = await apiRequest('POST', `${base}/list`, path ? { path } : {});
|
|
198
|
-
if (!res.ok) return textResult(formatError(res));
|
|
199
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// action === 'upload'
|
|
203
|
-
if (!filename) return textResult('action="upload" requires `filename`.');
|
|
204
|
-
if (content_base64 == null) return textResult('action="upload" requires `content_base64`.');
|
|
205
|
-
const body: Record<string, unknown> = { filename, content_base64 };
|
|
206
|
-
if (importFlag != null) body.import = importFlag;
|
|
207
|
-
if (confirm_token) body.confirm_token = confirm_token;
|
|
208
|
-
const res = await apiRequest('POST', `${base}/upload`, body);
|
|
209
|
-
if (!res.ok) return textResult(formatError(res));
|
|
210
|
-
if (isPreview(res.data)) {
|
|
211
|
-
return textResult(renderPreview(activeAccount, res.data, 'To upload this media, re-call dailey_wp_media with the same project/filename/content_base64 and this confirm_token.'));
|
|
212
|
-
}
|
|
213
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
214
|
-
},
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
// ── Tool 3 — wp-cli passthrough ──────────────────────────────────────────
|
|
218
|
-
server.tool(
|
|
219
|
-
'dailey_wp_cli',
|
|
220
|
-
[
|
|
221
|
-
'Run a wp-cli command against a live WordPress site. `args` is the argv array passed straight through (e.g. ["option","get","siteurl"] or ["post","list","--format=json"]).',
|
|
222
|
-
'Read-only commands (e.g. `option get`, `post list`, `plugin list`) run immediately and return stdout/stderr/exit_code.',
|
|
223
|
-
'Write commands require allow_write:true AND the two-phase confirm:',
|
|
224
|
-
' 1) Call with allow_write:true but WITHOUT confirm_token — the server returns a PREVIEW echoing the target domain/db/env and the pending change (it does NOT run the write).',
|
|
225
|
-
' 2) SHOW the preview, confirm the site, then call AGAIN with the same args + allow_write:true + the returned confirm_token to execute (snapshot-first).',
|
|
226
|
-
'The server enforces an allow-list and REFUSES anything outside it — no `config`, `core`, `eval`, `search-replace`, or `db import/export`. Never fabricate a confirm_token. Results surface the active_account (and identity echo on writes).',
|
|
227
|
-
'Consumes customer-api#18 routes; 404s until that ships (same change window).',
|
|
228
|
-
].join('\n'),
|
|
229
|
-
{
|
|
230
|
-
project: z.string().describe('The WordPress project — its id (or slug/ref the server can resolve)'),
|
|
231
|
-
args: z.array(z.string()).describe('wp-cli argv, passed straight through. The server enforces the allow-list.'),
|
|
232
|
-
allow_write: z.boolean().optional().describe('Required (true) for any write command; the server also gates writes by its allow-list. Read-only commands do not need this.'),
|
|
233
|
-
confirm_token: z.string().optional().describe('Two-phase confirm token for writes. Omit on the first call to get the preview; pass the exact token the preview returned on the second call. Never fabricate one.'),
|
|
234
|
-
account: z.string().optional().describe('Acting-as target: slug or id of a managed account (must be in your fleet). Scopes this and subsequent calls, like dailey_use_account.'),
|
|
235
|
-
},
|
|
236
|
-
async ({ project, args, allow_write, confirm_token, account }) => {
|
|
237
|
-
const activeAccount = scopeAccount(account);
|
|
238
|
-
const body: Record<string, unknown> = { args };
|
|
239
|
-
if (allow_write != null) body.allow_write = allow_write;
|
|
240
|
-
if (confirm_token) body.confirm_token = confirm_token;
|
|
241
|
-
|
|
242
|
-
const res = await apiRequest('POST', `/projects/${encodeURIComponent(project)}/wp/cli`, body);
|
|
243
|
-
if (!res.ok) return textResult(formatError(res));
|
|
244
|
-
if (isPreview(res.data)) {
|
|
245
|
-
return textResult(renderPreview(activeAccount, res.data, 'To run this write command, re-call dailey_wp_cli with the same args + allow_write:true and this confirm_token.'));
|
|
246
|
-
}
|
|
247
|
-
return textResult(renderResult(activeAccount, res.data));
|
|
248
|
-
},
|
|
249
|
-
);
|
|
250
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { basename } from 'node:path';
|
|
5
|
-
import { apiRequest, formatError, textResult } from '../api.js';
|
|
6
|
-
import { putFileToPresignedUrl } from '../upload.js';
|
|
7
|
-
|
|
8
|
-
interface StartResponse {
|
|
9
|
-
migration_id: string;
|
|
10
|
-
db_upload: { url: string; key: string; headers: Record<string, string>; max_bytes: number };
|
|
11
|
-
content_upload: { url: string; key: string; headers: Record<string, string>; max_bytes: number };
|
|
12
|
-
warning?: string;
|
|
13
|
-
}
|
|
14
|
-
interface RunResponse { ok: boolean; migration_id: string; new_url: string }
|
|
15
|
-
interface StatusResponse { status: string; step?: string; error?: string; log_tail?: string; finished_at?: string }
|
|
16
|
-
interface ScanFinding { level: string; code: string; message: string }
|
|
17
|
-
interface ScanResponse { ok: boolean; verdict: 'clean' | 'warn' | 'blocked'; findings: ScanFinding[] }
|
|
18
|
-
|
|
19
|
-
export function registerWordPressMigrateTools(server: McpServer) {
|
|
20
|
-
server.tool(
|
|
21
|
-
'dailey_wordpress_migrate',
|
|
22
|
-
'Migrate an existing WordPress site (from any host) onto Dailey OS, intact. action=migrate uploads a MySQL dump (.sql/.sql.gz) + a wp-content archive (.tar.gz/.zip) from local paths, then runs the import (DB import, serialized-safe URL rewrite, wp-content swap) and reports the final status. WARNING: replaces the target project\'s database and wp-content. action=status checks a previous migration.',
|
|
23
|
-
{
|
|
24
|
-
project_id: z.string().describe('Target project ID (must be a WordPress project with a MySQL DB + volume)'),
|
|
25
|
-
action: z.enum(['migrate', 'status']).describe('migrate = full flow (upload + run + wait) | status = check a migration'),
|
|
26
|
-
db_file: z.string().optional().describe('Local path to the MySQL dump (.sql or .sql.gz) — required for migrate'),
|
|
27
|
-
content_file: z.string().optional().describe('Local path to the wp-content archive (.tar.gz/.tgz/.zip) — required for migrate'),
|
|
28
|
-
old_url: z.string().optional().describe('The site\'s current URL, e.g. https://oldsite.com — required for migrate'),
|
|
29
|
-
table_prefix: z.string().optional().describe('Table prefix if not wp_'),
|
|
30
|
-
allow_unsafe: z.boolean().optional().describe('Proceed even if the pre-migrate scan reports a blocked verdict (non-malware only)'),
|
|
31
|
-
migration_id: z.string().optional().describe('Migration ID — required for status'),
|
|
32
|
-
},
|
|
33
|
-
async ({ project_id, action, db_file, content_file, old_url, table_prefix, allow_unsafe, migration_id }) => {
|
|
34
|
-
if (action === 'status') {
|
|
35
|
-
if (!migration_id) return textResult('migration_id is required for action=status');
|
|
36
|
-
const res = await apiRequest<StatusResponse>('GET', `/projects/${project_id}/migrate/wordpress/${migration_id}`);
|
|
37
|
-
if (!res.ok) return textResult(formatError(res));
|
|
38
|
-
const s = res.data;
|
|
39
|
-
return textResult(`Migration ${migration_id}: ${s.status}${s.step ? ` (step: ${s.step})` : ''}${s.error ? `\nError: ${s.error}` : ''}${s.log_tail ? `\n--- log ---\n${s.log_tail}` : ''}`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// action === 'migrate'
|
|
43
|
-
if (!db_file || !content_file || !old_url) {
|
|
44
|
-
return textResult('db_file, content_file, and old_url are required for action=migrate');
|
|
45
|
-
}
|
|
46
|
-
for (const f of [db_file, content_file]) {
|
|
47
|
-
if (!existsSync(f)) return textResult(`File not found: ${f}`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const start = await apiRequest<StartResponse>('POST', `/projects/${project_id}/migrate/wordpress`, {
|
|
51
|
-
db_filename: basename(db_file),
|
|
52
|
-
content_filename: basename(content_file),
|
|
53
|
-
});
|
|
54
|
-
if (!start.ok) return textResult(formatError(start));
|
|
55
|
-
const { migration_id: mid, db_upload, content_upload } = start.data;
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
await putFileToPresignedUrl(db_upload.url, db_file, db_upload.headers);
|
|
59
|
-
await putFileToPresignedUrl(content_upload.url, content_file, content_upload.headers);
|
|
60
|
-
} catch (e: unknown) {
|
|
61
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
62
|
-
return textResult(`Upload failed: ${message}\nMigration ${mid} is still pending — fix the file and call migrate again (a new migration will be started).`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Pre-migrate scan is REQUIRED server-side before /run (returns 409
|
|
66
|
-
// scan_required otherwise). Without this, migrate fails at launch and
|
|
67
|
-
// leaves a pending migration lock on the project.
|
|
68
|
-
const scan = await apiRequest<ScanResponse>('POST', `/projects/${project_id}/migrate/wordpress/${mid}/scan`, {
|
|
69
|
-
allow_unsafe: Boolean(allow_unsafe),
|
|
70
|
-
});
|
|
71
|
-
if (scan.status === 409) {
|
|
72
|
-
const findings = (scan.data as ScanResponse | undefined)?.findings ?? [];
|
|
73
|
-
const list = findings.length ? findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}`).join('\n') : ' (no findings detail returned)';
|
|
74
|
-
return textResult(`Refusing to run: server-side scan gate is BLOCKED.\n${list}\nMigration ${mid} is still pending — pass allow_unsafe=true to override (logged) and call migrate again.`);
|
|
75
|
-
}
|
|
76
|
-
if (!scan.ok) return textResult(formatError(scan));
|
|
77
|
-
|
|
78
|
-
const run = await apiRequest<RunResponse>('POST', `/projects/${project_id}/migrate/wordpress/${mid}/run`, {
|
|
79
|
-
old_url, ...(table_prefix ? { table_prefix } : {}),
|
|
80
|
-
});
|
|
81
|
-
if (!run.ok) return textResult(formatError(run));
|
|
82
|
-
|
|
83
|
-
// Poll to terminal state (up to ~10 min; migrations are usually 1-3 min).
|
|
84
|
-
const started = Date.now();
|
|
85
|
-
let last: StatusResponse | null = null;
|
|
86
|
-
while (Date.now() - started < 10 * 60 * 1000) {
|
|
87
|
-
await new Promise((r) => setTimeout(r, 5000));
|
|
88
|
-
const st = await apiRequest<StatusResponse>('GET', `/projects/${project_id}/migrate/wordpress/${mid}`);
|
|
89
|
-
if (st.ok) {
|
|
90
|
-
last = st.data;
|
|
91
|
-
if (last.status === 'succeeded' || last.status === 'failed') break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (!last) return textResult(`Migration ${mid} launched but status could not be read. Check later with action=status.`);
|
|
95
|
-
if (last.status === 'succeeded') {
|
|
96
|
-
return textResult(`Migration succeeded. Site is live at ${run.data.new_url} with the imported content.\nNote: hard-refresh and re-save permalinks (Settings > Permalinks) if pretty URLs 404.`);
|
|
97
|
-
}
|
|
98
|
-
if (last.status === 'failed') {
|
|
99
|
-
return textResult(`Migration FAILED at step: ${last.step ?? 'unknown'}\n${last.error ?? ''}\n--- log ---\n${last.log_tail ?? ''}\nYour staged files were kept — fix the issue and run migrate again.`);
|
|
100
|
-
}
|
|
101
|
-
return textResult(`Migration ${mid} still ${last.status} (step: ${last.step ?? '-'}) after 10 min — check again with action=status migration_id=${mid}.`);
|
|
102
|
-
},
|
|
103
|
-
);
|
|
104
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { apiRequest, textResult, jsonResult, formatError } from '../api.js';
|
|
4
|
-
|
|
5
|
-
interface Snapshot {
|
|
6
|
-
id: string;
|
|
7
|
-
created_at: string;
|
|
8
|
-
kind: string;
|
|
9
|
-
status: string;
|
|
10
|
-
env?: string;
|
|
11
|
-
reason?: string;
|
|
12
|
-
label?: string | null;
|
|
13
|
-
db_bytes?: number;
|
|
14
|
-
uploads_bytes?: number;
|
|
15
|
-
content_bytes?: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface SnapshotsResponse {
|
|
19
|
-
snapshots: Snapshot[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface SnapshotStartResponse {
|
|
23
|
-
operation_id: string;
|
|
24
|
-
status_url?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface RestorePreviewPlan {
|
|
28
|
-
steps: string[];
|
|
29
|
-
backupFirst?: boolean;
|
|
30
|
-
sourceLabel?: string;
|
|
31
|
-
targetLabel?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface RestorePreviewResponse {
|
|
35
|
-
plan: RestorePreviewPlan;
|
|
36
|
-
confirm_token: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface RestoreExecuteResponse {
|
|
40
|
-
operation_id: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface Operation {
|
|
44
|
-
id: string;
|
|
45
|
-
type?: string;
|
|
46
|
-
status?: string;
|
|
47
|
-
current_step?: string;
|
|
48
|
-
verify?: unknown;
|
|
49
|
-
error?: string;
|
|
50
|
-
backup_snapshot_id?: string;
|
|
51
|
-
step_log?: string[];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface OperationResponse {
|
|
55
|
-
operation: Operation;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function fmtBytes(bytes?: number): string {
|
|
59
|
-
if (bytes == null) return '-';
|
|
60
|
-
if (bytes < 1024) return `${bytes}B`;
|
|
61
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
|
|
62
|
-
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
63
|
-
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)}GB`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function registerWordPressSnapshotTools(server: McpServer) {
|
|
67
|
-
server.tool(
|
|
68
|
-
'dailey_wp_snapshots',
|
|
69
|
-
'List WordPress snapshots for a project',
|
|
70
|
-
{
|
|
71
|
-
project_id: z.string().describe('The project ID'),
|
|
72
|
-
},
|
|
73
|
-
async ({ project_id }) => {
|
|
74
|
-
const res = await apiRequest<SnapshotsResponse>('GET', `/projects/${project_id}/wp/snapshots`);
|
|
75
|
-
if (!res.ok) return textResult(formatError(res));
|
|
76
|
-
|
|
77
|
-
const snapshots = res.data.snapshots;
|
|
78
|
-
if (!snapshots || snapshots.length === 0) {
|
|
79
|
-
return textResult('No snapshots found for this project.');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const lines = [
|
|
83
|
-
`Snapshots for project ${project_id}`,
|
|
84
|
-
`${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Reason'.padEnd(10)} ${'Label'.padEnd(24)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Content`,
|
|
85
|
-
'─'.repeat(115),
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
for (const s of snapshots) {
|
|
89
|
-
lines.push(
|
|
90
|
-
`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.reason || 'manual').padEnd(10)} ${((s.label ?? '').slice(0, 24) || '—').padEnd(24)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.content_bytes ?? s.uploads_bytes)}`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return textResult(lines.join('\n'));
|
|
95
|
-
},
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
server.tool(
|
|
99
|
-
'dailey_wp_snapshot',
|
|
100
|
-
'Create a snapshot (DB + uploads) of a WordPress project',
|
|
101
|
-
{
|
|
102
|
-
project_id: z.string().describe('The project ID'),
|
|
103
|
-
label: z.string().optional().describe('Optional human label; labeled points are kept until deleted (never auto-expire)'),
|
|
104
|
-
},
|
|
105
|
-
async ({ project_id, label }) => {
|
|
106
|
-
const res = await apiRequest<SnapshotStartResponse>('POST', `/projects/${project_id}/wp/snapshot`, label ? { label } : undefined);
|
|
107
|
-
if (!res.ok) return textResult(formatError(res));
|
|
108
|
-
|
|
109
|
-
const { operation_id } = res.data;
|
|
110
|
-
return textResult(
|
|
111
|
-
`Snapshot started. operation_id=${operation_id}. Poll with dailey_wp_operation_status (project_id, operation_id).`,
|
|
112
|
-
);
|
|
113
|
-
},
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
server.tool(
|
|
117
|
-
'dailey_wp_restore',
|
|
118
|
-
'Restore a WordPress project from a snapshot (DESTRUCTIVE — two-phase). Call WITHOUT confirm_token to get the plan; re-call WITH the returned confirm_token to execute.',
|
|
119
|
-
{
|
|
120
|
-
project_id: z.string().describe('The project ID'),
|
|
121
|
-
snapshot_id: z.string().describe('The snapshot ID to restore'),
|
|
122
|
-
confirm_token: z.string().optional().describe(
|
|
123
|
-
'Token from the plan response. Omit to preview the plan; provide to execute. Bound to this project+snapshot, ~10min TTL.',
|
|
124
|
-
),
|
|
125
|
-
},
|
|
126
|
-
async ({ project_id, snapshot_id, confirm_token }) => {
|
|
127
|
-
if (!confirm_token) {
|
|
128
|
-
// Phase 1: preview
|
|
129
|
-
const res = await apiRequest<RestorePreviewResponse>(
|
|
130
|
-
'POST',
|
|
131
|
-
`/projects/${project_id}/wp/restore/preview`,
|
|
132
|
-
{ snapshot_id },
|
|
133
|
-
);
|
|
134
|
-
if (!res.ok) return textResult(formatError(res));
|
|
135
|
-
|
|
136
|
-
const { plan, confirm_token: token } = res.data;
|
|
137
|
-
const lines: string[] = [];
|
|
138
|
-
|
|
139
|
-
if (plan.sourceLabel || plan.targetLabel) {
|
|
140
|
-
lines.push(`Restore plan: ${plan.sourceLabel ?? snapshot_id} → ${plan.targetLabel ?? 'this project'}`);
|
|
141
|
-
} else {
|
|
142
|
-
lines.push(`Restore plan for snapshot ${snapshot_id}:`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (plan.backupFirst) {
|
|
146
|
-
lines.push('• Backs up the target first as a rollback point.');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (plan.steps && plan.steps.length > 0) {
|
|
150
|
-
lines.push('');
|
|
151
|
-
lines.push('Steps:');
|
|
152
|
-
plan.steps.forEach((step, i) => {
|
|
153
|
-
lines.push(` ${i + 1}. ${step}`);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
lines.push('');
|
|
158
|
-
lines.push(`confirm_token: ${token}`);
|
|
159
|
-
lines.push('');
|
|
160
|
-
lines.push(
|
|
161
|
-
'This is destructive. To proceed, re-call dailey_wp_restore with the same project_id + snapshot_id and this confirm_token.',
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
return textResult(lines.join('\n'));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Phase 2: execute
|
|
168
|
-
const res = await apiRequest<RestoreExecuteResponse>(
|
|
169
|
-
'POST',
|
|
170
|
-
`/projects/${project_id}/wp/restore`,
|
|
171
|
-
{ snapshot_id, confirm_token, confirmation: 'RESTORE' },
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
if (!res.ok) {
|
|
175
|
-
if (res.status === 409) {
|
|
176
|
-
return textResult('A restore is already in progress for this project.');
|
|
177
|
-
}
|
|
178
|
-
// 400 (expired/invalid token) — surface the message
|
|
179
|
-
return textResult(formatError(res));
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const { operation_id } = res.data;
|
|
183
|
-
return textResult(
|
|
184
|
-
`Restore started. operation_id=${operation_id}. Poll with dailey_wp_operation_status.`,
|
|
185
|
-
);
|
|
186
|
-
},
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
server.tool(
|
|
190
|
-
'dailey_wp_operation_status',
|
|
191
|
-
'Check the status of a WordPress snapshot/restore operation',
|
|
192
|
-
{
|
|
193
|
-
project_id: z.string().describe('The project ID'),
|
|
194
|
-
operation_id: z.string().describe('The operation ID'),
|
|
195
|
-
},
|
|
196
|
-
async ({ project_id, operation_id }) => {
|
|
197
|
-
const res = await apiRequest<OperationResponse>(
|
|
198
|
-
'GET',
|
|
199
|
-
`/projects/${project_id}/wp/operations/${operation_id}`,
|
|
200
|
-
);
|
|
201
|
-
if (!res.ok) return textResult(formatError(res));
|
|
202
|
-
|
|
203
|
-
const op = res.data.operation;
|
|
204
|
-
const lines: string[] = [];
|
|
205
|
-
|
|
206
|
-
if (op.type) lines.push(`Type: ${op.type}`);
|
|
207
|
-
lines.push(`Status: ${op.status ?? '-'}`);
|
|
208
|
-
if (op.current_step) lines.push(`Current step: ${op.current_step}`);
|
|
209
|
-
if (op.verify != null) lines.push(`Verify: ${JSON.stringify(op.verify)}`);
|
|
210
|
-
if (op.error) lines.push(`Error: ${op.error}`);
|
|
211
|
-
if (op.backup_snapshot_id) lines.push(`Backup snapshot ID: ${op.backup_snapshot_id}`);
|
|
212
|
-
|
|
213
|
-
if (op.step_log && op.step_log.length > 0) {
|
|
214
|
-
const tail = op.step_log.slice(-10);
|
|
215
|
-
lines.push('');
|
|
216
|
-
lines.push('Step log (last 10):');
|
|
217
|
-
for (const entry of tail) {
|
|
218
|
-
lines.push(` ${entry}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return textResult(lines.join('\n'));
|
|
223
|
-
},
|
|
224
|
-
);
|
|
225
|
-
}
|