@daileyos/mcp-server 1.20.6 → 1.21.0
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.map +1 -1
- package/dist/api.js +5 -0
- package/dist/api.js.map +1 -1
- package/dist/index.js +54 -3
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +70 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
- package/src/api.ts +5 -0
- package/src/index.ts +61 -5
- package/src/version.ts +70 -0
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AA2CA,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAYD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAEnE;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAKD,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAsBD,UAAU,WAAW,CAAC,CAAC,GAAG,OAAO;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED,wBAAsB,UAAU,CAAC,CAAC,GAAG,OAAO,EAC1C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CA+CzB;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAwBpD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAkD3E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAItD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM;;;;;EAEtC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO;;;;;EAEvC"}
|
package/dist/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { OWN_VERSION } from './version.js';
|
|
4
5
|
const API_URL = process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api';
|
|
5
6
|
const DAILEY_EMAIL = process.env.DAILEY_EMAIL;
|
|
6
7
|
const DAILEY_PASSWORD = process.env.DAILEY_PASSWORD;
|
|
@@ -95,6 +96,10 @@ export async function apiRequest(method, path, body) {
|
|
|
95
96
|
// Identify MCP-originated traffic so the platform can record a customer's
|
|
96
97
|
// first successful MCP connection (onboarding progress).
|
|
97
98
|
'X-Dailey-Source': 'mcp',
|
|
99
|
+
// Version fingerprint (2026-07-13 stale-client incident): lets the
|
|
100
|
+
// platform see which MCP versions are live in the field. A request with
|
|
101
|
+
// X-Dailey-Source: mcp but NO version header is a pre-1.20.7 client.
|
|
102
|
+
'X-Dailey-Client-Version': OWN_VERSION,
|
|
98
103
|
};
|
|
99
104
|
// Manager / managed-accounts: when an active account is set, scope every
|
|
100
105
|
// request to it. The server verifies a live consent grant; absent header =
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAA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AAC,CAAC,UAAU,OAAO,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,OAAO,EAAE,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import {
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { hasCredentials, getActiveAccount, setActiveAccount } from './api.js';
|
|
6
|
+
import { OWN_VERSION, checkForNewerVersion, outdatedNotice } from './version.js';
|
|
5
7
|
import { registerAuthTools } from './tools/auth.js';
|
|
6
8
|
import { registerAccountTools } from './tools/accounts.js';
|
|
7
9
|
import { registerProjectTools } from './tools/projects.js';
|
|
@@ -99,10 +101,59 @@ async function preflight() {
|
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
await preflight();
|
|
104
|
+
// Staleness self-check (2026-07-13 incident: sessions silently ran a months-old
|
|
105
|
+
// MCP and the agent concluded platform features didn't exist). Fail-open + hard
|
|
106
|
+
// timeout; when outdated, the notice rides the server instructions so the AGENT
|
|
107
|
+
// itself tells the user to update instead of silently missing tools.
|
|
108
|
+
const newerVersion = await checkForNewerVersion();
|
|
109
|
+
if (newerVersion) {
|
|
110
|
+
process.stderr.write(`dailey-mcp: v${OWN_VERSION} is outdated (latest v${newerVersion})\n`);
|
|
111
|
+
}
|
|
102
112
|
const server = new McpServer({
|
|
103
113
|
name: 'dailey-os',
|
|
104
|
-
version:
|
|
105
|
-
});
|
|
114
|
+
version: OWN_VERSION,
|
|
115
|
+
}, newerVersion ? { instructions: outdatedNotice(newerVersion) } : undefined);
|
|
116
|
+
// ─── Account-context hardening (2026-07-13, Muenda's "which account am I in?") ───
|
|
117
|
+
// Two invariants, applied uniformly to ALL tools via this registration wrapper:
|
|
118
|
+
// 1. Every tool accepts an optional `account` param — a STATELESS, per-call
|
|
119
|
+
// scope to a managed account (set → run → restore). Agents no longer have
|
|
120
|
+
// to rely on dailey_use_account session state being what they remember.
|
|
121
|
+
// 2. Every tool result is prefixed with `[account: <effective>]` so the model
|
|
122
|
+
// (and the human reading the transcript) always sees which account the
|
|
123
|
+
// call actually ran against. Wrong-account work becomes visible instantly.
|
|
124
|
+
// Tools that declare their own `account` param (the WP tools) keep their schema;
|
|
125
|
+
// the wrapper still enforces the per-call set/restore around them.
|
|
126
|
+
{
|
|
127
|
+
const originalTool = server.tool.bind(server);
|
|
128
|
+
server.tool = (name, description, schema, handler) => {
|
|
129
|
+
const augmented = 'account' in schema
|
|
130
|
+
? schema
|
|
131
|
+
: {
|
|
132
|
+
...schema,
|
|
133
|
+
account: z.string().optional().describe('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.'),
|
|
134
|
+
};
|
|
135
|
+
return originalTool(name, description, augmented, async (args, extra) => {
|
|
136
|
+
const requested = typeof args?.account === 'string' && args.account.trim() ? args.account.trim() : undefined;
|
|
137
|
+
const prev = getActiveAccount();
|
|
138
|
+
if (requested)
|
|
139
|
+
setActiveAccount(requested);
|
|
140
|
+
try {
|
|
141
|
+
const result = await handler(args, extra);
|
|
142
|
+
const effective = requested ?? getActiveAccount() ?? 'self (your own account)';
|
|
143
|
+
if (result?.content?.length && result.content[0]?.type === 'text') {
|
|
144
|
+
result.content[0].text = `[account: ${effective}]\n${result.content[0].text}`;
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
// Restore ONLY when this call temporarily overrode the session scope —
|
|
150
|
+
// dailey_use_account itself must keep its session-setting behavior.
|
|
151
|
+
if (requested)
|
|
152
|
+
setActiveAccount(prev);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
}
|
|
106
157
|
// Core + identity
|
|
107
158
|
registerAuthTools(server);
|
|
108
159
|
registerAccountTools(server);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,sBAAsB,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 @@
|
|
|
1
|
+
export declare const OWN_VERSION: string;
|
|
2
|
+
/**
|
|
3
|
+
* Returns the newer registry version when this copy is outdated, else null.
|
|
4
|
+
* Fail-open: any network error / timeout returns null (never blocks startup).
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkForNewerVersion(timeoutMs?: number): Promise<string | null>;
|
|
7
|
+
/** The notice shown to the agent (via server instructions) when outdated. */
|
|
8
|
+
export declare function outdatedNotice(latest: string): string;
|
|
9
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,WAAW,EAAE,MAMtB,CAAC;AAaL;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,SAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBnF;AAED,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQrD"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
export const OWN_VERSION = (() => {
|
|
18
|
+
try {
|
|
19
|
+
return require('../package.json').version ?? '0.0.0';
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return '0.0.0';
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
/** Numeric semver compare (a<b → -1). Non-numeric parts compare as 0. */
|
|
26
|
+
function cmpSemver(a, b) {
|
|
27
|
+
const pa = a.split('.').map((x) => parseInt(x, 10) || 0);
|
|
28
|
+
const pb = b.split('.').map((x) => parseInt(x, 10) || 0);
|
|
29
|
+
for (let i = 0; i < 3; i++) {
|
|
30
|
+
if ((pa[i] ?? 0) < (pb[i] ?? 0))
|
|
31
|
+
return -1;
|
|
32
|
+
if ((pa[i] ?? 0) > (pb[i] ?? 0))
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns the newer registry version when this copy is outdated, else null.
|
|
39
|
+
* Fail-open: any network error / timeout returns null (never blocks startup).
|
|
40
|
+
*/
|
|
41
|
+
export async function checkForNewerVersion(timeoutMs = 1500) {
|
|
42
|
+
try {
|
|
43
|
+
const ctrl = new AbortController();
|
|
44
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
45
|
+
const res = await fetch('https://registry.npmjs.org/@daileyos%2Fmcp-server/latest', {
|
|
46
|
+
signal: ctrl.signal,
|
|
47
|
+
headers: { Accept: 'application/json' },
|
|
48
|
+
});
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
if (!res.ok)
|
|
51
|
+
return null;
|
|
52
|
+
const data = (await res.json());
|
|
53
|
+
const latest = data?.version;
|
|
54
|
+
if (latest && cmpSemver(OWN_VERSION, latest) < 0)
|
|
55
|
+
return latest;
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The notice shown to the agent (via server instructions) when outdated. */
|
|
63
|
+
export function outdatedNotice(latest) {
|
|
64
|
+
return (`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
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAW,CAAC,GAAG,EAAE;IACvC,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL,yEAAyE;AACzE,SAAS,SAAS,CAAC,CAAS,EAAE,CAAS;IACrC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,IA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AAC;IACd,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO,CACL,uCAAuC,WAAW,UAAU,MAAM,iBAAiB;QACnF,sEAAsE;QACtE,qDAAqD,WAAW,QAAQ,MAAM,MAAM;QACpF,iFAAiF;QACjF,uFAAuF,CACxF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { OWN_VERSION } from './version.js';
|
|
4
5
|
|
|
5
6
|
const API_URL = process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api';
|
|
6
7
|
const DAILEY_EMAIL = process.env.DAILEY_EMAIL;
|
|
@@ -110,6 +111,10 @@ export async function apiRequest<T = unknown>(
|
|
|
110
111
|
// Identify MCP-originated traffic so the platform can record a customer's
|
|
111
112
|
// first successful MCP connection (onboarding progress).
|
|
112
113
|
'X-Dailey-Source': 'mcp',
|
|
114
|
+
// Version fingerprint (2026-07-13 stale-client incident): lets the
|
|
115
|
+
// platform see which MCP versions are live in the field. A request with
|
|
116
|
+
// X-Dailey-Source: mcp but NO version header is a pre-1.20.7 client.
|
|
117
|
+
'X-Dailey-Client-Version': OWN_VERSION,
|
|
113
118
|
};
|
|
114
119
|
// Manager / managed-accounts: when an active account is set, scope every
|
|
115
120
|
// request to it. The server verifies a live consent grant; absent header =
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { hasCredentials, getActiveAccount, setActiveAccount } from './api.js';
|
|
8
|
+
import { OWN_VERSION, checkForNewerVersion, outdatedNotice } from './version.js';
|
|
7
9
|
import { registerAuthTools } from './tools/auth.js';
|
|
8
10
|
import { registerAccountTools } from './tools/accounts.js';
|
|
9
11
|
import { registerProjectTools } from './tools/projects.js';
|
|
@@ -114,10 +116,64 @@ async function preflight(): Promise<void> {
|
|
|
114
116
|
|
|
115
117
|
await preflight();
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
// Staleness self-check (2026-07-13 incident: sessions silently ran a months-old
|
|
120
|
+
// MCP and the agent concluded platform features didn't exist). Fail-open + hard
|
|
121
|
+
// timeout; when outdated, the notice rides the server instructions so the AGENT
|
|
122
|
+
// itself tells the user to update instead of silently missing tools.
|
|
123
|
+
const newerVersion = await checkForNewerVersion();
|
|
124
|
+
if (newerVersion) {
|
|
125
|
+
process.stderr.write(`dailey-mcp: v${OWN_VERSION} is outdated (latest v${newerVersion})\n`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const server = new McpServer(
|
|
129
|
+
{
|
|
130
|
+
name: 'dailey-os',
|
|
131
|
+
version: OWN_VERSION,
|
|
132
|
+
},
|
|
133
|
+
newerVersion ? { instructions: outdatedNotice(newerVersion) } : undefined,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// ─── Account-context hardening (2026-07-13, Muenda's "which account am I in?") ───
|
|
137
|
+
// Two invariants, applied uniformly to ALL tools via this registration wrapper:
|
|
138
|
+
// 1. Every tool accepts an optional `account` param — a STATELESS, per-call
|
|
139
|
+
// scope to a managed account (set → run → restore). Agents no longer have
|
|
140
|
+
// to rely on dailey_use_account session state being what they remember.
|
|
141
|
+
// 2. Every tool result is prefixed with `[account: <effective>]` so the model
|
|
142
|
+
// (and the human reading the transcript) always sees which account the
|
|
143
|
+
// call actually ran against. Wrong-account work becomes visible instantly.
|
|
144
|
+
// Tools that declare their own `account` param (the WP tools) keep their schema;
|
|
145
|
+
// the wrapper still enforces the per-call set/restore around them.
|
|
146
|
+
{
|
|
147
|
+
const originalTool = server.tool.bind(server);
|
|
148
|
+
(server as any).tool = (name: string, description: string, schema: Record<string, unknown>, handler: (...a: any[]) => any) => {
|
|
149
|
+
const augmented = 'account' in schema
|
|
150
|
+
? schema
|
|
151
|
+
: {
|
|
152
|
+
...schema,
|
|
153
|
+
account: z.string().optional().describe(
|
|
154
|
+
'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.',
|
|
155
|
+
),
|
|
156
|
+
};
|
|
157
|
+
return originalTool(name, description, augmented as any, async (args: any, extra: any) => {
|
|
158
|
+
const requested: string | undefined =
|
|
159
|
+
typeof args?.account === 'string' && args.account.trim() ? args.account.trim() : undefined;
|
|
160
|
+
const prev = getActiveAccount();
|
|
161
|
+
if (requested) setActiveAccount(requested);
|
|
162
|
+
try {
|
|
163
|
+
const result = await handler(args, extra);
|
|
164
|
+
const effective = requested ?? getActiveAccount() ?? 'self (your own account)';
|
|
165
|
+
if (result?.content?.length && result.content[0]?.type === 'text') {
|
|
166
|
+
result.content[0].text = `[account: ${effective}]\n${result.content[0].text}`;
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
} finally {
|
|
170
|
+
// Restore ONLY when this call temporarily overrode the session scope —
|
|
171
|
+
// dailey_use_account itself must keep its session-setting behavior.
|
|
172
|
+
if (requested) setActiveAccount(prev);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
}
|
|
121
177
|
|
|
122
178
|
// Core + identity
|
|
123
179
|
registerAuthTools(server);
|
package/src/version.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
}
|