cf-memory-mcp 3.8.3 → 3.8.4

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.
@@ -355,8 +355,19 @@ async function main() {
355
355
  }
356
356
 
357
357
  const args = process.argv.slice(2);
358
- const command = args[0];
359
- const projectPath = args[1] || '.';
358
+
359
+ // Detect command from how the script was called (cf-memory-index vs cf-memory-watch)
360
+ const scriptName = path.basename(process.argv[1]);
361
+ let command = args[0];
362
+ let projectPath = args[1] || '.';
363
+
364
+ if (scriptName.includes('watch')) {
365
+ command = 'watch';
366
+ projectPath = args[0] || '.';
367
+ } else if (scriptName.includes('index')) {
368
+ command = 'index';
369
+ projectPath = args[0] || '.';
370
+ }
360
371
 
361
372
  const options = {
362
373
  dryRun: args.includes('--dry-run'),
@@ -388,7 +399,12 @@ Environment:
388
399
  }
389
400
  }
390
401
 
391
- main().catch(err => {
392
- console.error('Error:', err.message);
393
- process.exit(1);
394
- });
402
+ // Export for programmatic use
403
+ if (require.main === module) {
404
+ main().catch(err => {
405
+ console.error('Error:', err.message);
406
+ process.exit(1);
407
+ });
408
+ }
409
+
410
+ module.exports = { IncrementalIndexer };
@@ -45,6 +45,7 @@ class CFMemoryMCP {
45
45
  this.legacyServerUrl = LEGACY_SERVER_URL;
46
46
  this.userAgent = `cf-memory-mcp/${PACKAGE_VERSION} (${os.platform()} ${os.arch()}; Node.js ${process.version})`;
47
47
  this.useStreamableHttp = true; // Try Streamable HTTP first
48
+ this.autoWatcher = null; // Background file watcher
48
49
 
49
50
  // Handle process termination gracefully
50
51
  process.on('SIGINT', () => this.shutdown('SIGINT'));
@@ -91,12 +92,46 @@ class CFMemoryMCP {
91
92
  try {
92
93
  // Skip connectivity test in MCP mode - it will be tested when first request is made
93
94
  this.logDebug('Starting MCP message processing...');
95
+
96
+ // Start auto-watcher if CF_MEMORY_AUTO_WATCH is set
97
+ if (process.env.CF_MEMORY_AUTO_WATCH === '1' || process.env.CF_MEMORY_AUTO_WATCH === 'true') {
98
+ this.startAutoWatcher();
99
+ }
100
+
94
101
  await this.processStdio();
95
102
  } catch (error) {
96
103
  this.logError('Failed to start MCP server:', error);
97
104
  process.exit(1);
98
105
  }
99
106
  }
107
+
108
+ /**
109
+ * Start auto-watching files for changes
110
+ */
111
+ async startAutoWatcher() {
112
+ // Use CF_MEMORY_WATCH_PATH if set, otherwise use current working directory
113
+ const watchPath = process.env.CF_MEMORY_WATCH_PATH || process.cwd();
114
+ const projectName = process.env.CF_MEMORY_PROJECT_NAME || path.basename(watchPath);
115
+
116
+ this.logDebug(`Starting auto-watch for: ${watchPath} (${projectName})`);
117
+
118
+ try {
119
+ // Dynamically import the indexer
120
+ const { IncrementalIndexer } = require('./cf-memory-mcp-indexer.js');
121
+ this.autoWatcher = new IncrementalIndexer(watchPath, {
122
+ name: projectName
123
+ });
124
+
125
+ // Start watching in background
126
+ this.autoWatcher.watch().catch(err => {
127
+ this.logError('Auto-watch error:', err);
128
+ });
129
+
130
+ this.logDebug('Auto-watch started successfully');
131
+ } catch (err) {
132
+ this.logError('Failed to start auto-watch:', err);
133
+ }
134
+ }
100
135
 
101
136
  /**
102
137
  * Test connectivity to the Cloudflare Worker
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-memory-mcp",
3
- "version": "3.8.3",
3
+ "version": "3.8.4",
4
4
  "description": "Best-in-class MCP server with CONTEXTUAL CHUNKING (Anthropic-style, 35-67% better retrieval), Optimized LLM stack (Llama-3.1-8B), BGE-M3 embeddings, Query Expansion Caching, Hybrid Embedding Strategy, and Unified Project Intelligence",
5
5
  "main": "bin/cf-memory-mcp.js",
6
6
  "bin": {