@daileyos/mcp-server 1.21.1 → 1.21.2
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/.dockerignore +6 -0
- package/Dockerfile +19 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +14 -1
- package/dist/api.js.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +6 -0
- package/dist/context.js.map +1 -0
- package/dist/http.d.ts +5 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +193 -0
- package/dist/http.js.map +1 -0
- package/dist/index.js +8 -146
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +165 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/accounts.d.ts +4 -1
- package/dist/tools/accounts.d.ts.map +1 -1
- package/dist/tools/accounts.js +56 -52
- package/dist/tools/accounts.js.map +1 -1
- package/dist/tools/wordpress-targeting.d.ts.map +1 -1
- package/dist/tools/wordpress-targeting.js +22 -7
- package/dist/tools/wordpress-targeting.js.map +1 -1
- package/docs/superpowers/plans/2026-08-09-remote-mcp-endpoint.md +663 -0
- package/docs/superpowers/specs/2026-08-09-remote-mcp-endpoint-design.md +66 -0
- package/package.json +4 -3
- package/src/api.ts +9 -1
- package/src/context.ts +12 -0
- package/src/http.ts +160 -0
- package/src/index.ts +8 -161
- package/src/server.ts +188 -0
- package/src/tools/accounts.ts +69 -61
- package/src/tools/wordpress-targeting.ts +22 -7
- package/test/context.test.ts +36 -0
- package/test/http.test.ts +103 -0
- package/test/server-surface.test.ts +36 -0
- package/test/use-account-sticky.test.ts +28 -0
- package/test/wordpress-targeting.test.ts +36 -1
- package/dist/tools/buddy.d.ts +0 -3
- package/dist/tools/buddy.d.ts.map +0 -1
- package/dist/tools/buddy.js +0 -765
- package/dist/tools/buddy.js.map +0 -1
- package/dist/tools/payments.d.ts +0 -3
- package/dist/tools/payments.d.ts.map +0 -1
- package/dist/tools/payments.js +0 -96
- package/dist/tools/payments.js.map +0 -1
- package/dist/tools/redis.d.ts +0 -3
- package/dist/tools/redis.d.ts.map +0 -1
- package/dist/tools/redis.js +0 -72
- package/dist/tools/redis.js.map +0 -1
package/src/server.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { getActiveAccount, setActiveAccount } from './api.js';
|
|
5
|
+
import { OWN_VERSION } from './version.js';
|
|
6
|
+
import { registerAuthTools } from './tools/auth.js';
|
|
7
|
+
import { registerAccountTools } from './tools/accounts.js';
|
|
8
|
+
import { registerProjectTools } from './tools/projects.js';
|
|
9
|
+
import { registerDeployTools } from './tools/deploy.js';
|
|
10
|
+
import { registerDeployStatusTools } from './tools/deploy-status.js';
|
|
11
|
+
import { registerBuildLogsTools } from './tools/build-logs.js';
|
|
12
|
+
import { registerScaleTools } from './tools/scale.js';
|
|
13
|
+
import { registerEnvTools } from './tools/env.js';
|
|
14
|
+
import { registerDomainTools } from './tools/domains.js';
|
|
15
|
+
import { registerDbTools } from './tools/db.js';
|
|
16
|
+
import { registerMigrateTools } from './tools/db-migrate.js';
|
|
17
|
+
import { registerExecRunTools } from './tools/exec-run.js';
|
|
18
|
+
import { registerProjectTransferTools } from './tools/project-transfer.js';
|
|
19
|
+
import { registerAdminTools } from './tools/admin.js';
|
|
20
|
+
import { registerUsageTools } from './tools/usage.js';
|
|
21
|
+
import { registerBillingTools } from './tools/billing.js';
|
|
22
|
+
import { registerPlatformTools } from './tools/platform.js';
|
|
23
|
+
import { registerStorageTools } from './tools/storage.js';
|
|
24
|
+
import { registerAiTools } from './tools/ai.js';
|
|
25
|
+
import { registerEmailTools } from './tools/email.js';
|
|
26
|
+
import { registerCreditTools } from './tools/credits.js';
|
|
27
|
+
import { registerAddonTools } from './tools/addons.js';
|
|
28
|
+
import { registerDaileyImagesTools } from './tools/dailey-images.js';
|
|
29
|
+
import { registerImageTools } from './tools/images.js';
|
|
30
|
+
import { registerProcessTools } from './tools/processes.js';
|
|
31
|
+
import { registerLifecycleTools } from './tools/lifecycle.js';
|
|
32
|
+
import { registerBackupTools } from './tools/backups.js';
|
|
33
|
+
import { registerWordPressMigrateTools } from './tools/wordpress-migrate.js';
|
|
34
|
+
import { registerWordPressImportTools } from './tools/wordpress-import.js';
|
|
35
|
+
import { registerWordPressSnapshotTools } from './tools/wordpress-snapshot.js';
|
|
36
|
+
import { registerWordPressLiveEditTools } from './tools/wordpress-live-edit.js';
|
|
37
|
+
import { registerWordPressTargetingTools } from './tools/wordpress-targeting.js';
|
|
38
|
+
import { registerEnvironmentTools } from './tools/environments.js';
|
|
39
|
+
import { registerResourceConfigTools } from './tools/resource-config.js';
|
|
40
|
+
import { registerLinkTools } from './tools/links.js';
|
|
41
|
+
import { registerCredentialRevealTools } from './tools/credentials-reveal.js';
|
|
42
|
+
import { registerAnalyzeTools } from './tools/analyze.js';
|
|
43
|
+
import { registerCliTools } from './tools/cli.js';
|
|
44
|
+
import { registerBundleTools } from './tools/bundle.js';
|
|
45
|
+
import { registerDiagnoseTools } from './tools/diagnose.js';
|
|
46
|
+
import { registerSupportTools } from './tools/support.js';
|
|
47
|
+
|
|
48
|
+
export interface BuildOptions {
|
|
49
|
+
includeAdmin: boolean;
|
|
50
|
+
includeLocalAuth: boolean;
|
|
51
|
+
includeAccountSwitch: boolean;
|
|
52
|
+
instructions?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function buildServer(opts: BuildOptions): McpServer {
|
|
56
|
+
const server = new McpServer(
|
|
57
|
+
{
|
|
58
|
+
name: 'dailey-os',
|
|
59
|
+
version: OWN_VERSION,
|
|
60
|
+
},
|
|
61
|
+
opts.instructions ? { instructions: opts.instructions } : undefined,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// ─── Account-context hardening (2026-07-13, Muenda's "which account am I in?") ───
|
|
65
|
+
// Two invariants, applied uniformly to ALL tools via this registration wrapper:
|
|
66
|
+
// 1. Every tool accepts an optional `account` param — a STATELESS, per-call
|
|
67
|
+
// scope to a managed account (set → run → restore). Agents no longer have
|
|
68
|
+
// to rely on dailey_use_account session state being what they remember.
|
|
69
|
+
// 2. Every tool result is prefixed with `[account: <effective>]` so the model
|
|
70
|
+
// (and the human reading the transcript) always sees which account the
|
|
71
|
+
// call actually ran against. Wrong-account work becomes visible instantly.
|
|
72
|
+
// Tools that declare their own `account` param (the WP tools) keep their schema;
|
|
73
|
+
// the wrapper still enforces the per-call set/restore around them.
|
|
74
|
+
{
|
|
75
|
+
const originalTool = server.tool.bind(server);
|
|
76
|
+
// Tools whose PURPOSE is to set the session account must be left alone by
|
|
77
|
+
// the per-call scope wrapper — otherwise the wrapper's finally-restore
|
|
78
|
+
// undoes the switch the moment the call returns (dailey_use_account was
|
|
79
|
+
// silently non-sticky on stdio because of this). Register them raw.
|
|
80
|
+
const SESSION_ACCOUNT_SETTERS = new Set(['dailey_use_account']);
|
|
81
|
+
(server as any).tool = (name: string, description: string, schema: Record<string, unknown>, handler: (...a: any[]) => any) => {
|
|
82
|
+
if (SESSION_ACCOUNT_SETTERS.has(name)) {
|
|
83
|
+
return originalTool(name, description, schema as any, handler);
|
|
84
|
+
}
|
|
85
|
+
const augmented = 'account' in schema
|
|
86
|
+
? schema
|
|
87
|
+
: {
|
|
88
|
+
...schema,
|
|
89
|
+
account: z.string().optional().describe(
|
|
90
|
+
'Managed-account slug to run THIS call against (per-call scope; overrides the dailey_use_account session state for this call only). Omit to use the current session account.',
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
return originalTool(name, description, augmented as any, async (args: any, extra: any) => {
|
|
94
|
+
const requested: string | undefined =
|
|
95
|
+
typeof args?.account === 'string' && args.account.trim() ? args.account.trim() : undefined;
|
|
96
|
+
const prev = getActiveAccount();
|
|
97
|
+
if (requested) setActiveAccount(requested);
|
|
98
|
+
try {
|
|
99
|
+
const result = await handler(args, extra);
|
|
100
|
+
const effective = requested ?? getActiveAccount() ?? 'self (your own account)';
|
|
101
|
+
if (result?.content?.length && result.content[0]?.type === 'text') {
|
|
102
|
+
result.content[0].text = `[account: ${effective}]\n${result.content[0].text}`;
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
} finally {
|
|
106
|
+
// Restore ONLY when this call temporarily overrode the session scope —
|
|
107
|
+
// dailey_use_account itself must keep its session-setting behavior.
|
|
108
|
+
if (requested) setActiveAccount(prev);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Core + identity
|
|
115
|
+
if (opts.includeLocalAuth) registerAuthTools(server);
|
|
116
|
+
registerAccountTools(server, {
|
|
117
|
+
includeSwitch: opts.includeAccountSwitch,
|
|
118
|
+
remoteHint: !opts.includeAccountSwitch,
|
|
119
|
+
});
|
|
120
|
+
registerPlatformTools(server);
|
|
121
|
+
registerUsageTools(server);
|
|
122
|
+
registerBillingTools(server);
|
|
123
|
+
// À-la-carte billing surfaces — prepaid credits + capacity add-ons.
|
|
124
|
+
registerCreditTools(server);
|
|
125
|
+
registerAddonTools(server);
|
|
126
|
+
|
|
127
|
+
// Projects + deploys
|
|
128
|
+
registerProjectTools(server);
|
|
129
|
+
registerAnalyzeTools(server);
|
|
130
|
+
registerDeployTools(server);
|
|
131
|
+
registerDeployStatusTools(server);
|
|
132
|
+
registerBuildLogsTools(server);
|
|
133
|
+
registerImageTools(server);
|
|
134
|
+
|
|
135
|
+
// Lifecycle + scaling
|
|
136
|
+
registerScaleTools(server);
|
|
137
|
+
registerLifecycleTools(server);
|
|
138
|
+
registerResourceConfigTools(server);
|
|
139
|
+
registerProcessTools(server);
|
|
140
|
+
|
|
141
|
+
// Config
|
|
142
|
+
registerEnvTools(server);
|
|
143
|
+
registerDomainTools(server);
|
|
144
|
+
registerLinkTools(server);
|
|
145
|
+
registerCredentialRevealTools(server);
|
|
146
|
+
|
|
147
|
+
// Data
|
|
148
|
+
registerDbTools(server);
|
|
149
|
+
registerMigrateTools(server);
|
|
150
|
+
registerStorageTools(server);
|
|
151
|
+
registerAiTools(server);
|
|
152
|
+
registerEmailTools(server);
|
|
153
|
+
registerDaileyImagesTools(server);
|
|
154
|
+
registerBackupTools(server);
|
|
155
|
+
registerWordPressMigrateTools(server);
|
|
156
|
+
registerWordPressImportTools(server);
|
|
157
|
+
registerWordPressSnapshotTools(server);
|
|
158
|
+
// WordPress live-edit tools (files/media/wp-cli) wrapping customer-api#18's
|
|
159
|
+
// tenant-scoped live-edit routes. Mutating ops are two-phase (preview → confirm_token).
|
|
160
|
+
registerWordPressLiveEditTools(server);
|
|
161
|
+
// Scenario 1 create + WP targeting spine (list/target), paired with the
|
|
162
|
+
// customer-api targeting-spine deploy.
|
|
163
|
+
registerWordPressTargetingTools(server);
|
|
164
|
+
registerEnvironmentTools(server);
|
|
165
|
+
|
|
166
|
+
// Runtime operations — exec into a pod, run one-off jobs
|
|
167
|
+
registerExecRunTools(server);
|
|
168
|
+
|
|
169
|
+
// Admin-only — customer onboarding, project transfer
|
|
170
|
+
if (opts.includeAdmin) {
|
|
171
|
+
registerAdminTools(server);
|
|
172
|
+
registerProjectTransferTools(server);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// CLI assist
|
|
176
|
+
registerCliTools(server);
|
|
177
|
+
|
|
178
|
+
// Atomic deploy bundle
|
|
179
|
+
registerBundleTools(server);
|
|
180
|
+
|
|
181
|
+
// One-stop health check — first tool to reach for when something is broken
|
|
182
|
+
registerDiagnoseTools(server);
|
|
183
|
+
|
|
184
|
+
// Support — escalate to Dailey OS team
|
|
185
|
+
registerSupportTools(server);
|
|
186
|
+
|
|
187
|
+
return server;
|
|
188
|
+
}
|
package/src/tools/accounts.ts
CHANGED
|
@@ -21,10 +21,16 @@ const AUTH_REQUIRED_ERROR = {
|
|
|
21
21
|
help_url: 'https://docs.dailey.cloud/auth',
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export function registerAccountTools(
|
|
24
|
+
export function registerAccountTools(
|
|
25
|
+
server: McpServer,
|
|
26
|
+
opts: { includeSwitch?: boolean; remoteHint?: boolean } = {},
|
|
27
|
+
): void {
|
|
28
|
+
const { includeSwitch = true, remoteHint = false } = opts;
|
|
29
|
+
|
|
25
30
|
server.tool(
|
|
26
31
|
'dailey_accounts',
|
|
27
|
-
'List the managed accounts (the "fleet") this user manages — other Dailey accounts that have granted you a consent-based access grant. Returns each account\'s managed_customer_id, slug, and name, plus which account is currently active for this session. Empty fleet means you manage no other accounts. Use `dailey_use_account` to switch into one of these accounts; after switching, all other dailey tools operate inside that account until you clear or switch.'
|
|
32
|
+
'List the managed accounts (the "fleet") this user manages — other Dailey accounts that have granted you a consent-based access grant. Returns each account\'s managed_customer_id, slug, and name, plus which account is currently active for this session. Empty fleet means you manage no other accounts. Use `dailey_use_account` to switch into one of these accounts; after switching, all other dailey tools operate inside that account until you clear or switch.' +
|
|
33
|
+
(remoteHint ? ' NOTE: this server is remote and stateless — there is no session account switching. Pass `account: "<slug>"` on each tool call to operate in a managed account.' : ''),
|
|
28
34
|
{},
|
|
29
35
|
async () => {
|
|
30
36
|
const res = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
|
|
@@ -44,68 +50,70 @@ export function registerAccountTools(server: McpServer) {
|
|
|
44
50
|
},
|
|
45
51
|
);
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
if (includeSwitch) {
|
|
54
|
+
server.tool(
|
|
55
|
+
'dailey_use_account',
|
|
56
|
+
'Switch the active managed-account context for this MCP session. Pass `account` (a slug or id from `dailey_accounts`) to operate INSIDE that managed account; after calling this, ALL other dailey tools act inside that managed account until you clear or switch. Pass `clear: true` to stop and operate as yourself again. The target account must be in your fleet (`dailey_accounts`) — an invalid account is rejected. This context is session-scoped: it persists for the life of this MCP server.',
|
|
57
|
+
{
|
|
58
|
+
account: z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('The slug or id of a managed account to operate within (must be in your fleet from dailey_accounts)'),
|
|
62
|
+
clear: z
|
|
63
|
+
.boolean()
|
|
64
|
+
.optional()
|
|
65
|
+
.describe('If true, clear the active managed account and operate as yourself again'),
|
|
66
|
+
},
|
|
67
|
+
async ({ account, clear }) => {
|
|
68
|
+
if (clear) {
|
|
69
|
+
setActiveAccount(undefined);
|
|
70
|
+
return jsonResult({
|
|
71
|
+
ok: true,
|
|
72
|
+
active_account: null,
|
|
73
|
+
operating_as: 'self',
|
|
74
|
+
message: 'Cleared managed-account context — now operating as yourself.',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
if (!account || !account.trim()) {
|
|
79
|
+
return jsonResult({
|
|
80
|
+
ok: false,
|
|
81
|
+
message: 'Provide `account` (a slug or id from dailey_accounts) to switch into, or `clear: true` to operate as yourself.',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
const res = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
|
|
86
|
+
if (!res.ok) {
|
|
87
|
+
if (res.status === 401 || res.status === 403) {
|
|
88
|
+
return jsonResult(AUTH_REQUIRED_ERROR);
|
|
89
|
+
}
|
|
90
|
+
return jsonResult({ ok: false, error: formatError(res) });
|
|
82
91
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
const fleet = Array.isArray(res.data) ? res.data : [];
|
|
93
|
+
const target = account.trim();
|
|
94
|
+
const match = fleet.find(
|
|
95
|
+
(a) => a.slug === target || a.managed_customer_id === target,
|
|
96
|
+
);
|
|
97
|
+
if (!match) {
|
|
98
|
+
return jsonResult({
|
|
99
|
+
ok: false,
|
|
100
|
+
message: `Account "${target}" is not in your managed-accounts fleet. Call dailey_accounts to list the accounts you manage.`,
|
|
101
|
+
available: fleet.map((a) => ({ slug: a.slug, name: a.name })),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Use the slug as the header value when available (matches the dashboard/CLI
|
|
106
|
+
// convention); the server accepts either slug or id.
|
|
107
|
+
const activeValue = match.slug || match.managed_customer_id;
|
|
108
|
+
setActiveAccount(activeValue);
|
|
91
109
|
return jsonResult({
|
|
92
|
-
ok:
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
ok: true,
|
|
111
|
+
active_account: activeValue,
|
|
112
|
+
operating_as: 'managed_account',
|
|
113
|
+
account: match,
|
|
114
|
+
message: `Now operating within "${match.name}" (${match.slug}). All subsequent dailey tool calls run inside this account until you clear or switch.`,
|
|
95
115
|
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// convention); the server accepts either slug or id.
|
|
100
|
-
const activeValue = match.slug || match.managed_customer_id;
|
|
101
|
-
setActiveAccount(activeValue);
|
|
102
|
-
return jsonResult({
|
|
103
|
-
ok: true,
|
|
104
|
-
active_account: activeValue,
|
|
105
|
-
operating_as: 'managed_account',
|
|
106
|
-
account: match,
|
|
107
|
-
message: `Now operating within "${match.name}" (${match.slug}). All subsequent dailey tool calls run inside this account until you clear or switch.`,
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
);
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
}
|
|
111
119
|
}
|
|
@@ -9,10 +9,25 @@ import {
|
|
|
9
9
|
setActiveAccount,
|
|
10
10
|
} from '../api.js';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The catalog SLUG (the key in dailey-deploy-service's CATALOG, src/routes/deploy-image.ts)
|
|
14
|
+
* — not an image ref. This is what gets stored as the project's `repo_url`, and the
|
|
15
|
+
* deploy-service resolves the template from it on every deploy: MySQL DB env, the
|
|
16
|
+
* persistent wp-content volume, the backup sidecar, the Recreate strategy and the
|
|
17
|
+
* generated admin creds all hang off that lookup.
|
|
18
|
+
*
|
|
19
|
+
* It used to be the image ref `wordpress:6-apache`, matched by comparing image
|
|
20
|
+
* repositories. On 2026-07-13 the catalog image was repointed to
|
|
21
|
+
* `registry.dailey.cloud/catalog/wordpress:6-apache-wpcli` to bake in wp-cli, and the
|
|
22
|
+
* repository names stopped matching — so `getCatalogEntry` returned null and every
|
|
23
|
+
* WordPress site created afterwards came up as a generic stateless app: no volume, no
|
|
24
|
+
* WORDPRESS_DB_* env, no wp-cli, serving the installer. Verified 2026-08-07.
|
|
25
|
+
*
|
|
26
|
+
* The slug is matched by exact key (`if (CATALOG[input]) return CATALOG[input]`), which
|
|
27
|
+
* is the FIRST branch of the lookup, so it cannot be broken by repointing the image
|
|
28
|
+
* again. Prefer the slug over any image ref here, permanently.
|
|
29
|
+
*/
|
|
30
|
+
const WORDPRESS_CATALOG_SLUG = 'wordpress';
|
|
16
31
|
|
|
17
32
|
interface CreatedProject {
|
|
18
33
|
id: string;
|
|
@@ -55,7 +70,7 @@ export function registerWordPressTargetingTools(server: McpServer) {
|
|
|
55
70
|
// ── Tool 1 — Scenario 1: create a fresh hardened WordPress site ──────────
|
|
56
71
|
server.tool(
|
|
57
72
|
'dailey_create_wordpress',
|
|
58
|
-
'Create a brand-new hardened WordPress site in the effective account (respects the account set by dailey_use_account, or the optional `account` arg here). POSTs the standard project-create endpoint with the WordPress catalog
|
|
73
|
+
'Create a brand-new hardened WordPress site in the effective account (respects the account set by dailey_use_account, or the optional `account` arg here). POSTs the standard project-create endpoint with the WordPress catalog slug so the deploy-service provisions the MySQL database, a persistent wp-content volume, a backup sidecar, and generated admin credentials. Note: WordPress core is NOT auto-installed — the site serves the standard WordPress installer on first visit; the generated admin credentials are for the account you create there. Prefer this over dailey_wordpress_import when you just need a fresh site (import is for migrating an existing bundle). Returns the project_id, slug, the wp-admin URL, and the effective account. The generated admin password is retrievable via dailey_reveal_credential (key WORDPRESS_ADMIN_PASSWORD).',
|
|
59
74
|
{
|
|
60
75
|
name: z.string().describe('Project name for the new WordPress site'),
|
|
61
76
|
account: z
|
|
@@ -68,10 +83,10 @@ export function registerWordPressTargetingTools(server: McpServer) {
|
|
|
68
83
|
|
|
69
84
|
// Reuse the exact dailey_create_project call shape (POST /projects) but
|
|
70
85
|
// with the hardened WordPress catalog inputs. The deploy-service resolves
|
|
71
|
-
// the catalog template
|
|
86
|
+
// the catalog template from this slug and wires DB + storage + admin creds.
|
|
72
87
|
const res = await apiRequest<CreatedProject>('POST', '/projects', {
|
|
73
88
|
name,
|
|
74
|
-
repo_url:
|
|
89
|
+
repo_url: WORDPRESS_CATALOG_SLUG,
|
|
75
90
|
needs_database: true,
|
|
76
91
|
needs_storage: true,
|
|
77
92
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { requestContext } from '../src/context.js';
|
|
4
|
+
import { resolveToken, setActiveAccount, getActiveAccount } from '../src/api.js';
|
|
5
|
+
|
|
6
|
+
test('resolveToken prefers the ALS store token over env/config', () => {
|
|
7
|
+
requestContext.run({ token: 'tok-from-request' }, () => {
|
|
8
|
+
assert.equal(resolveToken(), 'tok-from-request');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('setActiveAccount inside a request scopes to that request only', () => {
|
|
13
|
+
// Outside any request: module-global behavior (stdio path).
|
|
14
|
+
setActiveAccount(undefined);
|
|
15
|
+
requestContext.run({ token: 't1' }, () => {
|
|
16
|
+
setActiveAccount('acme');
|
|
17
|
+
assert.equal(getActiveAccount(), 'acme');
|
|
18
|
+
});
|
|
19
|
+
// The write above must NOT have leaked to the module global.
|
|
20
|
+
assert.equal(getActiveAccount(), undefined);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('two concurrent request contexts never see each other', async () => {
|
|
24
|
+
const seen: Array<string | undefined> = [];
|
|
25
|
+
await Promise.all([
|
|
26
|
+
new Promise<void>((res) => requestContext.run({ token: 'a' }, () => {
|
|
27
|
+
setActiveAccount('acct-a');
|
|
28
|
+
setTimeout(() => { seen.push(getActiveAccount()); assert.equal(resolveToken(), 'a'); res(); }, 20);
|
|
29
|
+
})),
|
|
30
|
+
new Promise<void>((res) => requestContext.run({ token: 'b' }, () => {
|
|
31
|
+
setActiveAccount('acct-b');
|
|
32
|
+
setTimeout(() => { seen.push(getActiveAccount()); assert.equal(resolveToken(), 'b'); res(); }, 10);
|
|
33
|
+
})),
|
|
34
|
+
]);
|
|
35
|
+
assert.deepEqual(seen.sort(), ['acct-a', 'acct-b']);
|
|
36
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { test, before, after } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import type { Server } from 'node:http';
|
|
4
|
+
import { createHttpServer, MAX_INFLIGHT, getInflight } from '../src/http.js';
|
|
5
|
+
|
|
6
|
+
let server: Server; let base: string;
|
|
7
|
+
before(async () => {
|
|
8
|
+
server = createHttpServer();
|
|
9
|
+
await new Promise<void>((r) => server.listen(0, () => r()));
|
|
10
|
+
const addr = server.address() as { port: number };
|
|
11
|
+
base = `http://127.0.0.1:${addr.port}`;
|
|
12
|
+
});
|
|
13
|
+
after(() => server.close());
|
|
14
|
+
|
|
15
|
+
test('healthz is open', async () => {
|
|
16
|
+
const r = await fetch(`${base}/healthz`);
|
|
17
|
+
assert.equal(r.status, 200);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('POST /mcp without bearer → 401 with WWW-Authenticate', async () => {
|
|
21
|
+
const r = await fetch(`${base}/mcp`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{}' });
|
|
22
|
+
assert.equal(r.status, 401);
|
|
23
|
+
assert.equal(
|
|
24
|
+
r.headers.get('www-authenticate'),
|
|
25
|
+
'Bearer resource_metadata="https://mcp.dailey.cloud/.well-known/oauth-protected-resource"',
|
|
26
|
+
);
|
|
27
|
+
const body = await r.json();
|
|
28
|
+
assert.equal(body.jsonrpc, '2.0');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('GET /mcp → 405 (stateless)', async () => {
|
|
32
|
+
const r = await fetch(`${base}/mcp`, { headers: { Authorization: 'Bearer x' } });
|
|
33
|
+
assert.equal(r.status, 405);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('wrong content-type → 415', async () => {
|
|
37
|
+
const r = await fetch(`${base}/mcp`, { method: 'POST', headers: { Authorization: 'Bearer x', 'Content-Type': 'text/plain' }, body: '{}' });
|
|
38
|
+
assert.equal(r.status, 415);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('oauth-protected-resource metadata served', async () => {
|
|
42
|
+
const r = await fetch(`${base}/.well-known/oauth-protected-resource`);
|
|
43
|
+
assert.equal(r.status, 200);
|
|
44
|
+
const j = await r.json();
|
|
45
|
+
assert.equal(j.resource, 'https://mcp.dailey.cloud');
|
|
46
|
+
assert.deepEqual(j.authorization_servers, ['https://core.dailey.cloud']);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('tools/list works with any bearer (no capi call), excludes admin/switch/transfer, includes whoami', async () => {
|
|
50
|
+
const { Client } = await import('@modelcontextprotocol/sdk/client/index.js');
|
|
51
|
+
const { StreamableHTTPClientTransport } = await import('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
52
|
+
const client = new Client({ name: 'test', version: '0' });
|
|
53
|
+
const transport = new StreamableHTTPClientTransport(new URL(`${base}/mcp`), {
|
|
54
|
+
requestInit: { headers: { Authorization: 'Bearer dummy-token' } },
|
|
55
|
+
});
|
|
56
|
+
await client.connect(transport);
|
|
57
|
+
const tools = await client.listTools();
|
|
58
|
+
assert.ok(tools.tools.length > 40);
|
|
59
|
+
assert.ok(tools.tools.every((t) => !t.name.startsWith('dailey_admin')));
|
|
60
|
+
const names = tools.tools.map((t) => t.name);
|
|
61
|
+
// includeLocalAuth is TRUE on the remote surface — dailey_whoami must be reachable.
|
|
62
|
+
assert.ok(names.includes('dailey_whoami'), 'dailey_whoami should be on the remote surface');
|
|
63
|
+
// includeAccountSwitch and includeAdmin are FALSE on the remote surface.
|
|
64
|
+
assert.ok(!names.includes('dailey_use_account'), 'dailey_use_account must not be on the remote surface');
|
|
65
|
+
assert.ok(!names.includes('dailey_project_transfer_plan'), 'dailey_project_transfer_plan must not be on the remote surface');
|
|
66
|
+
await client.close();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('per-token rate limit trips at 61st request in a minute', async () => {
|
|
70
|
+
for (let i = 0; i < 60; i++) {
|
|
71
|
+
const r = await fetch(`${base}/mcp`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: { Authorization: 'Bearer ratelimit-test', 'Content-Type': 'application/json' },
|
|
74
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: i, method: 'ping' }),
|
|
75
|
+
});
|
|
76
|
+
assert.notEqual(r.status, 429, `request ${i + 1}/60 should not be rate-limited`);
|
|
77
|
+
}
|
|
78
|
+
const r61 = await fetch(`${base}/mcp`, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
headers: { Authorization: 'Bearer ratelimit-test', 'Content-Type': 'application/json' },
|
|
81
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 60, method: 'ping' }),
|
|
82
|
+
});
|
|
83
|
+
assert.equal(r61.status, 429);
|
|
84
|
+
assert.ok(r61.headers.get('retry-after'), 'Retry-After header should be present on 429');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('whoami round-trip with a real token', { skip: !process.env.DAILEY_TEST_TOKEN }, async () => {
|
|
88
|
+
const { Client } = await import('@modelcontextprotocol/sdk/client/index.js');
|
|
89
|
+
const { StreamableHTTPClientTransport } = await import('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
90
|
+
const client = new Client({ name: 'test', version: '0' });
|
|
91
|
+
const transport = new StreamableHTTPClientTransport(new URL(`${base}/mcp`), {
|
|
92
|
+
requestInit: { headers: { Authorization: `Bearer ${process.env.DAILEY_TEST_TOKEN}` } },
|
|
93
|
+
});
|
|
94
|
+
await client.connect(transport);
|
|
95
|
+
const out = await client.callTool({ name: 'dailey_whoami', arguments: {} });
|
|
96
|
+
assert.ok(JSON.stringify(out).length > 0);
|
|
97
|
+
await client.close();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('in-flight cap constants and cleanup', () => {
|
|
101
|
+
assert.equal(MAX_INFLIGHT, 50, 'MAX_INFLIGHT should be 50');
|
|
102
|
+
assert.equal(getInflight(), 0, 'inflight counter should be 0 after all requests completed (no leak)');
|
|
103
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { buildServer } from '../src/server.js';
|
|
4
|
+
|
|
5
|
+
async function toolNames(opts: Parameters<typeof buildServer>[0]): Promise<string[]> {
|
|
6
|
+
const server = buildServer(opts);
|
|
7
|
+
// McpServer keeps registrations in a private map; list via the underlying
|
|
8
|
+
// server's request handler is heavyweight, so use the public accessor
|
|
9
|
+
// pattern the SDK supports: (server as any)._registeredTools.
|
|
10
|
+
return Object.keys((server as any)._registeredTools ?? {});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
test('remote surface excludes admin, local-auth, and account-switch tools', async () => {
|
|
14
|
+
const names = await toolNames({ includeAdmin: false, includeLocalAuth: false, includeAccountSwitch: false });
|
|
15
|
+
assert.ok(names.length > 40, `expected >40 tools, got ${names.length}`);
|
|
16
|
+
for (const n of names) {
|
|
17
|
+
assert.ok(!n.startsWith('dailey_admin'), `admin tool leaked: ${n}`);
|
|
18
|
+
}
|
|
19
|
+
// Local auth tools registered by registerAuthTools (src/tools/auth.ts):
|
|
20
|
+
// dailey_whoami, dailey_auth_status, dailey_auth_enable — no `dailey_login`
|
|
21
|
+
// tool actually exists in this codebase.
|
|
22
|
+
assert.ok(!names.includes('dailey_whoami'), 'local auth tool leaked');
|
|
23
|
+
assert.ok(!names.includes('dailey_auth_status'), 'local auth tool leaked');
|
|
24
|
+
assert.ok(!names.includes('dailey_auth_enable'), 'local auth tool leaked');
|
|
25
|
+
assert.ok(!names.includes('dailey_use_account'), 'account switch tool leaked');
|
|
26
|
+
assert.ok(names.some((n) => n.includes('account')), 'account LIST tool should remain');
|
|
27
|
+
assert.ok(!names.includes('dailey_project_transfer_plan'), 'project-transfer tool leaked to remote surface');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('stdio surface includes everything', async () => {
|
|
31
|
+
const names = await toolNames({ includeAdmin: true, includeLocalAuth: true, includeAccountSwitch: true });
|
|
32
|
+
assert.ok(names.some((n) => n.startsWith('dailey_admin')), 'admin tools missing on stdio surface');
|
|
33
|
+
assert.ok(names.includes('dailey_use_account'), 'switch tool missing on stdio surface');
|
|
34
|
+
assert.ok(names.includes('dailey_whoami'), 'local auth tools missing on stdio surface');
|
|
35
|
+
assert.ok(names.includes('dailey_project_transfer_plan'), 'project-transfer tool missing on stdio surface');
|
|
36
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { buildServer } from '../src/server.js';
|
|
4
|
+
import { getActiveAccount, setActiveAccount } from '../src/api.js';
|
|
5
|
+
|
|
6
|
+
// dailey_use_account must be registered WITHOUT the per-call scope wrapper, so
|
|
7
|
+
// its session-set survives (the wrapper's finally-restore used to undo it).
|
|
8
|
+
test('dailey_use_account is registered raw (no wrapper-injected account param)', () => {
|
|
9
|
+
const server = buildServer({ includeAdmin: false, includeLocalAuth: true, includeAccountSwitch: true });
|
|
10
|
+
const reg = (server as any)._registeredTools ?? {};
|
|
11
|
+
const use = reg['dailey_use_account'];
|
|
12
|
+
assert.ok(use, 'dailey_use_account should be registered when includeAccountSwitch');
|
|
13
|
+
// Wrapped tools get an injected `account` prop in their input schema; the
|
|
14
|
+
// switch tool must NOT (it manages the session directly).
|
|
15
|
+
const shape = use.inputSchema?.shape ?? use.inputSchema?._def?.shape?.() ?? {};
|
|
16
|
+
// Its own schema defines `slug`/`account`? Confirm it wasn't double-wrapped:
|
|
17
|
+
// a wrapped tool's handler saves+restores; raw registration means calling it
|
|
18
|
+
// leaves the module-global set. Exercise that directly:
|
|
19
|
+
setActiveAccount(undefined);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('a wrapped tool restores session account after a per-call override', () => {
|
|
23
|
+
// Sanity: the wrapper still works for normal tools (restore-after-call).
|
|
24
|
+
setActiveAccount('base-acct');
|
|
25
|
+
// getActiveAccount reflects the module global outside any ALS request.
|
|
26
|
+
assert.equal(getActiveAccount(), 'base-acct');
|
|
27
|
+
setActiveAccount(undefined);
|
|
28
|
+
});
|
|
@@ -65,7 +65,7 @@ test('dailey_create_wordpress POSTs /projects with the hardened WP catalog body
|
|
|
65
65
|
assert.ok(post, 'must POST /projects');
|
|
66
66
|
assert.deepStrictEqual(post!.body, {
|
|
67
67
|
name: 'My Blog',
|
|
68
|
-
repo_url: 'wordpress
|
|
68
|
+
repo_url: 'wordpress',
|
|
69
69
|
needs_database: true,
|
|
70
70
|
needs_storage: true,
|
|
71
71
|
});
|
|
@@ -125,3 +125,38 @@ test('dailey_wp_target returns a clear not-found on 404 pointing at dailey_wp_li
|
|
|
125
125
|
assert.match(parsed.message, /No WordPress project matching 'ghost'/);
|
|
126
126
|
assert.match(parsed.message, /dailey_wp_list/);
|
|
127
127
|
});
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Regression guard for the 2026-08-07 outage.
|
|
131
|
+
*
|
|
132
|
+
* `repo_url` is what deploy-service resolves the catalog template from on EVERY
|
|
133
|
+
* deploy — the MySQL env, the persistent wp-content volume, the backup sidecar and
|
|
134
|
+
* the Recreate strategy all hang off that lookup. It must be the catalog SLUG.
|
|
135
|
+
*
|
|
136
|
+
* It was previously the image ref `wordpress:6-apache`, matched by comparing image
|
|
137
|
+
* repositories. When the catalog image was repointed to
|
|
138
|
+
* `registry.dailey.cloud/catalog/wordpress:6-apache-wpcli` on 2026-07-13, the
|
|
139
|
+
* repositories stopped matching, the lookup returned null, and every WordPress site
|
|
140
|
+
* created afterwards came up as a generic stateless app — no volume, no
|
|
141
|
+
* WORDPRESS_DB_*, no wp-cli — serving the installer.
|
|
142
|
+
*
|
|
143
|
+
* The assertion above used to pin the image ref, so it stayed green throughout.
|
|
144
|
+
* This test states the actual invariant instead: never send an image ref here.
|
|
145
|
+
*/
|
|
146
|
+
test('dailey_create_wordpress sends the catalog SLUG, never an image ref (repoint-proof)', async (t) => {
|
|
147
|
+
const mock = makeApiMock();
|
|
148
|
+
t.mock.module('../src/api.js', { namedExports: mock.namedExports });
|
|
149
|
+
|
|
150
|
+
const { registerWordPressTargetingTools } = await import('../src/tools/wordpress-targeting.js?t=slug');
|
|
151
|
+
const { server, getHandler } = makeFakeServer();
|
|
152
|
+
registerWordPressTargetingTools(server as any);
|
|
153
|
+
|
|
154
|
+
await getHandler('dailey_create_wordpress')({ name: 'Shop' });
|
|
155
|
+
|
|
156
|
+
const post = mock.calls.find((c) => c.path === '/projects');
|
|
157
|
+
const repoUrl = (post!.body as any).repo_url as string;
|
|
158
|
+
|
|
159
|
+
assert.strictEqual(repoUrl, 'wordpress', 'must be the catalog slug');
|
|
160
|
+
assert.ok(!repoUrl.includes(':'), 'a tag means an image ref was sent, not a slug');
|
|
161
|
+
assert.ok(!repoUrl.includes('/'), 'a registry path means an image ref was sent, not a slug');
|
|
162
|
+
});
|
package/dist/tools/buddy.d.ts
DELETED