@mrxkun/mcfast-mcp 4.1.4 → 4.1.6

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 CHANGED
@@ -623,6 +623,14 @@ Read API (Total: 6ms)
623
623
 
624
624
  ## 📝 Changelog
625
625
 
626
+ ### v4.1.5 (2026-02-17) 🐛 Critical MCP Fix
627
+
628
+ - 🔧 **Fixed JSON-RPC Stream Corruption**
629
+ - Replaced ALL `console.log` with `console.error` (35+ statements)
630
+ - MCP protocol uses `stdout` for JSON-RPC - console.log corrupts stream
631
+ - Error `[FileWatche..." is not valid JSON` now resolved
632
+ - Fixed in 10 files: strategy-selector, agents-md, curated-memory, databases, context-analyzer, daily-logs, embedder, sync-engine, ultra-embedder
633
+
626
634
  ### v4.1.4 (2026-02-17) 🎉 ContextAnalyzer API
627
635
 
628
636
  - ✨ **ContextAnalyzer Integration**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mrxkun/mcfast-mcp",
3
- "version": "4.1.4",
4
- "description": "Ultra-fast code editing with WASM acceleration, fuzzy patching, multi-layer caching, and 8 unified tools. v4.1.4: ContextAnalyzer API integration, Mercury Coder support, SQL migration ready.",
3
+ "version": "4.1.6",
4
+ "description": "Ultra-fast code editing with WASM acceleration, fuzzy patching, multi-layer caching, and 8 unified tools. v4.1.6: Critical MCP fix - Redirect stdout to stderr to prevent JSON-RPC stream corruption.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mcfast-mcp": "src/index.js"
package/src/index.js CHANGED
@@ -5,6 +5,20 @@
5
5
  * Proxies code edit requests to mcfast Cloud (Vercel)
6
6
  */
7
7
 
8
+ // CRITICAL: Redirect all stdout writes to stderr to prevent JSON parsing errors in MCP
9
+ // MCP protocol requires stdout to contain ONLY JSON-RPC messages
10
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
11
+ process.stdout.write = function(chunk, encoding, callback) {
12
+ // Redirect all stdout writes to stderr
13
+ return process.stderr.write(chunk, encoding, callback);
14
+ };
15
+
16
+ // Also override console.log to use stderr
17
+ const originalConsoleLog = console.log;
18
+ console.log = function(...args) {
19
+ console.error(...args);
20
+ };
21
+
8
22
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
23
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
24
  import { ListToolsRequestSchema, CallToolRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema } from "@modelcontextprotocol/sdk/types.js";
@@ -293,7 +293,7 @@ export class StrategySelector {
293
293
  }
294
294
  } catch (e) {
295
295
  // Use defaults
296
- console.log('[StrategySelector] Using default model');
296
+ console.error('[StrategySelector] Using default model');
297
297
  }
298
298
  }
299
299
 
@@ -29,14 +29,14 @@ export class AgentsMdBootstrap {
29
29
  */
30
30
  async bootstrap() {
31
31
  if (await this.exists()) {
32
- console.log(`[AgentsMdBootstrap] AGENTS.md already exists`);
32
+ console.error(`[AgentsMdBootstrap] AGENTS.md already exists`);
33
33
  return false;
34
34
  }
35
35
 
36
36
  await fs.mkdir(path.dirname(this.agentsFile), { recursive: true });
37
37
  await fs.writeFile(this.agentsFile, this.getContent());
38
38
 
39
- console.log(`[AgentsMdBootstrap] Created ${this.agentsFile}`);
39
+ console.error(`[AgentsMdBootstrap] Created ${this.agentsFile}`);
40
40
  return true;
41
41
  }
42
42
 
@@ -47,7 +47,7 @@ export class AgentsMdBootstrap {
47
47
  await fs.mkdir(path.dirname(this.agentsFile), { recursive: true });
48
48
  await fs.writeFile(this.agentsFile, this.getContent());
49
49
 
50
- console.log(`[AgentsMdBootstrap] Regenerated ${this.agentsFile}`);
50
+ console.error(`[AgentsMdBootstrap] Regenerated ${this.agentsFile}`);
51
51
  return true;
52
52
  }
53
53
 
@@ -25,7 +25,7 @@ export class CuratedMemory {
25
25
  const defaultContent = this.getDefaultContent();
26
26
  await fs.mkdir(path.dirname(this.memoryFile), { recursive: true });
27
27
  await fs.writeFile(this.memoryFile, defaultContent);
28
- console.log(`[CuratedMemory] Created ${this.memoryFile}`);
28
+ console.error(`[CuratedMemory] Created ${this.memoryFile}`);
29
29
  }
30
30
  }
