local-mcp 3.0.427 → 3.0.429
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 +3 -0
- package/index.js +32 -21
- package/package.json +5 -5
- package/setup.js +61 -111
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
| **Terminal** | `curl -fsSL 'https://local-mcp.com/install?ref=npm' \| bash` | One-line setup |
|
|
21
21
|
| **npx** | `npx -y local-mcp@latest setup` | Configuring AI clients from an existing Node environment |
|
|
22
22
|
|
|
23
|
+
**Windows without Node.js:** `npx` is not available there. Use the Windows installer instead: [`LMCP-Setup.exe`](https://download.local-mcp.com/LMCP-Setup.exe).
|
|
24
|
+
|
|
23
25
|
Auto-detects and configures Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, and Zed. Restart your AI client once.
|
|
24
26
|
|
|
25
27
|
> **Cursor users:** LMCP tools only appear in **Agent mode**. Open a new Composer window (⌘I) and make sure the mode selector shows **Agent** (not Chat or Edit). Without Agent mode, the tools are installed but invisible.
|
|
@@ -183,6 +185,7 @@ Full policy: **[local-mcp.com/en/privacy](https://local-mcp.com/en/privacy)**.
|
|
|
183
185
|
|
|
184
186
|
```bash
|
|
185
187
|
npx -y local-mcp@latest setup # configure all detected AI clients
|
|
188
|
+
npx -y local-mcp@latest link # link this machine to your LMCP account (a code you approve on the web)
|
|
186
189
|
npx -y local-mcp@latest update # how to update (npx -y local-mcp@latest)
|
|
187
190
|
npx -y local-mcp@latest status # show server status
|
|
188
191
|
```
|
package/index.js
CHANGED
|
@@ -123,7 +123,7 @@ const cmd = process.argv[2]
|
|
|
123
123
|
|
|
124
124
|
// Comandos que este wrapper entiende. Sin argumentos arranca el server MCP por stdio, que es
|
|
125
125
|
// como lo lanzan los clientes de IA — ese camino NO cambia.
|
|
126
|
-
const COMANDOS = ['setup', 'update', 'uninstall', 'status']
|
|
126
|
+
const COMANDOS = ['setup', 'link', 'update', 'uninstall', 'status']
|
|
127
127
|
const PEDIDOS_DE_AYUDA = ['--help', '-h', 'help']
|
|
128
128
|
|
|
129
129
|
// Evento de lanzamiento (launch-event.js, #11): cada lanzamiento del camino del server reporta
|
|
@@ -201,15 +201,18 @@ const SINONIMOS_DEL_SERVER = ['stdio']
|
|
|
201
201
|
function mostrarAyuda() {
|
|
202
202
|
console.log(`local-mcp — Local MCP Server
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
local-mcp
|
|
206
|
-
local-mcp stdio
|
|
207
|
-
local-mcp setup
|
|
208
|
-
local-mcp
|
|
209
|
-
local-mcp
|
|
210
|
-
local-mcp
|
|
211
|
-
|
|
212
|
-
local-mcp
|
|
204
|
+
Usage:
|
|
205
|
+
local-mcp start the MCP server over stdio (what an AI app does)
|
|
206
|
+
local-mcp stdio the same, said explicitly
|
|
207
|
+
local-mcp setup install and configure your AI apps
|
|
208
|
+
local-mcp link link this computer to your LMCP account (a code)
|
|
209
|
+
local-mcp link --approve approve a pending link on this computer
|
|
210
|
+
local-mcp link --deny decline a pending link on this computer
|
|
211
|
+
local-mcp status show the status
|
|
212
|
+
local-mcp update how to update (npx -y local-mcp@latest)
|
|
213
|
+
local-mcp uninstall uninstall
|
|
214
|
+
|
|
215
|
+
local-mcp --help this help`)
|
|
213
216
|
}
|
|
214
217
|
|
|
215
218
|
async function main() {
|
|
@@ -231,7 +234,7 @@ async function main() {
|
|
|
231
234
|
const pedidoDeAyuda = PEDIDOS_DE_AYUDA.includes(cmd)
|
|
232
235
|
mostrarAyuda()
|
|
233
236
|
if (!pedidoDeAyuda) {
|
|
234
|
-
console.error(`\
|
|
237
|
+
console.error(`\nUnknown command "${cmd}".`)
|
|
235
238
|
reportarLanzamiento('rejected-argument')
|
|
236
239
|
}
|
|
237
240
|
process.exit(pedidoDeAyuda ? 0 : 2)
|
|
@@ -246,11 +249,18 @@ async function main() {
|
|
|
246
249
|
process.exit(process.platform === 'linux' ? 1 : 0)
|
|
247
250
|
}
|
|
248
251
|
|
|
252
|
+
// #125: vuelve a mostrar el link y el código de la máquina y espera la aprobación (~2 min).
|
|
253
|
+
// Sale 0 como `status`: el estado está escrito en la salida, y un agente lo lee de ahí.
|
|
254
|
+
if (cmd === 'link') {
|
|
255
|
+
await require('./link').runLinkCommand(process.argv.slice(3))
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
|
|
249
259
|
// 3.0.423: el server viene dentro del paquete; no hay runtime en cache que borrar (ese directorio
|
|
250
260
|
// guarda el id de la máquina y el token del relay, que no son del server de npm).
|
|
251
261
|
if (cmd === 'update') {
|
|
252
|
-
console.log('
|
|
253
|
-
console.log('
|
|
262
|
+
console.log('The LMCP server ships inside the npm package. For the latest version: npx -y local-mcp@latest')
|
|
263
|
+
console.log('With the LMCP app installed, the app updates itself.')
|
|
254
264
|
return
|
|
255
265
|
}
|
|
256
266
|
|
|
@@ -293,23 +303,23 @@ async function main() {
|
|
|
293
303
|
? JSON.parse(fs.readFileSync(catalogFile, 'utf8'))
|
|
294
304
|
: await require('./setup')._fetchClientsCatalog()
|
|
295
305
|
if (!catalog) {
|
|
296
|
-
console.log('
|
|
306
|
+
console.log('Could not read the AI app catalog: the "local-mcp" entries in your AI apps stay; remove them by hand.')
|
|
297
307
|
} else {
|
|
298
308
|
const r = unconfigureClients(catalog)
|
|
299
|
-
for (const x of r.removed) console.log(`
|
|
300
|
-
for (const x of r.left) console.log(`
|
|
309
|
+
for (const x of r.removed) console.log(`Removed the local-mcp entry from ${x.client}: ${x.file}`)
|
|
310
|
+
for (const x of r.left) console.log(`Left in ${x.client}${x.file ? ' (' + x.file + ')' : ''}: ${x.reason}; remove "local-mcp" by hand.`)
|
|
301
311
|
}
|
|
302
312
|
} catch (e) {
|
|
303
|
-
console.log('
|
|
313
|
+
console.log('Could not remove the entries from your AI apps: ' + e.message)
|
|
304
314
|
}
|
|
305
315
|
|
|
306
316
|
if (fs.existsSync(CACHE_DIR)) {
|
|
307
317
|
fs.rmSync(CACHE_DIR, { recursive: true, force: true })
|
|
308
|
-
console.log(`
|
|
318
|
+
console.log(`Removed the runtime from ${CACHE_DIR}`)
|
|
309
319
|
} else {
|
|
310
|
-
console.log('No
|
|
320
|
+
console.log('No cached runtime.')
|
|
311
321
|
}
|
|
312
|
-
console.log('Local MCP
|
|
322
|
+
console.log('Local MCP uninstalled.')
|
|
313
323
|
return
|
|
314
324
|
}
|
|
315
325
|
|
|
@@ -324,7 +334,8 @@ async function main() {
|
|
|
324
334
|
console.log(`LMCP v${s.version} — ${s.server}`)
|
|
325
335
|
} catch { console.log(data) }
|
|
326
336
|
})
|
|
327
|
-
|
|
337
|
+
// #124 (7): without the LMCP app nothing listens on 8765, and that is the npx mode, not a failure.
|
|
338
|
+
}).on('error', () => console.log(`LMCP v${require('./package.json').version} — no background service: the server is started by your AI app when it needs it (npx -y local-mcp@latest).`))
|
|
328
339
|
return
|
|
329
340
|
}
|
|
330
341
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "local-mcp",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.429",
|
|
4
4
|
"description": "Let ChatGPT, Claude, Cursor & any MCP client actually use your Mac or Windows PC — read & reply to email, manage your calendar, text over iMessage, find files, work with Teams, Slack, Notion & Office. Runs locally, no API keys.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"node": ">=20"
|
|
26
26
|
},
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"local-mcp-darwin-arm64": "3.0.
|
|
29
|
-
"local-mcp-darwin-x64": "3.0.
|
|
30
|
-
"local-mcp-windows-x64": "3.0.
|
|
31
|
-
"local-mcp-windows-arm64": "3.0.
|
|
28
|
+
"local-mcp-darwin-arm64": "3.0.429",
|
|
29
|
+
"local-mcp-darwin-x64": "3.0.429",
|
|
30
|
+
"local-mcp-windows-x64": "3.0.429",
|
|
31
|
+
"local-mcp-windows-arm64": "3.0.429"
|
|
32
32
|
},
|
|
33
33
|
"os": [
|
|
34
34
|
"darwin",
|
package/setup.js
CHANGED
|
@@ -13,6 +13,7 @@ const path = require('path')
|
|
|
13
13
|
const os = require('os')
|
|
14
14
|
const { execSync, execFileSync } = require('child_process')
|
|
15
15
|
const download = require('./download')
|
|
16
|
+
const { runLink } = require('./link')
|
|
16
17
|
|
|
17
18
|
const HOME = os.homedir()
|
|
18
19
|
const NPX_COMMAND = 'npx'
|
|
@@ -25,11 +26,19 @@ const NPX_ARGS = ['-y', 'local-mcp@latest']
|
|
|
25
26
|
function _resolveNpxPath() {
|
|
26
27
|
try {
|
|
27
28
|
const candidate = path.join(path.dirname(process.execPath), 'npx')
|
|
28
|
-
if (fs.existsSync(candidate)) return candidate
|
|
29
|
+
if (fs.existsSync(candidate)) return _stableNpxPath(candidate)
|
|
29
30
|
} catch {}
|
|
30
31
|
return NPX_COMMAND
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
// #124 (4): Homebrew's process.execPath is the versioned Cellar path; the next `brew upgrade node@22`
|
|
35
|
+
// deletes it and every configured client breaks. opt/<formula> is Homebrew's stable link to it.
|
|
36
|
+
function _stableNpxPath(p, exists = fs.existsSync) {
|
|
37
|
+
const m = /^(.*)\/Cellar\/([^/]+)\/[^/]+\/bin\/([^/]+)$/.exec(p)
|
|
38
|
+
const opt = m && `${m[1]}/opt/${m[2]}/bin/${m[3]}`
|
|
39
|
+
return opt && exists(opt) ? opt : p
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
// Write a shell launcher script that wraps npx with a Node version check and
|
|
34
43
|
// curl-based telemetry. This gives us visibility into failures that happen
|
|
35
44
|
// BEFORE Node loads our code (e.g. old nvm default in Claude Desktop's PATH).
|
|
@@ -49,7 +58,9 @@ function _writeLaunchScript(npxAbsPath, cacheDir, isWin = _IS_WIN) {
|
|
|
49
58
|
// appended a SECOND copy of whatever the MCP host passed, so a client
|
|
50
59
|
// configured with args ended up running `npx -y local-mcp@latest -y
|
|
51
60
|
// local-mcp@latest` (#1394 §C).
|
|
52
|
-
|
|
61
|
+
// #124 (4): winget's Node lives in a versioned folder; if it is gone, the npx on PATH. goto, not
|
|
62
|
+
// an if (...) block: a path with parentheses (Program Files (x86)) would close the block.
|
|
63
|
+
const script = `@echo off\r\nif not exist "${npxAbsPath}" goto path_npx\r\n"${npxAbsPath}" -y local-mcp@latest\r\nexit /b %errorlevel%\r\n:path_npx\r\nnpx -y local-mcp@latest\r\n`
|
|
53
64
|
fs.writeFileSync(cmdPath, script)
|
|
54
65
|
return cmdPath
|
|
55
66
|
} catch {
|
|
@@ -73,7 +84,10 @@ function _writeLaunchScript(npxAbsPath, cacheDir, isWin = _IS_WIN) {
|
|
|
73
84
|
' printf \'LMCP requires Node 16+. Current: %s\\nFix: nvm alias default 22 && nvm uninstall %s — then restart Claude Desktop.\\n\' "$NODE_VER" "$NODE_VER" >&2',
|
|
74
85
|
' exit 1',
|
|
75
86
|
'fi',
|
|
76
|
-
|
|
87
|
+
// #124 (4): the path written here can disappear (a Node upgrade); then the npx on PATH.
|
|
88
|
+
`NPX="${npxAbsPath}"`,
|
|
89
|
+
'[ -x "$NPX" ] || NPX="$(command -v npx || echo npx)"',
|
|
90
|
+
'exec "$NPX" -y local-mcp@latest "$@"',
|
|
77
91
|
].join('\n') + '\n'
|
|
78
92
|
fs.writeFileSync(launcherPath, script, { mode: 0o755 })
|
|
79
93
|
return launcherPath
|
|
@@ -92,7 +106,7 @@ const _IS_WIN = process.platform === 'win32'
|
|
|
92
106
|
const _IS_MAC = process.platform === 'darwin'
|
|
93
107
|
const _APPDATA = process.env.APPDATA || path.join(HOME, 'AppData', 'Roaming')
|
|
94
108
|
|
|
95
|
-
// Where LMCP's own config.json (
|
|
109
|
+
// Where LMCP's own config.json (cloud_token, activation_checklist_pending)
|
|
96
110
|
// lives. Used to hardcode the macOS "Library/Application Support" path unconditionally, so
|
|
97
111
|
// on Windows it resolved to a nonsense C:\Users\X\Library\...\Local MCP directory that
|
|
98
112
|
// nothing reads or creates on its own (#1390). Parameterized so it's testable without
|
|
@@ -416,6 +430,7 @@ async function runSetup(opts = {}) {
|
|
|
416
430
|
const configured = []
|
|
417
431
|
const failed = []
|
|
418
432
|
let clientsRun = null // #3212: en la Mac, el reporte del binario
|
|
433
|
+
let clientes = []
|
|
419
434
|
// #3212 — Windows now shares the exact darwin path: the go-server binary
|
|
420
435
|
// decides and writes (lmcp-server --configure-clients --json), never a
|
|
421
436
|
// second JS-side client list. Linux has no runtime-native writer yet
|
|
@@ -423,7 +438,7 @@ async function runSetup(opts = {}) {
|
|
|
423
438
|
if (process.platform === 'darwin' || _IS_WIN) {
|
|
424
439
|
const launcher = _launcherArgsForConfigureClients(process.platform, stableCommand, stableArgs)
|
|
425
440
|
clientsRun = runConfigureClients(_findServerBinary(_embeddedServer || _bundled, CACHE_DIR), launcher.command, launcher.args)
|
|
426
|
-
|
|
441
|
+
clientes = (clientsRun.report && clientsRun.report.clients) || []
|
|
427
442
|
_trackSetupStep('detect', clientsRun.runtime === 'ok' ? 'ok' : clientsRun.runtime, '', {
|
|
428
443
|
clientsFound: clientes.filter(c => c.status !== 'not_installed').map(c => c.id),
|
|
429
444
|
clientsNotFound: clientes.filter(c => c.status === 'not_installed').map(c => c.id),
|
|
@@ -444,7 +459,7 @@ async function runSetup(opts = {}) {
|
|
|
444
459
|
}
|
|
445
460
|
}
|
|
446
461
|
if (clientsRun.runtime !== 'ok') {
|
|
447
|
-
console.error(`⚠ AI apps not configured yet (${clientsRun.runtime}) —
|
|
462
|
+
console.error(`⚠ AI apps not configured yet (${clientsRun.runtime}) — run 'npx -y local-mcp@latest setup' again, or see https://local-mcp.com/setup`)
|
|
448
463
|
} else if (clientes.length > 0 && clientes.every(c => c.status === 'not_installed')) {
|
|
449
464
|
console.log('\n No AI client detected yet — LMCP is installed and ready.')
|
|
450
465
|
console.log(' Install one (Claude Desktop, Cursor, VS Code...), then run:')
|
|
@@ -456,33 +471,24 @@ async function runSetup(opts = {}) {
|
|
|
456
471
|
const cfgDir = _localMcpConfigDir()
|
|
457
472
|
const cfgFile = path.join(cfgDir, 'config.json')
|
|
458
473
|
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
if (email) {
|
|
462
|
-
try {
|
|
463
|
-
const r = _safeReadConfig(cfgFile)
|
|
464
|
-
const cfg = r.data || {}
|
|
465
|
-
if (!cfg.license_email) {
|
|
466
|
-
cfg.license_email = email
|
|
467
|
-
_atomicWriteConfig(cfgFile, cfg)
|
|
468
|
-
console.log(`✓ Email saved: ${email}`)
|
|
469
|
-
}
|
|
470
|
-
} catch { /* config not created yet — will be created on first run */ }
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// Interactive email prompt removed (2026-06-05) — same change already made in
|
|
474
|
-
// install.sh on 2026-04-19. It paused `curl | bash` up to 30s on a confusing
|
|
475
|
-
// mid-install prompt while ground-truth telemetry showed ~98% of machines that
|
|
476
|
-
// hit it reached a heartbeat anyway (no conversion impact). Email is still
|
|
477
|
-
// captured non-interactively: via LMCP_EMAIL above, the anon tunnel register,
|
|
478
|
-
// and the tray/settings UI later.
|
|
474
|
+
// #120 (Darío, 2026-10-28): no email from the environment or a prompt. The account comes from
|
|
475
|
+
// signing in on the web (My LMCP); the machine links by download token or device code.
|
|
479
476
|
|
|
480
477
|
// Health check — verify binary works before showing success
|
|
481
|
-
const healthOk = _runHealthCheck()
|
|
478
|
+
const healthOk = _runHealthCheck(_findServerBinary(_embeddedServer || _bundled, CACHE_DIR))
|
|
482
479
|
_trackSetupStep('binary_health', healthOk ? 'ok' : 'failed', '', {})
|
|
483
480
|
|
|
481
|
+
// #125 (decisión «A»): the machine links to the person's account with a code, printed for them and
|
|
482
|
+
// for the agent running the setup; it waits up to ~2 min for the approval on the web.
|
|
483
|
+
const accountLink = await runLink({
|
|
484
|
+
bin: _findServerBinary(_embeddedServer || _bundled, CACHE_DIR),
|
|
485
|
+
track: (status, error) => _trackSetupStep('account_link', status, '', error ? { error } : {}),
|
|
486
|
+
})
|
|
487
|
+
|
|
484
488
|
// setup_complete summary
|
|
485
|
-
|
|
489
|
+
const fin = _setupCompleteStatus(clientsRun, clientes)
|
|
490
|
+
_trackSetupStep('setup_complete', fin.status, '', {
|
|
491
|
+
error: fin.error,
|
|
486
492
|
clientsFound: configured,
|
|
487
493
|
clientsNotFound: failed.map(f => f.name || f),
|
|
488
494
|
})
|
|
@@ -578,21 +584,11 @@ async function runSetup(opts = {}) {
|
|
|
578
584
|
// npx also downloads no proxies and launches no client (#112).
|
|
579
585
|
|
|
580
586
|
// Anon-first cloud relay activation (replaces the interactive email prompt
|
|
581
|
-
// removed 2026-04-19).
|
|
582
|
-
//
|
|
583
|
-
// can attach an email later via the tray or /settings for cross-Mac
|
|
584
|
-
// sync. Non-fatal on failure — the install still
|
|
587
|
+
// removed 2026-04-19). Register an anonymous tunnel token keyed on
|
|
588
|
+
// machine_id so cloud relay comes online immediately. Non-fatal on failure — the install still
|
|
585
589
|
// succeeds and the server can retry at startup.
|
|
586
|
-
// Provisioning is ALWAYS anonymous
|
|
587
|
-
// (#
|
|
588
|
-
// cloud_token, depending on /tunnel/token minting one for that address on first contact — the
|
|
589
|
-
// very TOFU path being removed (a stranger can pre-register someone else's address and end up
|
|
590
|
-
// sharing the token):
|
|
591
|
-
// 1. `if (!email)` — an install that supplied LMCP_EMAIL never registered at all.
|
|
592
|
-
// 2. `alreadyLinked` — a config that already carried license_email was skipped too, even
|
|
593
|
-
// with no token. That one is easier to miss: it fires on the SECOND run of a machine
|
|
594
|
-
// whose email was saved a few lines above.
|
|
595
|
-
// Both fail silently: setup finishes, nothing is printed, the relay simply never comes up.
|
|
590
|
+
// Provisioning is ALWAYS anonymous — same change made in install.sh (#1083); setup never
|
|
591
|
+
// takes an email (#120). A skipped registration fails silently: the relay never comes up.
|
|
596
592
|
{
|
|
597
593
|
try {
|
|
598
594
|
// On darwin the token lives in config.json, read by the Swift tray. Off darwin
|
|
@@ -618,30 +614,15 @@ async function runSetup(opts = {}) {
|
|
|
618
614
|
console.log(' ✓ Cloud relay activated (anonymous)')
|
|
619
615
|
}
|
|
620
616
|
}
|
|
621
|
-
// Associate the email with this machine's token — the one just minted OR the one it
|
|
622
|
-
// already had. Outside the "no token yet" branch on purpose: a machine re-running setup
|
|
623
|
-
// (reinstall, upgrade, second attempt) already has a token, and nesting this inside meant
|
|
624
|
-
// its email was dropped without a sound. The cloud_token travels as proof of possession:
|
|
625
|
-
// /install-event has no auth, so that UPDATE refuses to touch a row unless the caller
|
|
626
|
-
// holds that machine's token.
|
|
627
|
-
if (email && token) await _associateEmail(email, token)
|
|
628
617
|
} catch { /* non-fatal */ }
|
|
629
618
|
|
|
630
|
-
//
|
|
631
|
-
//
|
|
632
|
-
if (!email) {
|
|
633
|
-
try {
|
|
634
|
-
const mid = _getMachineId()
|
|
635
|
-
if (mid) {
|
|
636
|
-
console.log(`\n \x1b[1m📧 Get update notifications:\x1b[0m https://local-mcp.com/settings?m=${mid}`)
|
|
637
|
-
}
|
|
638
|
-
} catch { /* non-fatal */ }
|
|
639
|
-
}
|
|
619
|
+
// #120: the account is created or signed in on the web; nothing here takes an email. #125: the
|
|
620
|
+
// machine's link to it was printed above (runLink).
|
|
640
621
|
}
|
|
641
622
|
|
|
642
623
|
// LMCP_METHOD lets install.sh pass 'curl' so we can distinguish it from
|
|
643
624
|
// a direct 'npx local-mcp setup' invocation in the analytics.
|
|
644
|
-
_pingInstall(configured, process.env.LMCP_METHOD || opts.method || 'npx-setup',
|
|
625
|
+
_pingInstall(configured, process.env.LMCP_METHOD || opts.method || 'npx-setup', binaryVersion)
|
|
645
626
|
|
|
646
627
|
// #3212 — el reporte para quien instaló sin mirar (un agente): qué quedó hecho y qué espera
|
|
647
628
|
// a la persona. Los permisos, sólo si los midió el tray. clientsRun is always set by this
|
|
@@ -655,6 +636,8 @@ async function runSetup(opts = {}) {
|
|
|
655
636
|
catalog: rep.catalog || null,
|
|
656
637
|
clients: rep.clients || [],
|
|
657
638
|
permissions: trayPermissions || 'unknown_until_tray_runs',
|
|
639
|
+
// #125: what the agent hands to the person (the code is theirs to type; never telemetry).
|
|
640
|
+
account_link: accountLink,
|
|
658
641
|
}
|
|
659
642
|
process.stdout.write(JSON.stringify(out) + '\n')
|
|
660
643
|
}
|
|
@@ -669,7 +652,9 @@ async function runSetup(opts = {}) {
|
|
|
669
652
|
// too, which would have fallen through to stdio mode and hung until the timeout (#1390
|
|
670
653
|
// finding 3), on top of checking a path+name (local-mcp-server, no .exe) the go-server
|
|
671
654
|
// binary never has.
|
|
672
|
-
function _healthCheckSpec(platform = process.platform, home = HOME, cacheDir = download.CACHE_DIR) {
|
|
655
|
+
function _healthCheckSpec(platform = process.platform, home = HOME, cacheDir = download.CACHE_DIR, found = null) {
|
|
656
|
+
// #124 (2): the binary setup found (bundled in npm since 3.0.423); the paths below are the fallback.
|
|
657
|
+
if (found) return { binPath: found, args: platform === 'darwin' ? ['--export-tools'] : ['--version'] }
|
|
673
658
|
if (platform === 'darwin') {
|
|
674
659
|
return { binPath: path.join(home, '.local', 'share', 'local-mcp', 'bin', 'local-mcp-server'), args: ['--export-tools'] }
|
|
675
660
|
}
|
|
@@ -677,9 +662,18 @@ function _healthCheckSpec(platform = process.platform, home = HOME, cacheDir = d
|
|
|
677
662
|
return { binPath: path.join(cacheDir, binName), args: ['--version'] }
|
|
678
663
|
}
|
|
679
664
|
|
|
680
|
-
|
|
665
|
+
// #124 (3): a client already configured by an earlier install is set up, not a failure; a failure
|
|
666
|
+
// says why in `error` (Windows reported failed with setup exiting 0).
|
|
667
|
+
function _setupCompleteStatus(clientsRun, clientes) {
|
|
668
|
+
if (clientes.some(c => c.status === 'configured' || c.status === 'already')) return { status: 'ok' }
|
|
669
|
+
if (!clientsRun || clientsRun.runtime !== 'ok') return { status: 'failed', error: 'runtime_' + ((clientsRun && clientsRun.runtime) || 'none') }
|
|
670
|
+
if (clientes.every(c => c.status === 'not_installed')) return { status: 'failed', error: 'no_client_detected' }
|
|
671
|
+
return { status: 'failed', error: 'clients_failed' }
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function _runHealthCheck(found) {
|
|
681
675
|
try {
|
|
682
|
-
const { binPath, args } = _healthCheckSpec()
|
|
676
|
+
const { binPath, args } = _healthCheckSpec(process.platform, HOME, download.CACHE_DIR, found)
|
|
683
677
|
if (!fs.existsSync(binPath)) return false
|
|
684
678
|
const result = execFileSync(binPath, args, {
|
|
685
679
|
timeout: 10000,
|
|
@@ -736,48 +730,6 @@ function _getMachineId(deps = {}) {
|
|
|
736
730
|
return id
|
|
737
731
|
}
|
|
738
732
|
|
|
739
|
-
/// Associate an email with this machine's tunnel token, presenting the token as proof of
|
|
740
|
-
/// possession. Setup used to get this for free by registering WITH the email; now that
|
|
741
|
-
/// provisioning is always anonymous, the association has to happen explicitly or these users
|
|
742
|
-
/// stay anonymous forever on the backend.
|
|
743
|
-
///
|
|
744
|
-
/// /install-event has no auth, so the UPDATE behind it refuses to touch a row unless the caller
|
|
745
|
-
/// holds that machine's token — that guard is what makes calling this from an unauthenticated
|
|
746
|
-
/// installer safe. Calling it when the email is already set is harmless: the backend also guards
|
|
747
|
-
/// on (email IS NULL OR email = ''), so a no-op is the normal case here, not an error.
|
|
748
|
-
///
|
|
749
|
-
/// Non-fatal on every failure path: setup must finish regardless.
|
|
750
|
-
async function _associateEmail(email, token) {
|
|
751
|
-
return new Promise((resolve) => {
|
|
752
|
-
try {
|
|
753
|
-
const { https } = require('./user-agent')
|
|
754
|
-
const payload = JSON.stringify({
|
|
755
|
-
stage: 'email_prompt',
|
|
756
|
-
email_prompt_result: 'submitted',
|
|
757
|
-
email,
|
|
758
|
-
machine_id: _getMachineId(),
|
|
759
|
-
cloud_token: token,
|
|
760
|
-
source: 'npx-setup',
|
|
761
|
-
})
|
|
762
|
-
const req = https.request({
|
|
763
|
-
host: BACKEND_HOST,
|
|
764
|
-
port: 443,
|
|
765
|
-
method: 'POST',
|
|
766
|
-
path: '/install-event',
|
|
767
|
-
headers: {
|
|
768
|
-
'Content-Type': 'application/json',
|
|
769
|
-
'Content-Length': Buffer.byteLength(payload),
|
|
770
|
-
},
|
|
771
|
-
timeout: 5000,
|
|
772
|
-
}, (res) => { res.on('data', () => {}); res.on('end', () => resolve()) })
|
|
773
|
-
req.on('error', () => resolve())
|
|
774
|
-
req.on('timeout', () => { try { req.destroy() } catch {} resolve() })
|
|
775
|
-
req.write(payload)
|
|
776
|
-
req.end()
|
|
777
|
-
} catch { resolve() }
|
|
778
|
-
})
|
|
779
|
-
}
|
|
780
|
-
|
|
781
733
|
// Where install-ref is persisted for the LONG-RUNNING process to read back on every
|
|
782
734
|
// heartbeat. NOT the same directory on every platform: Mac's Swift heartbeat
|
|
783
735
|
// (HeartbeatManager.swift installRef) reads ~/.local/share/local-mcp/install-ref, no
|
|
@@ -811,7 +763,7 @@ function _writeCloudToken(cacheDir, token) {
|
|
|
811
763
|
/// activates without asking for an email (2026-04-19 anon-first rollout). The
|
|
812
764
|
/// token is keyed on the Mac's machine_id (IOPlatformUUID, shared via Keychain
|
|
813
765
|
/// with the Swift daemon). Returns the token string or '' on failure — callers
|
|
814
|
-
/// treat failure as non-fatal
|
|
766
|
+
/// treat failure as non-fatal.
|
|
815
767
|
async function _registerAnonToken() {
|
|
816
768
|
return new Promise((resolve) => {
|
|
817
769
|
const { https } = require('./user-agent')
|
|
@@ -962,7 +914,7 @@ function _trackRestartPrompted(clientName) {
|
|
|
962
914
|
} catch { /* non-fatal */ }
|
|
963
915
|
}
|
|
964
916
|
|
|
965
|
-
function _pingInstall(clients, method,
|
|
917
|
+
function _pingInstall(clients, method, binaryVersion = '') {
|
|
966
918
|
try {
|
|
967
919
|
const { https } = require('./user-agent')
|
|
968
920
|
const pkg = require('./package.json')
|
|
@@ -986,7 +938,6 @@ function _pingInstall(clients, method, email = '', binaryVersion = '') {
|
|
|
986
938
|
method: method,
|
|
987
939
|
clients_configured: clients,
|
|
988
940
|
machine_id: machineId,
|
|
989
|
-
email: email || '',
|
|
990
941
|
source: process.env.LMCP_SOURCE || '',
|
|
991
942
|
ref: _getRef(),
|
|
992
943
|
})
|
|
@@ -1033,7 +984,6 @@ function _pingInstall(clients, method, email = '', binaryVersion = '') {
|
|
|
1033
984
|
arch: process.arch,
|
|
1034
985
|
transport: 'stdio',
|
|
1035
986
|
ai_client: clients[0] || '',
|
|
1036
|
-
license_email: email || '',
|
|
1037
987
|
started_at: new Date().toISOString(),
|
|
1038
988
|
})
|
|
1039
989
|
const hbReq = https.request({
|
|
@@ -1073,11 +1023,11 @@ function _fetchClientsCatalog(totalMs = 4000) {
|
|
|
1073
1023
|
|
|
1074
1024
|
module.exports = {
|
|
1075
1025
|
runSetup, runConfigureClients, _findServerBinary, _launcherArgsForConfigureClients,
|
|
1076
|
-
_cmdExists, _runHealthCheck,
|
|
1026
|
+
_cmdExists, _runHealthCheck, _setupCompleteStatus, _stableNpxPath,
|
|
1077
1027
|
CLIENTS_REPORT_SCHEMA,
|
|
1078
1028
|
_notSupportedOnPlatformResult,
|
|
1079
1029
|
_launcherSpawnSpec, _writeLaunchScript, _writeLaunchSpec,
|
|
1080
1030
|
_getMachineId, _healthCheckSpec, _localMcpConfigDir, _installRefDir,
|
|
1081
1031
|
_cloudTokenPath, _readCachedCloudToken, _writeCloudToken, _registerAnonToken, _pingInstall,
|
|
1082
|
-
_fetchClientsCatalog,
|
|
1032
|
+
_fetchClientsCatalog, _trackSetupStep,
|
|
1083
1033
|
}
|