cf-memory-mcp 3.29.0 → 3.30.0

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.
@@ -3001,7 +3001,19 @@ class CFMemoryMCP {
3001
3001
  cwd: process.env.CF_MEMORY_WATCH_PATH || process.cwd(),
3002
3002
  response_text: text,
3003
3003
  };
3004
- fs.writeFileSync(p, JSON.stringify(entry, null, 2));
3004
+ // Atomic write: serialize to a sibling .tmp then rename so a
3005
+ // crash mid-write never leaves a corrupt JSON file. rename(2)
3006
+ // is atomic on POSIX. On Windows it may fail if the target
3007
+ // exists, so fall back to a direct write there.
3008
+ const tmp = `${p}.tmp.${process.pid}`;
3009
+ try {
3010
+ fs.writeFileSync(tmp, JSON.stringify(entry, null, 2));
3011
+ fs.renameSync(tmp, p);
3012
+ } catch (renameErr) {
3013
+ // Fallback: direct write. Best-effort cleanup of .tmp.
3014
+ try { fs.unlinkSync(tmp); } catch (_) { /* ignore */ }
3015
+ fs.writeFileSync(p, JSON.stringify(entry, null, 2));
3016
+ }
3005
3017
  _mcpTrace('DISK_CACHE', `saved resume packet to ${p}`);
3006
3018
  } catch (err) {
3007
3019
  this.logDebug(`saveResumeToDisk failed: ${err && err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-memory-mcp",
3
- "version": "3.29.0",
3
+ "version": "3.30.0",
4
4
  "description": "Cloudflare-hosted MCP server for code indexing, retrieval, and assistant memory with a direct remote MCP endpoint and local stdio bridge.",
5
5
  "main": "bin/cf-memory-mcp.js",
6
6
  "bin": {