-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Description
The embeddings.ts file uses console.log() which outputs to stdout. In the MCP (Model Context Protocol) context, stdout is reserved for JSON-RPC communication. Any non-JSON output to stdout corrupts the protocol and causes connection errors.
Error observed in Claude Code debug logs
MCP server "plugin:episodic-memory:episodic-memory": Connection error: Unexpected token 'L', "Loading em"... is not valid JSON
MCP server "plugin:episodic-memory:episodic-memory": Connection error: Unexpected token 'E', "Embedding "... is not valid JSON
Root cause
src/embeddings.tslines 7 and 12 useconsole.log()instead ofconsole.error()- The
@xenova/transformerslibrary outputs progress messages to stdout by default
Suggested fix
In src/embeddings.ts:
import { pipeline, Pipeline, FeatureExtractionPipeline, env } from '@xenova/transformers';
// Disable progress callbacks to prevent stdout pollution in MCP context
env.allowLocalModels = true;
env.useBrowserCache = false;
let embeddingPipeline: FeatureExtractionPipeline | null = null;
export async function initEmbeddings(): Promise<void> {
if (!embeddingPipeline) {
console.error('Loading embedding model (first run may take time)...'); // Changed from console.log
embeddingPipeline = await pipeline(
'feature-extraction',
'Xenova/all-MiniLM-L6-v2',
{ progress_callback: null } // Disable progress output to stdout
);
console.error('Embedding model loaded'); // Changed from console.log
}
}Changes needed
- Change
console.log→console.errorfor all status messages (stdout is reserved for MCP JSON) - Add
{ progress_callback: null }to the pipeline options to disable@xenova/transformersprogress output - Import
envfrom@xenova/transformersand configure it to prevent additional stdout output
Environment
- episodic-memory version: 1.0.15
- Claude Code version: 2.1.2
- OS: Windows 11
Workaround
I've manually patched dist/embeddings.js with the fix above and it resolves the issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels