@daileyos/mcp-server 1.21.2 → 1.21.9
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.d.ts.map +1 -1
- package/dist/tools/accounts.js +3 -2
- 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 +8 -2
- 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 +5 -3
- 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 +10 -2
- 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,188 +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
|
-
jsonResult,
|
|
8
|
-
getActiveAccount,
|
|
9
|
-
setActiveAccount,
|
|
10
|
-
} from '../api.js';
|
|
11
|
-
|
|
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';
|
|
31
|
-
|
|
32
|
-
interface CreatedProject {
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
slug?: string;
|
|
36
|
-
status?: string;
|
|
37
|
-
repo_url?: string;
|
|
38
|
-
url?: string;
|
|
39
|
-
build_id?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// A WordPress project as returned by the targeting spine
|
|
43
|
-
// (customer-api feat/wp-targeting-spine).
|
|
44
|
-
interface WpProject {
|
|
45
|
-
project_id: string;
|
|
46
|
-
slug: string;
|
|
47
|
-
domain: string;
|
|
48
|
-
env: string;
|
|
49
|
-
db_name: string;
|
|
50
|
-
namespace: string;
|
|
51
|
-
active_account: string | null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface WpListResponse {
|
|
55
|
-
projects: WpProject[];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// If the caller passed an explicit `account`, adopt it as the acting-as target
|
|
59
|
-
// for this session (same mechanism as dailey_use_account — sends X-Dailey-Account
|
|
60
|
-
// on every subsequent request). Returns the EFFECTIVE account so every tool
|
|
61
|
-
// result can surface it and targeting is never ambiguous.
|
|
62
|
-
function scopeAccount(account?: string): string | null {
|
|
63
|
-
if (account && account.trim()) {
|
|
64
|
-
setActiveAccount(account.trim());
|
|
65
|
-
}
|
|
66
|
-
return getActiveAccount() ?? null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function registerWordPressTargetingTools(server: McpServer) {
|
|
70
|
-
// ── Tool 1 — Scenario 1: create a fresh hardened WordPress site ──────────
|
|
71
|
-
server.tool(
|
|
72
|
-
'dailey_create_wordpress',
|
|
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).',
|
|
74
|
-
{
|
|
75
|
-
name: z.string().describe('Project name for the new WordPress site'),
|
|
76
|
-
account: z
|
|
77
|
-
.string()
|
|
78
|
-
.optional()
|
|
79
|
-
.describe('Acting-as target: slug or id of a managed account to create the site in (must be in your fleet from dailey_accounts). Scopes this and subsequent calls, like dailey_use_account.'),
|
|
80
|
-
},
|
|
81
|
-
async ({ name, account }) => {
|
|
82
|
-
const activeAccount = scopeAccount(account);
|
|
83
|
-
|
|
84
|
-
// Reuse the exact dailey_create_project call shape (POST /projects) but
|
|
85
|
-
// with the hardened WordPress catalog inputs. The deploy-service resolves
|
|
86
|
-
// the catalog template from this slug and wires DB + storage + admin creds.
|
|
87
|
-
const res = await apiRequest<CreatedProject>('POST', '/projects', {
|
|
88
|
-
name,
|
|
89
|
-
repo_url: WORDPRESS_CATALOG_SLUG,
|
|
90
|
-
needs_database: true,
|
|
91
|
-
needs_storage: true,
|
|
92
|
-
});
|
|
93
|
-
if (!res.ok) return textResult(formatError(res));
|
|
94
|
-
|
|
95
|
-
const p = res.data;
|
|
96
|
-
const slug = p.slug || '';
|
|
97
|
-
const adminUrl = slug ? `https://${slug}.dailey.cloud/wp-admin` : '(slug pending — check dailey_project_info)';
|
|
98
|
-
|
|
99
|
-
return textResult(
|
|
100
|
-
[
|
|
101
|
-
`WordPress site created!`,
|
|
102
|
-
``,
|
|
103
|
-
`Project ID: ${p.id}`,
|
|
104
|
-
`Name: ${p.name}`,
|
|
105
|
-
`Slug: ${slug || '(pending)'}`,
|
|
106
|
-
`Status: ${p.status || 'pending'}`,
|
|
107
|
-
`Admin URL: ${adminUrl}`,
|
|
108
|
-
`Account: ${activeAccount ?? 'self'}`,
|
|
109
|
-
...(p.build_id ? [`Build: ${p.build_id} (auto-queued — watch with dailey_deploy_status)`] : []),
|
|
110
|
-
``,
|
|
111
|
-
`The generated admin password is retrievable via:`,
|
|
112
|
-
` dailey_reveal_credential(project_id="${p.id}", key="WORDPRESS_ADMIN_PASSWORD")`,
|
|
113
|
-
`Every reveal is audited and returns a masked preview by default.`,
|
|
114
|
-
].join('\n'),
|
|
115
|
-
);
|
|
116
|
-
},
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
// ── Tool 2 — list WordPress projects (targeting spine) ───────────────────
|
|
120
|
-
server.tool(
|
|
121
|
-
'dailey_wp_list',
|
|
122
|
-
'List the WordPress projects in the effective account. Call this instead of guessing a WP site from the generic dailey_list_projects — it returns only WordPress projects with their targeting identity (project_id, slug, domain, env, db_name, namespace) and prominently the active_account you are operating in. NOTE: requires the paired customer-api feat/wp-targeting-spine deploy; until that ships this returns 404 (expected — both merge together).',
|
|
123
|
-
{
|
|
124
|
-
account: z
|
|
125
|
-
.string()
|
|
126
|
-
.optional()
|
|
127
|
-
.describe('Acting-as target: slug or id of a managed account to list within (must be in your fleet from dailey_accounts). Scopes this and subsequent calls, like dailey_use_account.'),
|
|
128
|
-
},
|
|
129
|
-
async ({ account }) => {
|
|
130
|
-
const activeAccount = scopeAccount(account);
|
|
131
|
-
|
|
132
|
-
const res = await apiRequest<WpListResponse>('GET', '/projects/wp/list');
|
|
133
|
-
if (!res.ok) return jsonResult({ active_account: activeAccount, error: formatError(res) });
|
|
134
|
-
|
|
135
|
-
const projects = res.data.projects ?? [];
|
|
136
|
-
return jsonResult({
|
|
137
|
-
active_account: activeAccount,
|
|
138
|
-
count: projects.length,
|
|
139
|
-
projects,
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
// ── Tool 3 — resolve/confirm a WordPress target (targeting spine) ────────
|
|
145
|
-
server.tool(
|
|
146
|
-
'dailey_wp_target',
|
|
147
|
-
'Resolve a WordPress project reference (id OR slug) to its exact targeting identity and echo it back: project_id, slug, domain, env, db_name, namespace, and active_account. CALL THIS BEFORE ANY DESTRUCTIVE WordPress action (import, restore, clone, delete, db writes) to confirm you are about to act on the RIGHT domain/database/account — this is the fix for editing the wrong site. If no WordPress project matches the ref in the active account, returns a clear not-found pointing you at dailey_wp_list. NOTE: requires the paired customer-api feat/wp-targeting-spine deploy; until that ships this returns 404 (expected — both merge together).',
|
|
148
|
-
{
|
|
149
|
-
project: z.string().describe('The WordPress project to resolve — its id OR slug'),
|
|
150
|
-
account: z
|
|
151
|
-
.string()
|
|
152
|
-
.optional()
|
|
153
|
-
.describe('Acting-as target: slug or id of a managed account to resolve within (must be in your fleet from dailey_accounts). Scopes this and subsequent calls, like dailey_use_account.'),
|
|
154
|
-
},
|
|
155
|
-
async ({ project, account }) => {
|
|
156
|
-
const activeAccount = scopeAccount(account);
|
|
157
|
-
|
|
158
|
-
const res = await apiRequest<WpProject & { error?: string }>(
|
|
159
|
-
'GET',
|
|
160
|
-
`/projects/wp/resolve?ref=${encodeURIComponent(project)}`,
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
if (res.status === 404) {
|
|
164
|
-
return jsonResult({
|
|
165
|
-
active_account: activeAccount,
|
|
166
|
-
resolved: false,
|
|
167
|
-
message: `No WordPress project matching '${project}' in account '${activeAccount ?? 'self'}' — call dailey_wp_list to see the options.`,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (!res.ok) return jsonResult({ active_account: activeAccount, resolved: false, error: formatError(res) });
|
|
171
|
-
|
|
172
|
-
const t = res.data;
|
|
173
|
-
return jsonResult({
|
|
174
|
-
active_account: t.active_account ?? activeAccount,
|
|
175
|
-
resolved: true,
|
|
176
|
-
target: {
|
|
177
|
-
project_id: t.project_id,
|
|
178
|
-
slug: t.slug,
|
|
179
|
-
domain: t.domain,
|
|
180
|
-
env: t.env,
|
|
181
|
-
db_name: t.db_name,
|
|
182
|
-
namespace: t.namespace,
|
|
183
|
-
},
|
|
184
|
-
confirm: `About to act on ${t.domain} (db=${t.db_name}, env=${t.env}) in account '${t.active_account ?? activeAccount ?? 'self'}'. Verify this is the intended site before any destructive action.`,
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
);
|
|
188
|
-
}
|
package/src/upload.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createReadStream, statSync } from 'node:fs';
|
|
2
|
-
import { request } from 'node:https';
|
|
3
|
-
import { URL } from 'node:url';
|
|
4
|
-
|
|
5
|
-
/** Stream a local file to a presigned PUT URL. S3/R2 presigned PUTs require
|
|
6
|
-
* Content-Length (no chunked encoding), so this uses https.request, not fetch. */
|
|
7
|
-
export function putFileToPresignedUrl(
|
|
8
|
-
presignedUrl: string,
|
|
9
|
-
filePath: string,
|
|
10
|
-
headers: Record<string, string> = {},
|
|
11
|
-
onProgress?: (sentBytes: number, totalBytes: number) => void,
|
|
12
|
-
): Promise<void> {
|
|
13
|
-
const total = statSync(filePath).size;
|
|
14
|
-
if (total <= 0) return Promise.reject(new Error(`${filePath} is empty`));
|
|
15
|
-
return new Promise((resolve, reject) => {
|
|
16
|
-
const u = new URL(presignedUrl);
|
|
17
|
-
const req = request(
|
|
18
|
-
{ method: 'PUT', hostname: u.hostname, path: u.pathname + u.search, headers: { ...headers, 'Content-Length': total } },
|
|
19
|
-
(res) => {
|
|
20
|
-
let body = '';
|
|
21
|
-
res.on('data', (c) => { body += c; });
|
|
22
|
-
res.on('end', () => {
|
|
23
|
-
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) resolve();
|
|
24
|
-
else reject(new Error(`Upload failed: HTTP ${res.statusCode} ${body.slice(0, 300)}`));
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
);
|
|
28
|
-
req.on('error', reject);
|
|
29
|
-
let sent = 0;
|
|
30
|
-
const stream = createReadStream(filePath);
|
|
31
|
-
stream.on('data', (chunk) => { sent += (chunk as Buffer).length; onProgress?.(sent, total); });
|
|
32
|
-
stream.on('error', reject);
|
|
33
|
-
stream.pipe(req);
|
|
34
|
-
});
|
|
35
|
-
}
|
package/src/version.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version identity + staleness self-check.
|
|
3
|
-
*
|
|
4
|
-
* WHY (2026-07-13 dogfood incident): sessions silently ran a months-old MCP
|
|
5
|
-
* (global-install shadowing + stale npx cache), so the agent was missing ~35
|
|
6
|
-
* tools and told the customer the platform had no AI. Staleness must never be
|
|
7
|
-
* silent again:
|
|
8
|
-
* - OWN_VERSION is read from package.json (the server previously hardcoded a
|
|
9
|
-
* stale string) and sent on every API request as X-Dailey-Client-Version,
|
|
10
|
-
* so the platform can see exactly which versions are live in the field.
|
|
11
|
-
* - checkForNewerVersion() asks the npm registry (fail-open, hard timeout)
|
|
12
|
-
* whether this copy is behind; the caller surfaces the notice to the AGENT
|
|
13
|
-
* via server instructions, so the agent itself tells the user to update.
|
|
14
|
-
*/
|
|
15
|
-
import { createRequire } from 'node:module';
|
|
16
|
-
|
|
17
|
-
const require = createRequire(import.meta.url);
|
|
18
|
-
|
|
19
|
-
export const OWN_VERSION: string = (() => {
|
|
20
|
-
try {
|
|
21
|
-
return require('../package.json').version ?? '0.0.0';
|
|
22
|
-
} catch {
|
|
23
|
-
return '0.0.0';
|
|
24
|
-
}
|
|
25
|
-
})();
|
|
26
|
-
|
|
27
|
-
/** Numeric semver compare (a<b → -1). Non-numeric parts compare as 0. */
|
|
28
|
-
function cmpSemver(a: string, b: string): number {
|
|
29
|
-
const pa = a.split('.').map((x) => parseInt(x, 10) || 0);
|
|
30
|
-
const pb = b.split('.').map((x) => parseInt(x, 10) || 0);
|
|
31
|
-
for (let i = 0; i < 3; i++) {
|
|
32
|
-
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return -1;
|
|
33
|
-
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return 1;
|
|
34
|
-
}
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Returns the newer registry version when this copy is outdated, else null.
|
|
40
|
-
* Fail-open: any network error / timeout returns null (never blocks startup).
|
|
41
|
-
*/
|
|
42
|
-
export async function checkForNewerVersion(timeoutMs = 1500): Promise<string | null> {
|
|
43
|
-
try {
|
|
44
|
-
const ctrl = new AbortController();
|
|
45
|
-
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
46
|
-
const res = await fetch('https://registry.npmjs.org/@daileyos%2Fmcp-server/latest', {
|
|
47
|
-
signal: ctrl.signal,
|
|
48
|
-
headers: { Accept: 'application/json' },
|
|
49
|
-
});
|
|
50
|
-
clearTimeout(timer);
|
|
51
|
-
if (!res.ok) return null;
|
|
52
|
-
const data = (await res.json()) as { version?: string };
|
|
53
|
-
const latest = data?.version;
|
|
54
|
-
if (latest && cmpSemver(OWN_VERSION, latest) < 0) return latest;
|
|
55
|
-
return null;
|
|
56
|
-
} catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** The notice shown to the agent (via server instructions) when outdated. */
|
|
62
|
-
export function outdatedNotice(latest: string): string {
|
|
63
|
-
return (
|
|
64
|
-
`NOTE: this Dailey OS MCP server is v${OWN_VERSION}, but v${latest} is available. ` +
|
|
65
|
-
`Some platform tools/documentation may be missing from this session. ` +
|
|
66
|
-
`Tell the user: "My Dailey OS tools are outdated (v${OWN_VERSION} vs v${latest}) — ` +
|
|
67
|
-
`restart the app to pick up the latest," and prefer verifying capabilities with ` +
|
|
68
|
-
`dailey_platform_info / dailey_os_guide rather than assuming a feature does not exist.`
|
|
69
|
-
);
|
|
70
|
-
}
|
package/test/context.test.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
});
|
package/test/http.test.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
});
|