local-mcp 3.0.80 → 3.0.82

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.
Files changed (3) hide show
  1. package/download.js +3 -3
  2. package/index.js +26 -8
  3. package/package.json +1 -1
package/download.js CHANGED
@@ -156,13 +156,13 @@ async function ensureBinary() {
156
156
  } catch { /* no crítico */ }
157
157
 
158
158
  process.stderr.write(` Listo en ${versionDir}\n`)
159
- return { binPath, versionDir }
159
+ return { binPath, versionDir, version }
160
160
  }
161
161
 
162
162
  // Mantener compatibilidad con código que usa ensureRuntime
163
163
  async function ensureRuntime() {
164
- const { binPath, versionDir } = await ensureBinary()
165
- return { pythonBin: binPath, serverPath: binPath, runtimeDir: versionDir, binPath }
164
+ const { binPath, versionDir, version } = await ensureBinary()
165
+ return { pythonBin: binPath, serverPath: binPath, runtimeDir: versionDir, binPath, version }
166
166
  }
167
167
 
168
168
  /**
package/index.js CHANGED
@@ -112,16 +112,30 @@ async function main() {
112
112
  const versionFile = path.join(CACHE_DIR, '.server-version')
113
113
  const pkg = require('./package.json')
114
114
 
115
- // Fast path: if stable binary exists, version matches, exec directly.
115
+ // Semver comparison: returns true if version a >= b (e.g. "3.0.72" >= "3.0.70")
116
+ function semverGte(a, b) {
117
+ const av = (a || '').split('.').map(Number)
118
+ const bv = (b || '').split('.').map(Number)
119
+ for (let i = 0; i < 3; i++) {
120
+ const ai = av[i] || 0, bi = bv[i] || 0
121
+ if (ai > bi) return true
122
+ if (ai < bi) return false
123
+ }
124
+ return true
125
+ }
126
+
127
+ // Fast path: if stable binary exists AND its version is >= our npm package version, exec directly.
128
+ // Using >= (not ===) prevents Claude Desktop from downgrading a binary that the tray's
129
+ // UpdateManager has already upgraded. LMC-375: machine 5F8445AE downgraded 3.0.72→3.0.70
130
+ // because stale npx cache had old pkg.version and triggered the slow path unnecessarily.
116
131
  try {
117
132
  const stat = fs.lstatSync(stableBin)
118
133
  if (stat.isFile() && (stat.mode & 0o111)) {
119
- // Check if cached binary matches current npm version
120
134
  const cachedVersion = fs.existsSync(versionFile)
121
135
  ? fs.readFileSync(versionFile, 'utf8').trim()
122
136
  : ''
123
- if (cachedVersion === pkg.version) {
124
- // Version matches — use fast path
137
+ if (cachedVersion && semverGte(cachedVersion, pkg.version)) {
138
+ // Cached binary is same or newer — use fast path, no download needed
125
139
  const { ensureTray, ensureTeamsProxy, ensureM365Proxy } = require('./download')
126
140
  ensureTray().catch(() => {})
127
141
  ensureTeamsProxy().catch(() => {})
@@ -131,7 +145,7 @@ async function main() {
131
145
  child.on('exit', (code) => process.exit(code ?? 0))
132
146
  return
133
147
  }
134
- // Version mismatch fall through to download new binary
148
+ // Cached binary is older than our npm package — download/update
135
149
  process.stderr.write(`Updating LMCP server (${cachedVersion || '?'} → ${pkg.version})...\n`)
136
150
  _pingFirstRun(true)
137
151
  } else {
@@ -160,7 +174,7 @@ async function main() {
160
174
  process.exit(1)
161
175
  }
162
176
 
163
- const { binPath } = runtime
177
+ const { binPath, version: downloadedVersion } = runtime
164
178
 
165
179
  // Copy binary to stable path (survives version cleanup)
166
180
  try {
@@ -169,8 +183,12 @@ async function main() {
169
183
  fs.chmodSync(tmpPath, 0o755)
170
184
  try { execFileSync('codesign', ['--force', '--sign', '-', '--identifier', 'com.local-mcp.server', tmpPath], { stdio: 'pipe' }) } catch {}
171
185
  fs.renameSync(tmpPath, stableBin)
172
- // Write version file so fast path knows when to update
173
- fs.writeFileSync(versionFile, pkg.version)
186
+ // Write the ACTUAL downloaded binary version (not pkg.version) so the fast path
187
+ // knows what version is on disk. Using pkg.version here caused LMC-375: machines
188
+ // with old npm caches wrote an old version into .server-version even though
189
+ // ensureBinary() downloaded a newer binary, causing HeartbeatManager to report
190
+ // the stale version and triggering spurious downgrade events.
191
+ fs.writeFileSync(versionFile, downloadedVersion || pkg.version)
174
192
  // Also copy settings.html
175
193
  const settingsSrc = path.join(path.dirname(binPath), 'settings.html')
176
194
  const settingsDst = path.join(CACHE_DIR, 'settings.html')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-mcp",
3
- "version": "3.0.80",
3
+ "version": "3.0.82",
4
4
  "description": "LMCP — connect Claude Desktop, Cursor, Windsurf to Mail, Calendar, Contacts, Teams, OneDrive on macOS. Privacy-first: all data stays on your Mac.",
5
5
  "main": "index.js",
6
6
  "bin": {