31
31
 
@@ -118,7 +118,7 @@ This file contains curated, persistent knowledge.
118
118
  );
119
119
 
120
120
  await fs.writeFile(this.memoryFile, fileContent);
121
- console.log(`[CuratedMemory] Updated section: ${sectionName}`);
121
+ console.error(`[CuratedMemory] Updated section: ${sectionName}`);
122
122
 
123
123
  return true;
124
124
  }
@@ -315,7 +315,7 @@ This file contains curated, persistent knowledge.
315
315
  async promoteFromDailyLog(date, entryTitle, sectionName) {
316
316
  // This would require reading from daily log file
317
317
  // Implementation depends on DailyLogs integration
318
- console.log(`[CuratedMemory] Promote: ${entryTitle} from ${date} to ${sectionName}`);
318
+ console.error(`[CuratedMemory] Promote: ${entryTitle} from ${date} to ${sectionName}`);
319
319
  // TODO: Implement promotion logic
320
320
  return true;
321
321
  }
@@ -26,7 +26,7 @@ export class CodebaseDatabase {
26
26
  this.createTables();
27
27
  this.isInitialized = true;
28
28
 
29
- console.log(`[CodebaseDatabase] Initialized at: ${this.dbPath}`);
29
+ console.error(`[CodebaseDatabase] Initialized at: ${this.dbPath}`);
30
30
  }
31
31
 
