cf-memory-mcp 3.8.0 → 3.8.1

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.
@@ -24,6 +24,7 @@ const crypto = require('crypto');
24
24
  // Configuration
25
25
  const STREAMABLE_HTTP_URL = 'https://cf-memory-mcp-simplified.johnlam90.workers.dev/mcp/message';
26
26
  const LEGACY_SERVER_URL = 'https://cf-memory-mcp-simplified.johnlam90.workers.dev/mcp/message';
27
+ const PROGRESS_SSE_URL = 'https://cf-memory-mcp-simplified.johnlam90.workers.dev/api/indexing/progress';
27
28
  const PACKAGE_VERSION = require('../package.json').version;
28
29
  const TIMEOUT_MS = 60000; // Increased timeout for batch operations
29
30
  const CONNECT_TIMEOUT_MS = 10000;
@@ -31,6 +32,9 @@ const CONNECT_TIMEOUT_MS = 10000;
31
32
  // Get API key from environment variable (will be checked later)
32
33
  const API_KEY = process.env.CF_MEMORY_API_KEY;
33
34
 
35
+ // Optional: stream indexing progress via SSE
36
+ const ENABLE_PROGRESS = process.env.CF_MEMORY_PROGRESS === '1' || process.env.CF_MEMORY_PROGRESS === 'true';
37
+
34
38
  /**
35
39
  * Cross-platform MCP stdio bridge
36
40
  * Handles communication between MCP clients and the Cloudflare Worker
@@ -232,7 +236,7 @@ class CFMemoryMCP {
232
236
  * Handle local project indexing - scans local files and sends them via MCP
233
237
  */
234
238
  async handleIndexProject(message) {
235
- const { project_path, project_name, include_patterns, exclude_patterns } = message.params.arguments;
239
+ const { project_path, project_name, include_patterns, exclude_patterns, force_reindex } = message.params.arguments;
236
240
  const resolvedPath = path.resolve(project_path);
237
241
  const name = project_name || path.basename(resolvedPath);
238
242
 
@@ -277,6 +281,13 @@ class CFMemoryMCP {
277
281
  const batch = files.slice(i, i + BATCH_SIZE);
278
282
  this.logDebug(`Processing batch ${Math.floor(i/BATCH_SIZE) + 1}/${Math.ceil(files.length/BATCH_SIZE)} (${batch.length} files)`);
279
283
 
284
+ const sessionId = crypto.randomUUID();
285
+
286
+ // Optionally stream progress
287
+ const progressReader = ENABLE_PROGRESS
288
+ ? this.startProgressStream(sessionId)
289
+ : null;
290
+
280
291
  const projectResult = await this.makeRequest({
281
292
  jsonrpc: '2.0',
282
293
  id: `index-batch-${Date.now()}-${i}`,
@@ -291,11 +302,18 @@ class CFMemoryMCP {
291
302
  content: f.content
292
303
  })),
293
304
  include_patterns,
294
- exclude_patterns
305
+ exclude_patterns,
306
+ force_reindex
295
307
  }
296
308
  }
309
+ }, {
310
+ 'X-Progress-Session': sessionId
297
311
  });
298
312
 
313
+ if (progressReader) {
314
+ progressReader.stop();
315
+ }
316
+
299
317
  if (projectResult.error) {
300
318
  this.logError(`Batch ${i} failed:`, projectResult.error);
301
319
  continue;
@@ -460,26 +478,32 @@ class CFMemoryMCP {
460
478
  /**
461
479
  * Make HTTP request to the Cloudflare Worker (MCP JSON-RPC)
462
480
  */
463
- async makeRequest(message) {
481
+ async makeRequest(message, extraHeaders = null) {
464
482
  return new Promise((resolve) => {
465
483
  const serverUrl = this.useStreamableHttp ? this.streamableHttpUrl : this.legacyServerUrl;
466
484
  const url = new URL(serverUrl);
467
485
  const postData = JSON.stringify(message);
468
486
 
487
+ const headers = {
488
+ 'Content-Type': 'application/json',
489
+ 'Accept': 'application/json',
490
+ 'Accept-Encoding': 'identity',
491
+ 'User-Agent': this.userAgent,
492
+ 'Authorization': `Bearer ${API_KEY}`,
493
+ 'X-API-Key': API_KEY,
494
+ 'Content-Length': Buffer.byteLength(postData)
495
+ };
496
+
497
+ if (extraHeaders) {
498
+ Object.assign(headers, extraHeaders);
499
+ }
500
+
469
501
  const options = {
470
502
  hostname: url.hostname,
471
503
  port: url.port || 443,
472
504
  path: url.pathname,
473
505
  method: 'POST',
474
- headers: {
475
- 'Content-Type': 'application/json',
476
- 'Accept': 'application/json',
477
- 'Accept-Encoding': 'identity',
478
- 'User-Agent': this.userAgent,
479
- 'Authorization': `Bearer ${API_KEY}`,
480
- 'X-API-Key': API_KEY, // Also include for backwards compatibility
481
- 'Content-Length': Buffer.byteLength(postData)
482
- },
506
+ headers,
483
507
  timeout: TIMEOUT_MS
484
508
  };
485
509
 
@@ -538,6 +562,45 @@ class CFMemoryMCP {
538
562
  });
539
563
  }
540
564
 
565
+ startProgressStream(sessionId) {
566
+ const url = new URL(PROGRESS_SSE_URL);
567
+ url.searchParams.set('session', sessionId);
568
+
569
+ const options = {
570
+ hostname: url.hostname,
571
+ port: url.port || 443,
572
+ path: url.pathname + url.search,
573
+ method: 'GET',
574
+ headers: {
575
+ 'Accept': 'text/event-stream',
576
+ 'Cache-Control': 'no-cache',
577
+ 'X-API-Key': API_KEY,
578
+ 'User-Agent': this.userAgent
579
+ },
580
+ timeout: CONNECT_TIMEOUT_MS
581
+ };
582
+
583
+ const req = https.request(options, (res) => {
584
+ res.setEncoding('utf8');
585
+ res.on('data', (chunk) => {
586
+ // Print progress events to stderr to avoid breaking MCP stdio
587
+ if (chunk && chunk.trim()) {
588
+ process.stderr.write(`[PROGRESS] ${chunk.trim()}
589
+ `);
590
+ }
591
+ });
592
+ });
593
+
594
+ req.on('error', () => {});
595
+ req.end();
596
+
597
+ return {
598
+ stop: () => {
599
+ try { req.destroy(); } catch (_) {}
600
+ }
601
+ };
602
+ }
603
+
541
604
  /**
542
605
  * Graceful shutdown
543
606
  */
@@ -566,6 +629,7 @@ Usage:
566
629
 
567
630
  Environment Variables:
568
631
  CF_MEMORY_API_KEY=<key> Your CF Memory API key (required)
632
+ CF_MEMORY_PROGRESS=true Stream indexing progress to stderr (optional)
569
633
  DEBUG=1 Enable debug logging
570
634
  MCP_DEBUG=1 Enable MCP debug logging
571
635
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-memory-mcp",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
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": {