@stratta/mcp 0.9.4 → 0.9.5

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/README.md CHANGED
@@ -56,6 +56,20 @@ precedence over the saved key):
56
56
  claude mcp add stratta --scope user --env STRATTA_API_KEY=sk_strt_xxx -- npx -y @stratta/mcp
57
57
  ```
58
58
 
59
+ ## Staying up to date
60
+
61
+ `npx -y @stratta/mcp` fetches the published package, but npx caches what it
62
+ resolved, so a server can keep launching a version npm replaced weeks ago with
63
+ nothing to tell you.
64
+
65
+ ```bash
66
+ npx -y @stratta/mcp update
67
+ ```
68
+
69
+ Prints the version you are running and the one npm serves, and fetches the new
70
+ one if they differ. Restart your agent afterwards. The server also mentions it
71
+ on stderr at startup when it notices it is behind.
72
+
59
73
  ### Claude Desktop
60
74
 
61
75
  Sign in once from a terminal — the desktop app cannot prompt you interactively:
package/dist/index.js CHANGED
@@ -93,14 +93,31 @@ for (const def of [...readTools, ...dossierTools, ...ingestTools]) {
93
93
  (args) => call(def, args));
94
94
  }
95
95
  async function main() {
96
- if (process.argv[2] === 'login') {
96
+ const command = process.argv[2];
97
+ if (command === 'login') {
97
98
  const { runLogin } = await import('./login.js');
98
99
  await runLogin(process.argv.slice(3));
99
100
  return;
100
101
  }
102
+ if (command === 'update') {
103
+ const { runUpdate } = await import('./update.js');
104
+ await runUpdate(packageVersion());
105
+ return;
106
+ }
107
+ // `--version` because that is what everyone types first, and because
108
+ // `update` needs a cheap way to make npx materialise a given version.
109
+ if (command === '--version' || command === '-v' || command === 'version') {
110
+ console.log(packageVersion());
111
+ return;
112
+ }
101
113
  await server.connect(new StdioServerTransport());
102
114
  // Stderr only; stdout carries the MCP protocol.
103
115
  console.error(`[stratta-mcp] v${packageVersion()} listening on stdio`);
116
+ // After connect, never before: the check reaches the network, and a server
117
+ // that starts slowly because of a version lookup is a worse problem than an
118
+ // out-of-date one.
119
+ const { noticeIfOutdated } = await import('./update.js');
120
+ noticeIfOutdated(packageVersion());
104
121
  }
105
122
  main().catch((err) => {
106
123
  console.error('[stratta-mcp] fatal:', err);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What version npm would serve right now, or null if we could not ask.
3
+ *
4
+ * Deliberately quiet about failures: this runs on a path where being offline,
5
+ * behind a proxy, or on a flaky connection is ordinary, and none of that is
6
+ * worth an error. A missed check is not a problem; a server that refuses to
7
+ * start because a version check failed would be.
8
+ */
9
+ export declare function latestPublished(timeoutMs?: number): Promise<string | null>;
10
+ /** Numeric compare, so 0.9.10 sorts above 0.9.9. */
11
+ export declare function isNewer(candidate: string, current: string): boolean;
12
+ /**
13
+ * Tell the user, on stderr, when they are running something old.
14
+ *
15
+ * Fire-and-forget from `main`: the server is already listening by the time
16
+ * this resolves, so a slow registry delays nothing. stdout carries the MCP
17
+ * protocol and must stay clean.
18
+ */
19
+ export declare function noticeIfOutdated(current: string): void;
20
+ /**
21
+ * `npx @stratta/mcp update`.
22
+ *
23
+ * npx caches a resolved package and reuses it, so `npx -y @stratta/mcp` can
24
+ * keep launching a version that npm replaced weeks ago — the user has no way
25
+ * to tell, and nothing tells them. This says which version is running, which
26
+ * one is published, and clears the cache entry so the next launch fetches the
27
+ * new one.
28
+ */
29
+ export declare function runUpdate(current: string): Promise<void>;
package/dist/update.js ADDED
@@ -0,0 +1,88 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ const REGISTRY = 'https://registry.npmjs.org/@stratta/mcp/latest';
3
+ /**
4
+ * What version npm would serve right now, or null if we could not ask.
5
+ *
6
+ * Deliberately quiet about failures: this runs on a path where being offline,
7
+ * behind a proxy, or on a flaky connection is ordinary, and none of that is
8
+ * worth an error. A missed check is not a problem; a server that refuses to
9
+ * start because a version check failed would be.
10
+ */
11
+ export async function latestPublished(timeoutMs = 3000) {
12
+ try {
13
+ const res = await fetch(REGISTRY, {
14
+ signal: AbortSignal.timeout(timeoutMs),
15
+ headers: { accept: 'application/json' },
16
+ });
17
+ if (!res.ok)
18
+ return null;
19
+ const body = (await res.json());
20
+ return body.version ?? null;
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ /** Numeric compare, so 0.9.10 sorts above 0.9.9. */
27
+ export function isNewer(candidate, current) {
28
+ const a = candidate.split('.').map(Number);
29
+ const b = current.split('.').map(Number);
30
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
31
+ const x = a[i] ?? 0;
32
+ const y = b[i] ?? 0;
33
+ if (x !== y)
34
+ return x > y;
35
+ }
36
+ return false;
37
+ }
38
+ /**
39
+ * Tell the user, on stderr, when they are running something old.
40
+ *
41
+ * Fire-and-forget from `main`: the server is already listening by the time
42
+ * this resolves, so a slow registry delays nothing. stdout carries the MCP
43
+ * protocol and must stay clean.
44
+ */
45
+ export function noticeIfOutdated(current) {
46
+ void latestPublished().then((latest) => {
47
+ if (!latest || !isNewer(latest, current))
48
+ return;
49
+ console.error(`[stratta-mcp] version ${latest} disponible (vous avez ${current}) — ` +
50
+ `lancez : npx -y @stratta/mcp update`);
51
+ });
52
+ }
53
+ /**
54
+ * `npx @stratta/mcp update`.
55
+ *
56
+ * npx caches a resolved package and reuses it, so `npx -y @stratta/mcp` can
57
+ * keep launching a version that npm replaced weeks ago — the user has no way
58
+ * to tell, and nothing tells them. This says which version is running, which
59
+ * one is published, and clears the cache entry so the next launch fetches the
60
+ * new one.
61
+ */
62
+ export async function runUpdate(current) {
63
+ console.log(`Version installée : ${current}`);
64
+ const latest = await latestPublished(8000);
65
+ if (!latest) {
66
+ console.log('Impossible de joindre npm. Vérifiez votre connexion et réessayez.');
67
+ process.exitCode = 1;
68
+ return;
69
+ }
70
+ console.log(`Dernière publiée : ${latest}`);
71
+ if (!isNewer(latest, current)) {
72
+ console.log('\nVous êtes à jour.');
73
+ return;
74
+ }
75
+ console.log('\nRécupération de la nouvelle version…');
76
+ // `npx -y pkg@version` bypasses whatever npx had cached for the bare name,
77
+ // and populates the cache with the new one in the same step.
78
+ const r = spawnSync(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['-y', `@stratta/mcp@${latest}`, '--version'], { stdio: 'inherit' });
79
+ if (r.status === 0) {
80
+ console.log(`\n@stratta/mcp ${latest} est prêt.\n` +
81
+ 'Redémarrez votre agent pour que le serveur reparte sur cette version.');
82
+ }
83
+ else {
84
+ console.log(`\nLa récupération a échoué. À lancer à la main :\n` +
85
+ ` npx -y @stratta/mcp@${latest}`);
86
+ process.exitCode = 1;
87
+ }
88
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stratta/mcp",
3
3
  "mcpName": "ch.stratta/mcp",
4
- "version": "0.9.4",
4
+ "version": "0.9.5",
5
5
  "description": "MCP server exposing the engineering norms your firm is licensed for (SIA / Eurocodes) to any MCP client, via Stratta TreeRAG.",
6
6
  "license": "UNLICENSED",
7
7
  "author": "SmartFlow <hello@stratta.ch>",