32
32
  createTables() {
@@ -28,7 +28,7 @@ export class MemoryDatabase {
28
28
  this.createTables();
29
29
  this.isInitialized = true;
30
30
 
31
- console.log(`[MemoryDatabase] Initialized at: ${this.dbPath}`);
31
+ console.error(`[MemoryDatabase] Initialized at: ${this.dbPath}`);
32
32
  }
33
33
 
34
34
  createTables() {
@@ -33,7 +33,7 @@ export class ContextAnalyzer {
33
33
  patterns: []
34
34
  };
35
35
 
36
- console.log('[ContextAnalyzer] Initialized with mcfast API');
36
+ console.error('[ContextAnalyzer] Initialized with mcfast API');
37
37
  }
38
38
 
39
39
  /**
@@ -309,7 +309,7 @@ Return ONLY valid JSON, no markdown formatting.`;
309
309
  );
310
310
 
311
311
  await fs.writeFile(memoryPath, content);
312
- console.log(`[ContextAnalyzer] Updated MEMORY.md: ${analysis.memorySection}`);
312
+ console.error(`[ContextAnalyzer] Updated MEMORY.md: ${analysis.memorySection}`);
313
313
 
314
314
  } catch (error) {
315
315
  console.error('[ContextAnalyzer] Failed to update MEMORY.md:', error.message);
@@ -238,7 +238,7 @@ export class DailyLogs {
238
238
  const fileDate = file.replace('.md', '');
239
239
  if (fileDate < cutoffStr) {
240
240
  fs.unlinkSync(path.join(this.memoryPath, file));
241
- console.log(`[DailyLogs] Cleaned up: ${file}`);
241
+ console.error(`[DailyLogs] Cleaned up: ${file}`);
242
242
  }
243
243
  }
244
244
  }
@@ -27,12 +27,12 @@ export class Embedder {
27
27
  }
28
28
 
29
29
  async initialize() {
30
- console.log('[Embedder] Ultra-Enhanced Embedder initialized');
31
- console.log('[Embedder] Dimension:', this.ultra.dimension);
32
- console.log('[Embedder] Synonyms:', this.ultra.getStats().synonymCount);
33
- console.log('[Embedder] Domain patterns:', this.ultra.getStats().domainPatterns);
34
- console.log('[Embedder] Target accuracy: 90% (Option A - Fast & Offline)');
35
- console.log('[Embedder] Mercury re-ranking:', this.ultra.mercuryConfig.enabled ? 'ENABLED' : 'DISABLED (Option B ready)');
30
+ console.error('[Embedder] Ultra-Enhanced Embedder initialized');
31
+ console.error('[Embedder] Dimension:', this.ultra.dimension);
32
+ console.error('[Embedder] Synonyms:', this.ultra.getStats().synonymCount);
33
+ console.error('[Embedder] Domain patterns:', this.ultra.getStats().domainPatterns);
34
+ console.error('[Embedder] Target accuracy: 90% (Option A - Fast & Offline)');
35
+ console.error('[Embedder] Mercury re-ranking:', this.ultra.mercuryConfig.enabled ? 'ENABLED' : 'DISABLED (Option B ready)');
36
36
  }
37
37
 
38
38
  /**
@@ -159,7 +159,7 @@ export class Embedder {
159
159
  */
160
160
  enableMercuryReRanking(apiKey, options = {}) {
161
161
  this.ultra.enableMercuryReRanking(apiKey, options);
162
- console.log('[Embedder] ✨ Mercury re-ranking enabled! Accuracy target: 95%');
162
+ console.error('[Embedder] ✨ Mercury re-ranking enabled! Accuracy target: 95%');
163
163
  }
164
164
 
165
165
  /**
@@ -167,7 +167,7 @@ export class Embedder {
167
167
  */
168
168
  disableMercuryReRanking() {
169
169
  this.ultra.disableMercuryReRanking();
170
- console.log('[Embedder] Mercury re-ranking disabled. Using 90% accuracy mode.');
170
+ console.error('[Embedder] Mercury re-ranking disabled. Using 90% accuracy mode.');
171
171
  }
172
172
 
173
173
  /**
@@ -50,7 +50,7 @@ export class SyncEngine {
50
50
  // Start periodic sync
51
51
  this.startPeriodicSync();
52
52
 
53
- console.log(`[SyncEngine] Initialized. Last sync: ${this.lastSyncTime ? new Date(this.lastSyncTime).toISOString() : 'Never'}`);
53
+ console.error(`[SyncEngine] Initialized. Last sync: ${this.lastSyncTime ? new Date(this.lastSyncTime).toISOString() : 'Never'}`);
54
54
  }
55
55
 
56
56
  /**
@@ -82,7 +82,7 @@ export class SyncEngine {
82
82
  * Handle online event
83
83
  */
84
84
  handleOnline() {
85
- console.log('[SyncEngine] Back online, triggering sync...');
85
+ console.error('[SyncEngine] Back online, triggering sync...');
86
86
  this.isOnline = true;
87
87
  this.sync().catch(err => console.warn('[SyncEngine] Sync after reconnect failed:', err.message));
88
88
  this.emit('online');
@@ -92,7 +92,7 @@ export class SyncEngine {
92
92
  * Handle offline event
93
93
  */
94
94
  handleOffline() {
95
- console.log('[SyncEngine] Went offline');
95
+ console.error('[SyncEngine] Went offline');
96
96
  this.isOnline = false;
97
97
  this.emit('offline');
98
98
  }
@@ -188,7 +188,7 @@ export class SyncEngine {
188
188
  duration: `${duration}ms`
189
189
  };
190
190
 
191
- console.log(`[SyncEngine] ✅ Sync complete:`, result);
191
+ console.error(`[SyncEngine] ✅ Sync complete:`, result);
192
192
  this.emit('sync', result);
193
193
 
194
194
  return result;
@@ -1129,7 +1129,7 @@ export class UltraEnhancedEmbedder {
1129
1129
  this.mercuryConfig.apiKey = apiKey;
1130
1130
  this.mercuryConfig.rerankTopK = options.topK || 20;
1131
1131
  this.mercuryConfig.minScore = options.minScore || 0.3;
1132
- console.log('[UltraEnhancedEmbedder] Mercury re-ranking enabled');
1132
+ console.error('[UltraEnhancedEmbedder] Mercury re-ranking enabled');
1133
1133
  }
1134
1134
 
1135
1135
  /**
@@ -1137,7 +1137,7 @@ export class UltraEnhancedEmbedder {
1137
1137
  */
1138
1138
  disableMercuryReRanking() {
1139
1139
  this.mercuryConfig.enabled = false;
1140
- console.log('[UltraEnhancedEmbedder] Mercury re-ranking disabled');
1140
+ console.error('[UltraEnhancedEmbedder] Mercury re-ranking disabled');
1141
1141
  }
1142
1142
 
1143
1143
  /**
@@ -1204,7 +1204,7 @@ ${context}`;
1204
1204
  // const bestIndex = parseInt(response.choices[0].message.content) - 1;
1205
1205
 
1206
1206
  // For now, return candidates unchanged (implement Mercury integration later)
1207
- console.log('[UltraEnhancedEmbedder] Mercury re-ranking would be called here');
1207
+ console.error('[UltraEnhancedEmbedder] Mercury re-ranking would be called here');
1208
1208
  return candidates;
1209
1209
 
1210
1210
  } catch (error) {