local-mcp 3.0.420 → 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/README.md +7 -7
- package/bundled.js +40 -0
- package/download.js +91 -247
- package/index.js +141 -442
- package/launch-event.js +63 -12
- package/package.json +10 -4
- package/setup.js +59 -99
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Local MCP
|
|
2
2
|
|
|
3
|
-
> **Use your Mac from ChatGPT & Claude.ai on the web** — plus
|
|
3
|
+
> **Use your Mac or Windows PC from ChatGPT & Claude.ai on the web** — plus local tools for Claude Desktop, Cursor, Windsurf, VS Code & Zed. Connect any AI to Mail, Calendar, Contacts, iMessage, Teams, Slack, WhatsApp, Signal, OneDrive, Google Drive, Notion, Microsoft 365, Notes, Reminders, OmniFocus, Word/Excel/PowerPoint and more. Runs on your computer, no API keys — local tools read your data on your machine, and your AI provider receives the content needed for each request.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/local-mcp)
|
|
6
|
-
[](https://local-mcp.com?ref=npm)
|
|
7
7
|
[](https://local-mcp.com?ref=npm)
|
|
8
8
|
[](https://local-mcp.com/en/privacy)
|
|
9
9
|
[](https://glama.ai/mcp/servers/colibird-ai/local-mcp-releases?ref=npm)
|
|
@@ -41,7 +41,7 @@ Auto-detects and configures Claude Desktop, Claude Code, Cursor, Windsurf, VS Co
|
|
|
41
41
|
|
|
42
42
|
## What it does
|
|
43
43
|
|
|
44
|
-
LMCP runs a native MCP server that bridges your Mac
|
|
44
|
+
LMCP runs a native MCP server that bridges the apps on your Mac or Windows PC to any AI client. Availability varies by platform:
|
|
45
45
|
|
|
46
46
|
| Service | Capabilities |
|
|
47
47
|
|---------|-------------|
|
|
@@ -137,8 +137,6 @@ System (12): `lmcp_state` `get_config` `get_datetime` `daily_brief` `run_diagnos
|
|
|
137
137
|
|
|
138
138
|
Shortcuts (3): `shortcuts_list` `shortcuts_run` `shortcuts_view`
|
|
139
139
|
|
|
140
|
-
_Coming soon (not included in the 162 count above): **Evernote** (support is being rebuilt)._
|
|
141
|
-
|
|
142
140
|
|
|
143
141
|
|
|
144
142
|
## Safety
|
|
@@ -165,7 +163,7 @@ Full policy: **[local-mcp.com/en/privacy](https://local-mcp.com/en/privacy)**.
|
|
|
165
163
|
|
|
166
164
|
## Requirements
|
|
167
165
|
|
|
168
|
-
- macOS 13 Ventura or later (Apple Silicon and Intel)
|
|
166
|
+
- macOS 13 Ventura or later (Apple Silicon and Intel), or Windows 10 or later (64-bit)
|
|
169
167
|
- One of: Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, Zed
|
|
170
168
|
|
|
171
169
|
### Config file locations
|
|
@@ -185,10 +183,12 @@ Full policy: **[local-mcp.com/en/privacy](https://local-mcp.com/en/privacy)**.
|
|
|
185
183
|
|
|
186
184
|
```bash
|
|
187
185
|
npx -y local-mcp@latest setup # configure all detected AI clients
|
|
188
|
-
npx -y local-mcp@latest update #
|
|
186
|
+
npx -y local-mcp@latest update # how to update (npx -y local-mcp@latest)
|
|
189
187
|
npx -y local-mcp@latest status # show server status
|
|
190
188
|
```
|
|
191
189
|
|
|
190
|
+
The LMCP server ships inside the npm package: npm installs the signed binary for your platform (`local-mcp-darwin-arm64`, `local-mcp-darwin-x64`, `local-mcp-windows-x64` or `local-mcp-windows-arm64`) and `npx local-mcp` runs it from there. Starting the server downloads nothing. To update, run `npx -y local-mcp@latest`.
|
|
191
|
+
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
## Uninstall
|
package/bundled.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
/**
|
|
3
|
+
* bundled.js — the native LMCP server that ships inside npm (3.0.423, Darío 2026-10-22 «A»).
|
|
4
|
+
*
|
|
5
|
+
* One package per platform, installed by npm as an optionalDependency of `local-mcp` (the
|
|
6
|
+
* esbuild/Biome pattern): npm picks the one whose `os`/`cpu` match and skips the rest. The wrapper
|
|
7
|
+
* runs the binary in place, from node_modules. Nothing is downloaded at runtime, nothing is
|
|
8
|
+
* re-signed: the Mac binary is the Developer ID one from the signed release, the Windows one the
|
|
9
|
+
* Authenticode-signed one. Updates arrive with `npx -y local-mcp@latest`.
|
|
10
|
+
*
|
|
11
|
+
* This table is the single source of the package names: scripts/paquetes-plataforma.sh builds
|
|
12
|
+
* from it, and test/servidor-en-el-paquete.test.js holds package.json's optionalDependencies to it.
|
|
13
|
+
*/
|
|
14
|
+
const path = require('path')
|
|
15
|
+
|
|
16
|
+
// key `${process.platform}-${process.arch}` → package, binary inside it, and the release artifact
|
|
17
|
+
// it is built from (the key of /runtime/latest that names the tarball, and of its `hashes`).
|
|
18
|
+
const TARGETS = {
|
|
19
|
+
'darwin-arm64': { pkg: 'local-mcp-darwin-arm64', os: 'darwin', cpu: 'arm64', bin: 'local-mcp-server', url: 'url_arm64', hash: 'darwin-arm64' },
|
|
20
|
+
'darwin-x64': { pkg: 'local-mcp-darwin-x64', os: 'darwin', cpu: 'x64', bin: 'local-mcp-server', url: 'url_x64', hash: 'darwin-x64' },
|
|
21
|
+
'win32-x64': { pkg: 'local-mcp-windows-x64', os: 'win32', cpu: 'x64', bin: 'lmcp-server.exe', url: 'windows_amd64', hash: 'windows-amd64' },
|
|
22
|
+
'win32-arm64': { pkg: 'local-mcp-windows-arm64', os: 'win32', cpu: 'arm64', bin: 'lmcp-server.exe', url: 'windows_arm64', hash: 'windows-arm64' },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Absolute path of the bundled server for this platform, or null when there is none: an
|
|
27
|
+
* unsupported platform/arch, or the platform package was not installed (`--omit=optional`, a
|
|
28
|
+
* registry mirror without it, `--no-optional`). `resolve` is a seam for tests.
|
|
29
|
+
*/
|
|
30
|
+
function bundledServerPath (platform = process.platform, arch = process.arch, resolve = require.resolve) {
|
|
31
|
+
const t = TARGETS[`${platform}-${arch}`]
|
|
32
|
+
if (!t) return null
|
|
33
|
+
try {
|
|
34
|
+
return path.join(path.dirname(resolve(`${t.pkg}/package.json`)), 'bin', t.bin)
|
|
35
|
+
} catch {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { TARGETS, bundledServerPath }
|
package/download.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
/**
|
|
3
|
-
* download.js —
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* download.js — lo que `setup` instala desde R2: la app de la barra de menú y los proxies, más
|
|
4
|
+
* los lectores del id de la máquina y del token del relay. El server MCP NO se descarga: viene en
|
|
5
|
+
* el paquete de plataforma de npm (bundled.js, 3.0.423). Nada de este archivo corre en el camino
|
|
6
|
+
* del server.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
const { https, http } = require('./user-agent')
|
|
@@ -54,18 +55,45 @@ const TRAY_APP = process.platform === 'darwin'
|
|
|
54
55
|
|
|
55
56
|
// La instalación vieja que TRAY_APP supersede. Const (no literal suelto) porque el orden en
|
|
56
57
|
// que se la retira es lo que arregla #2654 y los tests la inyectan.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
// LMCP_APPLICATIONS_DIR is a test seam (test/aislado.preload.js points it at a temp dir so a test
|
|
59
|
+
// never sees, or acts on, the real /Applications). Unset in production.
|
|
60
|
+
const SYSTEM_APPLICATIONS = process.env.LMCP_APPLICATIONS_DIR || '/Applications'
|
|
61
|
+
const SYSTEM_TRAY_APP = path.join(SYSTEM_APPLICATIONS, 'LocalMCPTray.app')
|
|
62
|
+
|
|
63
|
+
// 3.0.423 renamed the installed app to LMCP.app (bundle id and executable unchanged); 3.0.422 and
|
|
64
|
+
// older keep LocalMCPTray.app. The npx helper is ALSO named LMCP.app but has another bundle id, so
|
|
65
|
+
// an LMCP.app is the tray only when its Info.plist says com.local-mcp.tray, never by name alone.
|
|
66
|
+
const TRAY_BUNDLE_ID = 'com.local-mcp.tray'
|
|
67
|
+
const TRAY_APP_NAMES = ['LMCP.app', 'LocalMCPTray.app']
|
|
68
|
+
|
|
69
|
+
const _CFBUNDLE_ID_RE = /<key>CFBundleIdentifier<\/key>\s*<string>([^<]*)<\/string>/
|
|
70
|
+
|
|
71
|
+
function _isTrayBundleId(app) {
|
|
72
|
+
const info = path.join(app, 'Contents', 'Info.plist')
|
|
73
|
+
let xml = ''
|
|
74
|
+
try { xml = fs.readFileSync(info, 'utf8') } catch { /* missing or binary: try plutil */ }
|
|
75
|
+
if (!_CFBUNDLE_ID_RE.test(xml)) {
|
|
76
|
+
try { xml = execFileSync('/usr/bin/plutil', ['-convert', 'xml1', '-o', '-', info], { stdio: 'pipe' }).toString() } catch { return false }
|
|
77
|
+
}
|
|
78
|
+
const m = _CFBUNDLE_ID_RE.exec(xml)
|
|
79
|
+
return !!m && m[1].trim() === TRAY_BUNDLE_ID
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Where an installed tray may live, under either name. Only bundles that exist and are the tray.
|
|
83
|
+
function trayAppPaths() {
|
|
84
|
+
if (process.platform !== 'darwin') return []
|
|
85
|
+
return [path.join(os.homedir(), 'Applications'), SYSTEM_APPLICATIONS]
|
|
86
|
+
.flatMap((dir) => TRAY_APP_NAMES.map((n) => path.join(dir, n)))
|
|
87
|
+
.filter((p) => { try { return fs.existsSync(p) && (path.basename(p) !== 'LMCP.app' || _isTrayBundleId(p)) } catch { return false } })
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Legacy id file (go-server's CacheDir()/.machine-id). lmcp-win#440: the client's store is now
|
|
91
|
+
// `.machine-id-v2` and this package writes NO id file on any path (lmcp-npm#92). The legacy file
|
|
92
|
+
// is only read, at rung 3 of the ladder below, for what a 3.0.420 client reports.
|
|
93
|
+
// cacheDir is a parameter so tests can point at a temp dir instead of the real user's cache.
|
|
68
94
|
const WIN_MACHINE_ID_CACHE_NAME = '.machine-id'
|
|
95
|
+
// The Go client's store (lmcp-win#440). Read here, never written.
|
|
96
|
+
const MACHINE_ID_STORE_NAME = '.machine-id-v2'
|
|
69
97
|
|
|
70
98
|
function _readWinMachineIdCache(cacheDir) {
|
|
71
99
|
try {
|
|
@@ -75,34 +103,32 @@ function _readWinMachineIdCache(cacheDir) {
|
|
|
75
103
|
}
|
|
76
104
|
}
|
|
77
105
|
|
|
78
|
-
|
|
106
|
+
// Rung 2: the stored id, when it is non-empty and at most 64 characters (same rule as the Go client).
|
|
107
|
+
function _readStoredMachineId(cacheDir) {
|
|
79
108
|
try {
|
|
80
|
-
fs.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fs.writeFileSync(tmp, id)
|
|
99
|
-
fs.renameSync(tmp, dest)
|
|
100
|
-
} catch {}
|
|
109
|
+
const id = fs.readFileSync(path.join(cacheDir, MACHINE_ID_STORE_NAME), 'utf8').trim()
|
|
110
|
+
return id.length <= 64 ? id : ''
|
|
111
|
+
} catch {
|
|
112
|
+
return ''
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// The go-server reads its relay token ONLY from getCacheDir()/.cloud-token, a plain trimmed string
|
|
117
|
+
// (tunnel.go:454,513-523); getCacheDir() is the same directory as CACHE_DIR here (#1390 finding 2).
|
|
118
|
+
function _cloudTokenPath(cacheDir) {
|
|
119
|
+
return path.join(cacheDir, '.cloud-token')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function _readCachedCloudToken(cacheDir) {
|
|
123
|
+
try {
|
|
124
|
+
const tok = fs.readFileSync(_cloudTokenPath(cacheDir), 'utf8').trim()
|
|
125
|
+
return tok.startsWith('lmcp-') ? tok : ''
|
|
126
|
+
} catch { return '' }
|
|
101
127
|
}
|
|
102
128
|
|
|
103
129
|
// Memoizes only the hardware probe (PowerShell/wmic spawn), not the whole
|
|
104
130
|
// ladder — same split as go-server's cachedHardware(). _getMachineId() runs on
|
|
105
|
-
// every
|
|
131
|
+
// every ensureTray()/... call, and setup.js calls it several
|
|
106
132
|
// times per `npx … setup` run (once per tracked step); without memoizing,
|
|
107
133
|
// each of those would pay a fresh PowerShell spawn. A failed probe is
|
|
108
134
|
// memoized too, on purpose: a run where PowerShell is blocked shouldn't retry
|
|
@@ -213,21 +239,20 @@ function _getMachineId(deps = {}) {
|
|
|
213
239
|
const id = r.toString().trim()
|
|
214
240
|
if (id) return id
|
|
215
241
|
} catch {}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
242
|
+
// lmcp-npm#92 (lmcp-win#440 C4): no hardware rung and no hostname hash on macOS, as
|
|
243
|
+
// lmcp-mac#546 did in the client. No id means nothing is registered under one.
|
|
244
|
+
return ''
|
|
245
|
+
}
|
|
246
|
+
// Off macOS (lmcp-win#440, lmcp-npm#92), read-only in every step:
|
|
247
|
+
// 2. the Go client's store; 3. no store and a relay token: the value a 3.0.420 client reports
|
|
248
|
+
// (hardware, else the legacy .machine-id, else the hostname hash); 4. otherwise no id — the
|
|
249
|
+
// binary mints one and registers itself under it.
|
|
250
|
+
const stored = _readStoredMachineId(cacheDir)
|
|
251
|
+
if (stored) return stored
|
|
252
|
+
if (!_readCachedCloudToken(cacheDir)) return ''
|
|
253
|
+
if (platform === 'win32') {
|
|
222
254
|
const hw = _probeWinHardwareId(execSync)
|
|
223
|
-
if (hw)
|
|
224
|
-
if (!deps.soloLectura) _writeWinMachineIdCache(cacheDir, hw)
|
|
225
|
-
return hw
|
|
226
|
-
}
|
|
227
|
-
// Both probes failed or are blocked — fall back to whatever the go-server
|
|
228
|
-
// already cached rather than diverging to the hostname hash (the poisoned-
|
|
229
|
-
// cache case go-server's own Get() guards against does not apply here:
|
|
230
|
-
// this file is only ever written with a hardware-derived id, by either side).
|
|
255
|
+
if (hw) return hw
|
|
231
256
|
const cached = _readWinMachineIdCache(cacheDir)
|
|
232
257
|
if (cached) return cached
|
|
233
258
|
} else {
|
|
@@ -236,23 +261,14 @@ function _getMachineId(deps = {}) {
|
|
|
236
261
|
if (mid) return mid
|
|
237
262
|
} catch {}
|
|
238
263
|
}
|
|
239
|
-
// El evento de lanzamiento (launch-event.js) pide soloLectura: no
|
|
240
|
-
//
|
|
241
|
-
// tener id antes que uno derivado del hostname.
|
|
264
|
+
// El evento de lanzamiento (launch-event.js) pide soloLectura: prefiere no tener id antes que
|
|
265
|
+
// uno derivado del hostname.
|
|
242
266
|
if (deps.soloLectura) return ''
|
|
243
267
|
// Fallback: hash hostname instead of sending raw PII
|
|
244
268
|
const crypto = require('crypto')
|
|
245
269
|
return crypto.createHash('sha256').update(os.hostname()).digest('hex').slice(0, 16)
|
|
246
270
|
}
|
|
247
271
|
|
|
248
|
-
function getArch(platform = process.platform) {
|
|
249
|
-
const plat = platform === 'win32' ? 'windows' : platform === 'linux' ? 'linux' : 'darwin'
|
|
250
|
-
const arch = process.arch
|
|
251
|
-
if (arch === 'arm64') return `${plat}-arm64`
|
|
252
|
-
if (arch === 'x64') return `${plat}-amd64`
|
|
253
|
-
throw new Error(`Unsupported architecture: ${plat}/${arch}. LMCP requires arm64 or x64.`)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
272
|
// Version of the artifact a given URL actually points at, parsed from the
|
|
257
273
|
// published name lmcp-server-<version>-<os>-<arch>.tar.gz. Returns null when the
|
|
258
274
|
// name doesn't match, so the caller falls back explicitly instead of inventing one.
|
|
@@ -266,22 +282,6 @@ function versionFromArtifactUrl(url, arch) {
|
|
|
266
282
|
return m ? m[1] : null
|
|
267
283
|
}
|
|
268
284
|
|
|
269
|
-
// La version contra la que ESTA plataforma tiene que compararse, sacada del
|
|
270
|
-
// mismo manifiesto. Existe porque `info.version` es la linea de Mac: usarla en
|
|
271
|
-
// Windows/Linux compara dos series distintas, que es lo que fastPathVersionOK ya
|
|
272
|
-
// se niega a hacer en el fast path (#1394 §C).
|
|
273
|
-
//
|
|
274
|
-
// Devuelve null cuando no se puede determinar — sin artefacto para la
|
|
275
|
-
// plataforma, o con un nombre que no parsea. El llamador NO debe caer a
|
|
276
|
-
// info.version: preferimos no decidir antes que decidir sobre un numero que
|
|
277
|
-
// describe otra plataforma.
|
|
278
|
-
function latestVersionForPlatform(info, arch) {
|
|
279
|
-
if (!info) return null
|
|
280
|
-
if (String(arch).startsWith('darwin')) return info.version || null
|
|
281
|
-
const url = info[String(arch).replace('-', '_')]
|
|
282
|
-
return url ? versionFromArtifactUrl(url, arch) : null
|
|
283
|
-
}
|
|
284
|
-
|
|
285
285
|
/**
|
|
286
286
|
* Obtiene la versión más reciente del binario desde el backend.
|
|
287
287
|
* Si esta máquina está en beta_machines, el backend retorna la versión beta.
|
|
@@ -331,7 +331,7 @@ function downloadOnce(url, destPath) {
|
|
|
331
331
|
}
|
|
332
332
|
if (res.statusCode !== 200) {
|
|
333
333
|
file.close()
|
|
334
|
-
fs.
|
|
334
|
+
fs.rmSync(destPath, { force: true })
|
|
335
335
|
return reject(new Error(`HTTP ${res.statusCode} descargando binario`))
|
|
336
336
|
}
|
|
337
337
|
|
|
@@ -352,7 +352,7 @@ function downloadOnce(url, destPath) {
|
|
|
352
352
|
|
|
353
353
|
res.pipe(file)
|
|
354
354
|
file.on('finish', () => { file.close(); process.stderr.write('\n'); resolve() })
|
|
355
|
-
file.on('error', (err) => { fs.
|
|
355
|
+
file.on('error', (err) => { fs.rmSync(destPath, { force: true }); reject(err) })
|
|
356
356
|
}).on('error', reject)
|
|
357
357
|
}
|
|
358
358
|
|
|
@@ -381,167 +381,6 @@ async function downloadFile(url, destPath) {
|
|
|
381
381
|
throw lastErr
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
/**
|
|
385
|
-
* Asegura que el binario esté descargado y listo.
|
|
386
|
-
* @returns {Promise<{binPath: string}>}
|
|
387
|
-
*/
|
|
388
|
-
async function ensureBinary(deps = {}) {
|
|
389
|
-
// Linux no está soportado (decisión de Dario, 2026-10-02; colibird-ai/lmcp-npm#9). Se dice
|
|
390
|
-
// ANTES de pedir nada: ni /runtime/latest ni un tarball. Anuncie lo que anuncie el API — llegó a
|
|
391
|
-
// anunciar URLs `linux_*` que daban 404, y la guarda vieja (sólo «si no hay URL») no saltaba.
|
|
392
|
-
if ((deps.platform || process.platform) === 'linux') throw new Error(LINUX_NO_SOPORTADO)
|
|
393
|
-
// Seam for tests (same idiom as ensureTray's `deps`, #2654): lets a test pin the
|
|
394
|
-
// platform and stub the network without touching process.platform or real HOME.
|
|
395
|
-
const {
|
|
396
|
-
platform = process.platform,
|
|
397
|
-
getLatest = getLatestBinary,
|
|
398
|
-
download = downloadFile,
|
|
399
|
-
} = deps
|
|
400
|
-
const arch = getArch(platform)
|
|
401
|
-
const info = await getLatest()
|
|
402
|
-
const version = info.version
|
|
403
|
-
|
|
404
|
-
// On non-darwin, use the Go server binary (cross-platform).
|
|
405
|
-
// The Go binary is a single file, not a nested tarball.
|
|
406
|
-
if (platform !== 'darwin') {
|
|
407
|
-
const binName = platform === 'win32' ? 'lmcp-server.exe' : 'lmcp-server'
|
|
408
|
-
const binPath = path.join(CACHE_DIR, binName)
|
|
409
|
-
const versionFile = path.join(CACHE_DIR, '.go-server-version')
|
|
410
|
-
|
|
411
|
-
// Resolve the download URL BEFORE the cache check: the version this platform
|
|
412
|
-
// actually installs is the one in that URL, not info.version (the Mac release).
|
|
413
|
-
//
|
|
414
|
-
// Each branch knows its own version by construction, so there is no guessing:
|
|
415
|
-
// · published URL → the version is whatever that name says. If the name
|
|
416
|
-
// doesn't parse we FAIL rather than fall back to info.version, which would
|
|
417
|
-
// record a Mac number against a non-Mac artifact — the very bug this path
|
|
418
|
-
// exists to fix, reappearing in the one corner nobody would look at.
|
|
419
|
-
// · composed URL → we built it from info.version, so that IS the version.
|
|
420
|
-
const archKey = arch.replace('-', '_') // windows-amd64 → windows_amd64
|
|
421
|
-
const publishedUrl = (info[archKey] && info[archKey].startsWith('http')) ? info[archKey] : null
|
|
422
|
-
|
|
423
|
-
let url, platformVersion
|
|
424
|
-
if (publishedUrl) {
|
|
425
|
-
platformVersion = versionFromArtifactUrl(publishedUrl, arch)
|
|
426
|
-
if (!platformVersion) {
|
|
427
|
-
throw new Error(
|
|
428
|
-
`No pude determinar la versión del artefacto publicado para ${arch}.\n` +
|
|
429
|
-
` URL: ${publishedUrl}\n` +
|
|
430
|
-
` Se esperaba un nombre lmcp-server-<versión>-${arch}.tar.gz.\n` +
|
|
431
|
-
`Reportalo: la convención de nombres del backend cambió.`
|
|
432
|
-
)
|
|
433
|
-
}
|
|
434
|
-
url = publishedUrl
|
|
435
|
-
} else {
|
|
436
|
-
platformVersion = version
|
|
437
|
-
url = `https://download.local-mcp.com/lmcp-server-${version}-${arch}.tar.gz`
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// Check if already cached at the right version. Comparing against
|
|
441
|
-
// info.version here re-downloaded the SAME artifact on every Mac release and
|
|
442
|
-
// then recorded the Mac number, so the machine reported a build it wasn't
|
|
443
|
-
// running. Comparing against platformVersion keeps both directions honest:
|
|
444
|
-
// an unchanged Windows artifact is a cache hit, a new one is a miss.
|
|
445
|
-
if (fs.existsSync(binPath)) {
|
|
446
|
-
try {
|
|
447
|
-
const cached = fs.readFileSync(versionFile, 'utf8').trim()
|
|
448
|
-
if (cached === platformVersion) return { binPath, versionDir: CACHE_DIR, version: platformVersion }
|
|
449
|
-
} catch {}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
process.stderr.write(`\nLMCP v${platformVersion} (${arch}) not found in cache.\n`)
|
|
453
|
-
process.stderr.write(`Downloading from ${url}\n`)
|
|
454
|
-
|
|
455
|
-
fs.mkdirSync(CACHE_DIR, { recursive: true })
|
|
456
|
-
const tarPath = path.join(CACHE_DIR, `go-server-${platformVersion}.tar.gz`)
|
|
457
|
-
|
|
458
|
-
try {
|
|
459
|
-
await download(url, tarPath)
|
|
460
|
-
process.stderr.write(` Extracting...\n`)
|
|
461
|
-
extractTar(tarPath, CACHE_DIR)
|
|
462
|
-
fs.unlinkSync(tarPath)
|
|
463
|
-
} catch (err) {
|
|
464
|
-
try { fs.unlinkSync(tarPath) } catch {}
|
|
465
|
-
// Only a 404 means the artifact for this version/arch genuinely isn't published.
|
|
466
|
-
// Every other failure (network, missing tar.exe, disk) is an environment problem —
|
|
467
|
-
// surface it verbatim so it's diagnosable. Masking ALL failures as "in preview" sent
|
|
468
|
-
// us chasing a backend version-alignment ghost that didn't exist (#1256): the artifact
|
|
469
|
-
// was published, valid and hash-correct; the client just failed to fetch/unpack it.
|
|
470
|
-
if (/HTTP 404/.test(err.message)) {
|
|
471
|
-
throw new Error(
|
|
472
|
-
`LMCP ${platformVersion} is not yet available for ${arch}.\n` +
|
|
473
|
-
`The Windows/Linux Go server is in preview — check https://local-mcp.com for updates.`
|
|
474
|
-
)
|
|
475
|
-
}
|
|
476
|
-
throw new Error(
|
|
477
|
-
`Failed to install LMCP ${platformVersion} (${arch}) from ${url}:\n ${err.message}`
|
|
478
|
-
)
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
if (!fs.existsSync(binPath)) {
|
|
482
|
-
throw new Error(`Binary not found after extraction: ${binPath}`)
|
|
483
|
-
}
|
|
484
|
-
if (platform !== 'win32') fs.chmodSync(binPath, 0o755)
|
|
485
|
-
fs.writeFileSync(versionFile, platformVersion)
|
|
486
|
-
|
|
487
|
-
process.stderr.write(` Ready at ${CACHE_DIR}\n`)
|
|
488
|
-
return { binPath, versionDir: CACHE_DIR, version: platformVersion }
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// macOS: Swift binary in a nested tarball
|
|
492
|
-
const url = `https://download.local-mcp.com/local-mcp-server-${version}-${arch}.tar.gz`
|
|
493
|
-
|
|
494
|
-
const versionDir = path.join(CACHE_DIR, version)
|
|
495
|
-
const binPath = path.join(versionDir, 'local-mcp-server', 'local-mcp-server')
|
|
496
|
-
|
|
497
|
-
// Ya está en cache
|
|
498
|
-
if (fs.existsSync(binPath)) {
|
|
499
|
-
return { binPath, versionDir, version }
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
process.stderr.write(`\nLMCP v${version} no encontrado en cache.\n`)
|
|
503
|
-
process.stderr.write(`Descargando desde ${url}\n`)
|
|
504
|
-
|
|
505
|
-
fs.mkdirSync(versionDir, { recursive: true })
|
|
506
|
-
const tarPath = path.join(versionDir, `server-${version}.tar.gz`)
|
|
507
|
-
|
|
508
|
-
await downloadFile(url, tarPath)
|
|
509
|
-
|
|
510
|
-
process.stderr.write(` Extrayendo...\n`)
|
|
511
|
-
extractTar(tarPath, versionDir)
|
|
512
|
-
fs.unlinkSync(tarPath)
|
|
513
|
-
|
|
514
|
-
if (!fs.existsSync(binPath)) {
|
|
515
|
-
throw new Error(`Binario no encontrado después de extraer: ${binPath}`)
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
fs.chmodSync(binPath, 0o755)
|
|
519
|
-
|
|
520
|
-
try { execFileSync('xattr', ['-d', 'com.apple.quarantine', binPath], { stdio: 'pipe' }) } catch {}
|
|
521
|
-
|
|
522
|
-
let hasSig = false
|
|
523
|
-
try {
|
|
524
|
-
execFileSync('codesign', ['--verify', binPath], { stdio: 'pipe' })
|
|
525
|
-
hasSig = true
|
|
526
|
-
} catch {}
|
|
527
|
-
if (!hasSig) {
|
|
528
|
-
try {
|
|
529
|
-
execFileSync('codesign', ['--force', '--sign', '-', '--identifier', 'com.local-mcp.server', binPath], { stdio: 'pipe' })
|
|
530
|
-
} catch (e) {
|
|
531
|
-
process.stderr.write(` [warn] ad-hoc codesign failed for server binary: ${e.message}\n`)
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
process.stderr.write(` Listo en ${versionDir}\n`)
|
|
536
|
-
return { binPath, versionDir, version }
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// Mantener compatibilidad con código que usa ensureRuntime
|
|
540
|
-
async function ensureRuntime() {
|
|
541
|
-
const { binPath, versionDir, version } = await ensureBinary()
|
|
542
|
-
return { pythonBin: binPath, serverPath: binPath, runtimeDir: versionDir, binPath, version }
|
|
543
|
-
}
|
|
544
|
-
|
|
545
384
|
/**
|
|
546
385
|
* The version a co-process is published at (lmcp-mac#382). `/runtime/latest` names it apart from
|
|
547
386
|
* the server's (`coprocess_version`, #3598); the Mac updater installs exactly that one and writes
|
|
@@ -622,8 +461,10 @@ async function ensureTeamsProxy(platform = process.platform, deps = {}) {
|
|
|
622
461
|
// Un .app "usable" es el EJECUTABLE adentro, no el directorio: una extracción a medias deja
|
|
623
462
|
// el bundle existiendo y vacío, y esa fue la falla de #1338. (#2654)
|
|
624
463
|
function _isUsableTrayBundle(trayApp) {
|
|
625
|
-
try {
|
|
626
|
-
|
|
464
|
+
try {
|
|
465
|
+
return fs.existsSync(path.join(trayApp, 'Contents', 'MacOS', 'LocalMCPTray')) &&
|
|
466
|
+
(path.basename(trayApp) !== 'LMCP.app' || _isTrayBundleId(trayApp))
|
|
467
|
+
} catch { return false }
|
|
627
468
|
}
|
|
628
469
|
|
|
629
470
|
// Version compare mirroring mac-swift/Sources/LocalMCPServer/Version.swift's isNewer —
|
|
@@ -772,6 +613,9 @@ async function ensureTray(deps = {}) {
|
|
|
772
613
|
// partial extraction, #1338) is NOT covered — that still needs repairing below.
|
|
773
614
|
if (_isUsableTrayBundle(trayApp)) return trayApp
|
|
774
615
|
if (_isUsableTrayBundle(systemTrayApp)) return systemTrayApp
|
|
616
|
+
// 3.0.423+: the tray is LMCP.app. Nothing to download or place next to it.
|
|
617
|
+
const renamed = [trayApp, systemTrayApp].map((p) => path.join(path.dirname(p), 'LMCP.app')).find(_isUsableTrayBundle)
|
|
618
|
+
if (renamed) return renamed
|
|
775
619
|
|
|
776
620
|
const info = await getLatest()
|
|
777
621
|
const version = info.version
|
|
@@ -934,11 +778,11 @@ async function ensureSlackProxy(platform = process.platform) {
|
|
|
934
778
|
}
|
|
935
779
|
|
|
936
780
|
module.exports = {
|
|
937
|
-
|
|
938
|
-
latestVersionForPlatform, getArch,
|
|
781
|
+
ensureTray, ensureTeamsProxy, ensureSlackProxy, versionFromArtifactUrl, coprocessVersion,
|
|
939
782
|
CACHE_DIR, TRAY_DIR, _getMachineId, LINUX_NO_SOPORTADO,
|
|
940
783
|
_probeWinHardwareId, _resetWinHardwareIdCacheForTests, UUIDS_DE_HARDWARE_BASURA, _esIdDeHardwareValido,
|
|
941
|
-
_readWinMachineIdCache,
|
|
942
|
-
|
|
784
|
+
_readWinMachineIdCache, WIN_MACHINE_ID_CACHE_NAME, MACHINE_ID_STORE_NAME, _readStoredMachineId,
|
|
785
|
+
_cloudTokenPath, _readCachedCloudToken,
|
|
786
|
+
_retireSupersededTrays, _isUsableTrayBundle, SYSTEM_TRAY_APP, trayAppPaths,
|
|
943
787
|
_bundleVersion, _isTrayRunningFrom, _versionIsNewer,
|
|
944
788
|
}
|