local-mcp 3.0.421 → 3.0.424

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/launch-event.js CHANGED
@@ -27,6 +27,11 @@ const OUTCOMES = ['spawned', 'rejected-argument', 'unsupported-node', 'unsupport
27
27
  const RAZONES = ['network', 'timeout', 'http-status', 'checksum-mismatch', 'disk-write',
28
28
  'permission-denied', 'binary-missing', 'early-exit', 'signal', 'uncaught-exception', 'init-failed', 'unknown']
29
29
  const CAMINO = 'npm-wrapper' // launch_path: quién arrancó el server
30
+ // 3.0.423 (lmcp-api#548): qué binario encontró el lanzamiento. El wrapper lo fija con fuente() en
31
+ // cuanto lo sabe; antes de saberlo (desinstalado, argumento rechazado) el evento no lo lleva.
32
+ const FUENTES = ['bundled', 'app_embedded', 'missing_platform']
33
+ let fuenteBinario
34
+ function fuente (valor) { if (FUENTES.includes(valor)) fuenteBinario = valor }
30
35
  const RE_VERSION = /^\d{1,3}\.\d{1,3}\.\d{1,5}$/
31
36
  const RE_MAQUINA = /^[A-Za-z0-9._:{}-]{1,64}$/
32
37
  const [TIMEOUT_MS, TOPE_MS] = [3000, 4000] // el pedido · la vida del proceso suelto
@@ -86,6 +91,8 @@ function cuerpo (outcome, clase, deps = {}) {
86
91
  }
87
92
  // Una razón fuera del conjunto no viaja, y un `spawned` no lleva razón; el evento sale igual.
88
93
  if (outcome !== 'spawned' && RAZONES.includes(deps.reason)) c.reason = deps.reason
94
+ const f = 'binarySource' in deps ? deps.binarySource : fuenteBinario
95
+ if (FUENTES.includes(f)) c.binary_source = f
89
96
  const id = 'machineId' in deps ? deps.machineId : idDeMaquina()
90
97
  if (typeof id === 'string' && RE_MAQUINA.test(id)) c.machine_id = id
91
98
  return c
@@ -178,6 +185,15 @@ function reportar (outcome, clase, { enProceso = false, reason } = {}) {
178
185
  if (enProceso) {
179
186
  const idEntorno = (process.env.LMCP_MACHINE_ID || '').trim()
180
187
  if (process.platform === 'win32' && !idEntorno) {
188
+ // lmcp-npm#92: el orden de _getMachineId sin el probe. Con el id guardado del cliente, ése;
189
+ // sin guardado y sin token, ninguno. El hardware se pide sólo para lo que reporta un 3.0.420.
190
+ const dl = require('./download')
191
+ const guardado = dl._readStoredMachineId(dl.CACHE_DIR)
192
+ if (guardado || !dl._readCachedCloudToken(dl.CACHE_DIR)) {
193
+ const c = cuerpo(outcome, clase, { machineId: guardado })
194
+ if (c) enviar(c, { soltar: true })
195
+ return
196
+ }
181
197
  pendiente = { outcome, clase }
182
198
  idDeHardwareWindows((id) => {
183
199
  if (!pendiente) return // ya salió por el proceso suelto
@@ -201,7 +217,9 @@ function silenciar () { reportado = true }
201
217
 
202
218
  function lanzarSuelto (outcome, clase, reason) {
203
219
  // La razón viaja como argumento sólo si es del conjunto: al proceso suelto no le llega texto libre.
204
- const hijo = cp.spawn(process.execPath, [__filename, outcome, clase, ...(RAZONES.includes(reason) ? [reason] : [])],
220
+ // La fuente del binario va detrás, también sólo si es del conjunto (RAZONES y FUENTES no se cruzan).
221
+ const hijo = cp.spawn(process.execPath, [__filename, outcome, clase, ...(RAZONES.includes(reason) ? [reason] : []),
222
+ ...(FUENTES.includes(fuenteBinario) ? [fuenteBinario] : [])],
205
223
  { detached: true, stdio: 'ignore', windowsHide: true })
206
224
  hijo.on('error', () => {})
207
225
  hijo.unref()
@@ -217,12 +235,15 @@ function soltarPendiente () {
217
235
  try { lanzarSuelto(outcome, clase) } catch {}
218
236
  }
219
237
 
220
- // Como programa es el proceso suelto: `node launch-event.js <outcome> <clase> [reason]`.
238
+ // Como programa es el proceso suelto: `node launch-event.js <outcome> <clase> [reason] [binary_source]`.
221
239
  if (require.main === module) {
222
240
  setTimeout(() => process.exit(0), TOPE_MS).unref()
223
- const c = apagado() ? null : cuerpo(process.argv[2], process.argv[3], { reason: process.argv[4] })
241
+ const c = apagado() ? null : cuerpo(process.argv[2], process.argv[3], {
242
+ reason: process.argv.slice(4).find(a => RAZONES.includes(a)),
243
+ binarySource: process.argv.slice(4).find(a => FUENTES.includes(a))
244
+ })
224
245
  if (c) enviar(c)
225
246
  }
226
247
 
227
- module.exports = { PLATAFORMAS, CLASES, OUTCOMES, RAZONES, CAMINO, razonDeError, RE_VERSION, RE_MAQUINA, TOPE_ID_MS, claseDeArgumento, apagado, cuerpo, reportar, silenciar, soltarPendiente,
248
+ module.exports = { PLATAFORMAS, CLASES, OUTCOMES, RAZONES, CAMINO, FUENTES, fuente, razonDeError, RE_VERSION, RE_MAQUINA, TOPE_ID_MS, claseDeArgumento, apagado, cuerpo, reportar, silenciar, soltarPendiente,
228
249
  _idDeHardwareWindows: idDeHardwareWindows } // costura de test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-mcp",
3
- "version": "3.0.421",
3
+ "version": "3.0.424",
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": {
@@ -13,6 +13,7 @@
13
13
  "files": [
14
14
  "index.js",
15
15
  "download.js",
16
+ "bundled.js",
16
17
  "setup.js",
17
18
  "launch-event.js",
18
19
  "user-agent.js",
@@ -23,6 +24,12 @@
23
24
  "engines": {
24
25
  "node": ">=20"
25
26
  },
27
+ "optionalDependencies": {
28
+ "local-mcp-darwin-arm64": "3.0.424",
29
+ "local-mcp-darwin-x64": "3.0.424",
30
+ "local-mcp-windows-x64": "3.0.424",
31
+ "local-mcp-windows-arm64": "3.0.424"
32
+ },
26
33
  "os": [
27
34
  "darwin",
28
35
  "win32"
package/setup.js CHANGED
@@ -318,8 +318,8 @@ async function runSetup(opts = {}) {
318
318
  process.exitCode = sinLinux.exitCode
319
319
  return
320
320
  }
321
- // Cross-platform: macOS configures the Swift tray + embedded server; Windows downloads the
322
- // go-server standalone binary (download.js) and writes the MCP client config.
321
+ // Cross-platform: macOS configures the Swift tray + embedded server; Windows installs the
322
+ // go-server from the npm platform package (bundled.js) and writes the MCP client config.
323
323
  const forceAll = opts.all || process.argv.includes('--all')
324
324
  const refArg = process.argv.find(a => a.startsWith('--ref='))
325
325
  if (refArg) process.env.LMCP_REF = refArg.split('=')[1]
@@ -354,7 +354,6 @@ async function runSetup(opts = {}) {
354
354
  console.error(` Fix: nvm alias default 22 && nvm uninstall ${process.version} (then relaunch Claude Desktop)\n`)
355
355
  }
356
356
 
357
- // Pre-download binary so first launch is instant
358
357
  // All clients use a shell launcher that wraps npx (self-healing if binary is
359
358
  // missing/broken, and surfaces telemetry + clear errors if Node is too old).
360
359
  let npxAbsPath = _resolveNpxPath() // baked into the launcher script
@@ -362,88 +361,52 @@ async function runSetup(opts = {}) {
362
361
  let stableArgs = NPX_ARGS
363
362
  let binaryVersion = ''
364
363
  // ADR-0004 phase 3 (darwin): if the notarized server is already embedded in
365
- // LocalMCPTray.app, skip pre-downloading + ad-hoc re-signing the standalone
366
- // binary — the launcher (→ npx → index.js) prefers the embedded one anyway,
367
- // and the ad-hoc copy is what resets Automation TCC. The tray is ensured later
368
- // in setup; on a fresh install where the .app isn't present yet this is null
369
- // and we keep the legacy pre-download as a fallback.
364
+ // LocalMCPTray.app, the launcher (→ npx → index.js) prefers it.
370
365
  const _embeddedServer = process.platform === 'darwin'
371
- ? [
372
- path.join(os.homedir(), 'Applications', 'LocalMCPTray.app', 'Contents', 'MacOS', 'local-mcp-server'),
373
- path.join('/Applications', 'LocalMCPTray.app', 'Contents', 'MacOS', 'local-mcp-server'),
374
- ].find(p => { try { return fs.statSync(p).isFile() } catch { return false } })
366
+ ? download.trayAppPaths().map(app => path.join(app, 'Contents', 'MacOS', 'local-mcp-server')).find(p => { try { return fs.statSync(p).isFile() } catch { return false } })
375
367
  : null
376
- try {
377
- const { ensureBinary, CACHE_DIR } = require('./download')
378
- if (_embeddedServer) {
379
- // Embedded server present — no standalone download needed. Still write the
380
- // launcher and record the embedded version for the npx fast-path skip.
381
- try {
382
- binaryVersion = fs.readFileSync(
383
- path.join(os.homedir(), '.local', 'share', 'local-mcp', 'tray', '.version'), 'utf8'
384
- ).trim()
385
- } catch {}
386
- process.stderr.write('✓ Using server embedded in LocalMCPTray.app\n\n')
387
- } else {
388
- process.stderr.write('Downloading LMCP runtime...\n')
389
- const { binPath, version: bv } = await ensureBinary()
390
- binaryVersion = bv || ''
368
+ // 3.0.423: the server comes in npm's platform package (bundled.js). Nothing is downloaded and
369
+ // nothing is re-signed: the Mac binary keeps its Developer ID signature.
370
+ const _bundled = (() => { const p = require('./bundled').bundledServerPath(); try { return p && fs.statSync(p).isFile() ? p : null } catch { return null } })()
371
+ const { CACHE_DIR } = download
372
+ if (_embeddedServer) {
373
+ try {
374
+ binaryVersion = fs.readFileSync(
375
+ path.join(os.homedir(), '.local', 'share', 'local-mcp', 'tray', '.version'), 'utf8'
376
+ ).trim()
377
+ } catch {}
378
+ process.stderr.write('✓ Using server embedded in the LMCP app\n\n')
379
+ } else if (_bundled) {
380
+ try { binaryVersion = fs.readFileSync(path.join(path.dirname(_bundled), 'VERSION'), 'utf8').trim() } catch {}
381
+ // Windows: the go-server's --configure-clients points every AI client at
382
+ // %LOCALAPPDATA%\local-mcp\bin\lmcp-server.exe (lmcp-win internal/aiclients ServerBinary), so
383
+ // setup — which the person asked for — puts the bundled binary there. A copy, not a download.
384
+ // The Mac clients go through the launcher → npx, which runs the bundled binary in place.
385
+ // With the LMCP app installed (lmcp-tray.exe in that folder) the app already put its server there
386
+ // and keeps it updated: setup leaves it alone.
387
+ if (_IS_WIN && !fs.existsSync(path.join(CACHE_DIR, 'lmcp-tray.exe'))) {
388
+ const dest = path.join(CACHE_DIR, 'lmcp-server.exe')
391
389
  try {
392
- // Copy binary to stable path (npx fast-path will exec it directly). darwin-only:
393
- // off darwin, ensureBinary() already writes the go-server binary directly at its
394
- // final name (lmcp-server / lmcp-server.exe) inside CACHE_DIR — index.js's fast
395
- // path looks for exactly that. This block, unguarded, used to also run there and
396
- // leave a dead second copy misnamed `local-mcp-server` (no .exe, never read by
397
- // anything) plus a doomed `codesign` call and an EISDIR migration written for a
398
- // curl-install bug that only ever existed on macOS's old Python installer (#1390).
399
- if (_IS_MAC) {
400
- const stablePath = path.join(CACHE_DIR, 'local-mcp-server')
401
- const tmpPath = stablePath + '.tmp'
402
- fs.copyFileSync(binPath, tmpPath)
403
- fs.chmodSync(tmpPath, 0o755)
404
- try { execFileSync('codesign', ['--force', '--sign', '-', '--identifier', 'com.local-mcp.server', tmpPath], { stdio: 'pipe' }) } catch {}
405
- // curl route-3 installs the binary one level deeper:
406
- // ~/.local/share/local-mcp/bin/local-mcp-server/local-mcp-server
407
- // leaving stablePath itself as a DIRECTORY. fs.renameSync throws EISDIR
408
- // silently, so the npm stable binary is never written and the old curl
409
- // server stays running forever (LMC-158).
410
- try {
411
- const st = fs.statSync(stablePath)
412
- if (st.isDirectory()) {
413
- process.stderr.write(' Migrating from curl install: removing old versioned directory at stable path\n')
414
- fs.rmSync(stablePath, { recursive: true, force: true })
415
- }
416
- } catch { /* stablePath doesn't exist — nothing to do */ }
417
- fs.renameSync(tmpPath, stablePath)
418
- }
419
- // Write the actual binary version (from /runtime/latest), not the npm package
420
- // version. npm and Swift binary versions can diverge (npm-only fixes bump npm
421
- // without a Swift rebuild). Writing pkg.version here caused the tray to think
422
- // a newer binary was on disk and restart-loop (LMC-TODO). Runs on every
423
- // platform: index.js's readCachedVersion() reads .server-version off darwin too.
424
- fs.writeFileSync(path.join(CACHE_DIR, '.server-version'), binaryVersion || '')
425
- const settingsSrc = path.join(path.dirname(binPath), 'settings.html')
426
- const settingsDst = path.join(CACHE_DIR, 'settings.html')
427
- if (fs.existsSync(settingsSrc)) fs.copyFileSync(settingsSrc, settingsDst)
428
- } catch {}
429
- process.stderr.write('✓ Runtime ready\n\n')
390
+ fs.mkdirSync(CACHE_DIR, { recursive: true })
391
+ fs.copyFileSync(_bundled, dest + '.tmp')
392
+ fs.renameSync(dest + '.tmp', dest)
393
+ if (binaryVersion) fs.writeFileSync(path.join(CACHE_DIR, '.go-server-version'), binaryVersion)
394
+ process.stderr.write(`✓ LMCP server installed in ${CACHE_DIR}\n\n`)
395
+ } catch (e) {
396
+ try { fs.unlinkSync(dest + '.tmp') } catch {}
397
+ process.stderr.write(` (Could not install the LMCP server in ${CACHE_DIR}: ${e.message})\n\n`)
398
+ }
430
399
  }
431
- // Write the launcher script now that we have CACHE_DIR.
432
- // The launcher uses curl (no Node dependency) to send telemetry if Node is
433
- // too old, then exec's npx. Claude Desktop runs this script instead of npx
434
- // directly, so failures are visible in MCP logs AND in our backend events.
400
+ } else {
401
+ process.stderr.write(` (The LMCP server for ${process.platform}-${process.arch} is not in this package; run: npx -y local-mcp@latest setup)\n\n`)
402
+ }
403
+ // The launcher uses curl (no Node dependency) to send telemetry if Node is
404
+ // too old, then exec's npx. Claude Desktop runs this script instead of npx
405
+ // directly, so failures are visible in MCP logs AND in our backend events.
406
+ try {
435
407
  const spec = _writeLaunchSpec(npxAbsPath, CACHE_DIR)
436
408
  if (spec) { stableCommand = spec.command; stableArgs = spec.args }
437
- } catch (err) {
438
- process.stderr.write(` (Runtime download failed, will download on first run: ${err.message})\n\n`)
439
- // Still try to write a launcher even if binary download failed — the version
440
- // check + telemetry path is independent of the binary.
441
- try {
442
- const { CACHE_DIR } = require('./download')
443
- const spec = _writeLaunchSpec(npxAbsPath, CACHE_DIR)
444
- if (spec) { stableCommand = spec.command; stableArgs = spec.args }
445
- } catch {}
446
- }
409
+ } catch {}
447
410
  // stableCommand is now the shell launcher script path. It wraps npx with a
448
411
  // Node version check + curl telemetry before exec'ing. If launcher creation
449
412
  // failed it falls back to plain 'npx'.
@@ -458,9 +421,8 @@ async function runSetup(opts = {}) {
458
421
  // second JS-side client list. Linux has no runtime-native writer yet
459
422
  // (§3.8): a generic message, no per-client guesswork, no files written.
460
423
  if (process.platform === 'darwin' || _IS_WIN) {
461
- const { CACHE_DIR } = require('./download')
462
424
  const launcher = _launcherArgsForConfigureClients(process.platform, stableCommand, stableArgs)
463
- clientsRun = runConfigureClients(_findServerBinary(_embeddedServer, CACHE_DIR), launcher.command, launcher.args)
425
+ clientsRun = runConfigureClients(_findServerBinary(_embeddedServer || _bundled, CACHE_DIR), launcher.command, launcher.args)
464
426
  const clientes = (clientsRun.report && clientsRun.report.clients) || []
465
427
  _trackSetupStep('detect', clientsRun.runtime === 'ok' ? 'ok' : clientsRun.runtime, '', {
466
428
  clientsFound: clientes.filter(c => c.status !== 'not_installed').map(c => c.id),
@@ -540,7 +502,7 @@ async function runSetup(opts = {}) {
540
502
  if (configured.length > 0) {
541
503
  if (healthOk) {
542
504
  console.log(`✅ LMCP configured for: ${configured.join(', ')}\n`)
543
- console.log(' ✓ Server binary verified — 192+ tools ready\n')
505
+ console.log(' ✓ Server binary verified — tools ready\n')
544
506
  } else {
545
507
  console.log(`⚠ LMCP configured for: ${configured.join(', ')}`)
546
508
  console.log(' Server binary could not be verified — it may still work after restart.\n')
@@ -794,15 +756,17 @@ function _getRef() {
794
756
  // The one thing download.js's version doesn't do is seed the macOS Keychain with the
795
757
  // ioreg-derived id so the Swift tray reads the same value setup computed. That side
796
758
  // effect stays here, gated to darwin, instead of moving into download.js: download's
797
- // _getMachineId runs on every ensureBinary()/ensureTray()/... call (i.e. on every
759
+ // _getMachineId runs on every ensureTray()/... call (i.e. on every
798
760
  // npx spawn), and a Keychain write there would be needless overhead on a hot path
799
761
  // that setup.js — which only runs once at install time — doesn't share.
800
762
  // `deps` es la costura de test (#84): sin ella un test pedía al Keychain REAL de quien lo corre
801
763
  // que creara o pisara la identidad de la máquina. Producto: nadie la pasa, nada cambia.
802
764
  function _getMachineId(deps = {}) {
803
765
  const id = download._getMachineId(deps)
804
- if ((deps.platform ? deps.platform === 'darwin' : _IS_MAC) && id) {
805
- try { (deps.execImpl || execSync)(`security add-generic-password -s com.local-mcp.machine-id -a machine-id -w "${id}" -U 2>/dev/null`, { stdio: 'pipe' }) } catch {}
766
+ // #94: the id can come from a config.json something else wrote. Only a contract-shaped id is
767
+ // seeded, and through execFile with an argument array: no shell sees it.
768
+ if ((deps.platform ? deps.platform === 'darwin' : _IS_MAC) && require('./launch-event').RE_MAQUINA.test(id)) {
769
+ try { (deps.execFileImpl || execFileSync)('security', ['add-generic-password', '-s', 'com.local-mcp.machine-id', '-a', 'machine-id', '-w', id, '-U'], { stdio: 'pipe' }) } catch {}
806
770
  }
807
771
  return id
808
772
  }
@@ -869,16 +833,7 @@ function _installRefDir(platform = process.platform, home = HOME, cacheDir = dow
869
833
  // looks at config.json — so writing the token to cfgFile there left it registered under a
870
834
  // key nothing could ever redeem (#1390 finding 2). getCacheDir() in the go-server resolves
871
835
  // to the exact same directory as CACHE_DIR here (tunnel.go:1107-1113 vs. download.js:39-41).
872
- function _cloudTokenPath(cacheDir) {
873
- return path.join(cacheDir, '.cloud-token')
874
- }
875
-
876
- function _readCachedCloudToken(cacheDir) {
877
- try {
878
- const tok = fs.readFileSync(_cloudTokenPath(cacheDir), 'utf8').trim()
879
- return tok.startsWith('lmcp-') ? tok : ''
880
- } catch { return '' }
881
- }
836
+ const { _cloudTokenPath, _readCachedCloudToken } = download
882
837
 
883
838
  function _writeCloudToken(cacheDir, token) {
884
839
  fs.mkdirSync(cacheDir, { recursive: true })
@@ -896,6 +851,8 @@ async function _registerAnonToken() {
896
851
  return new Promise((resolve) => {
897
852
  const { https } = require('./user-agent')
898
853
  const machineId = _getMachineId()
854
+ // lmcp-npm#92: no id, no registration. The binary mints its id and registers itself.
855
+ if (!machineId) return resolve('')
899
856
  const payload = JSON.stringify({ machine_id: machineId })
900
857
  const req = https.request({
901
858
  host: BACKEND_HOST,
@@ -1102,7 +1059,8 @@ function _pingInstall(clients, method, email = '', binaryVersion = '') {
1102
1059
  }
1103
1060
 
1104
1061
  // Send initial heartbeat so the machine appears as "activated" immediately
1105
- // Even if the user doesn't restart their AI client right away
1062
+ // Even if the user doesn't restart their AI client right away. Not without an id (#92).
1063
+ if (!machineId) return
1106
1064
  const hb = JSON.stringify({
1107
1065
  machine_id: machineId,
1108
1066
  version: binaryVersion || pkg.version,
@@ -1201,6 +1159,6 @@ module.exports = {
1201
1159
  _notSupportedOnPlatformResult,
1202
1160
  _launcherSpawnSpec, _writeLaunchScript, _writeLaunchSpec,
1203
1161
  _getMachineId, _healthCheckSpec, _localMcpConfigDir, _installRefDir,
1204
- _cloudTokenPath, _readCachedCloudToken, _writeCloudToken, _registerAnonToken,
1162
+ _cloudTokenPath, _readCachedCloudToken, _writeCloudToken, _registerAnonToken, _pingInstall,
1205
1163
  _autoLaunchClient, _fetchClientsCatalog,
1206
1164
  }