byterover-cli icon indicating copy to clipboard operation
byterover-cli copied to clipboard

[BUG] MCP server (Claude Code) does not store data in Qdrant while the graphical interface works correctly

Open Sheld0n-Cooper opened this issue 1 year ago • 5 comments

Description

I’m using Cipher with the Gemini API.
The graphical interface works as expected at http://localhost:3000, and all data is correctly added to the Qdrant database when using the UI.

However, when I use the MCP server (Claude Code), the data is not stored in Qdrant.

Steps to Reproduce

  • Start Qdrant.
  • Start Cipher with the Gemini API:
    cipher --mode mcp
    
  • Use the MCP server with Claude Code → ask Cipher to remember a preference (for example: language = French).
  • Claude confirms the memory action with this message:
    “Great! I’ve added to Cipher’s memory that your preferred language is French. The system will remember this preference for our future interactions.”
  • Check Qdrant → no data is added.

Expected Behavior

Data added via the MCP server (Claude Code) should be stored in the Qdrant database, just like when it comes from the graphical interface.

Actual Behavior

Claude Code confirms the data is stored, but nothing is written to Qdrant.

Configuration

WSL ubuntu nodeJS: v22.17.0 cipher: 0.3.0 pnpm: 10.17.1

.env

# Cipher Environment Configuration
# Copy this file to .env and fill in your actual values

# ====================
# API Configuration
# ====================
# At least one API key is required
OPENAI_API_KEY=your-openai-api-key-here
ANTHROPIC_API_KEY=your-anthropic-api-key-here
OPENROUTER_API_KEY=your-openrouter-api-key-here
QWEN_API_KEY=your-alibaba-cloud-api-key-here
GEMINI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
VOYAGE_API_KEY=your-voyage-api-key-here
DEEPSEEK_API_KEY=your-deepseek-api-key-here

# Ollama Configuration (optional - only if using Ollama)
# OLLAMA_BASE_URL=http://localhost:11434

# ====================
# Embedding Configuration (optional)
# ====================
# Provider priority: OpenAI > Gemini > Ollama > Disabled
# If not specified in YAML, uses environment auto-detection

# Override embedding model (optional)
# EMBEDDING_MODEL=text-embedding-3-small

# Disable embeddings entirely (lightweight mode)
# DISABLE_EMBEDDINGS=true

# Optional: OpenAI base URL (for custom endpoints)
# OPENAI_BASE_URL=https://api.openai.com/v1

# ====================
# AWS Bedrock Configuration (optional - only if using AWS provider)
# ====================
AWS_ACCESS_KEY_ID=your-aws-access-key-id
AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key
AWS_DEFAULT_REGION=us-east-1
# Optional: AWS_SESSION_TOKEN=your-session-token

# ====================
# Azure OpenAI Configuration (optional - only if using Azure provider)
# ====================
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_VERSION=2024-10-01-preview

# ====================
# Application Settings
# ====================
NODE_ENV=development
CIPHER_LOG_LEVEL=info
 # Enable reflection memory tools in API mode (for web interface)
ENABLE_REFLECTION_TOOLS_IN_API_MODE=false
REDACT_SECRETS=true

# API prefix for routes
# CIPHER_API_PREFIX=""

# ====================
# Storage Configuration
# ====================
STORAGE_CACHE_TYPE=in-memory
# STORAGE_CACHE_HOST=localhost
# STORAGE_CACHE_PORT=6379
# STORAGE_CACHE_USERNAME=
# STORAGE_CACHE_PASSWORD=
# STORAGE_CACHE_DATABASE=0

STORAGE_DATABASE_TYPE=sqlite
STORAGE_DATABASE_NAME=/home/sheldon/code/cipher/data/cipher.db

# ====================
# Web Search Configuration
# ====================
WEB_SEARCH_ENABLE=true
WEB_SEARCH_ENGINE=duckduckgo # From now, cipher only supports duckduckgo engine
WEB_SEARCH_SAFETY_MODE=strict # Strict or moderate
WEB_SEARCH_MAX_RESULTS=2 # Number of search result at once
WEB_SEARCH_RATE_LIMIT=10 # Rate limit per minute

# CIPHER_MULTI_BACKEND=1
# CIPHER_PG_URL=postgres://cipheruser:cipherpass@localhost:5432/cipherdb
# CIPHER_WAL_FLUSH_INTERVAL=5000
# ====================
# Memory Search Configuration
# ====================
# Options: knowledge, reflection, both
SEARCH_MEMORY_TYPE=both

# ====================
# Vector Store Configuration
# ====================
# Available types: in-memory, chromadb, qdrant, milvus, faiss, pgvector, pinecone, weaviate, redis 
VECTOR_STORE_TYPE=qdrant

# Qdrant configuration (only used if VECTOR_STORE_TYPE=qdrant)
VECTOR_STORE_HOST=localhost
VECTOR_STORE_PORT=6333
VECTOR_STORE_URL=http://localhost:6333
# VECTOR_STORE_API_KEY=your-qdrant-api-key

# Milvus configuration (only used if VECTOR_STORE_TYPE=milvus)
# VECTOR_STORE_HOST=localhost
# VECTOR_STORE_PORT=19530
# VECTOR_STORE_URL=your-milvus-cluster-endpoint
# VECTOR_STORE_API_KEY=your-milvus-api-key
# VECTOR_STORE_USERNAME=your-milvus-zilliz-cloud-username
# VECTOR_STORE_PASSWORD=your-milvus-zilliz-cloud-password

# Vector collection settings
# NOTE: Naming rules vary by database type (see comments in original file).
# The name of the main collection/index for knowledge memory.
#
# IMPORTANT: Naming rules are specific to your chosen VECTOR_STORE_TYPE:
#   - ChromaDB, Milvus, pgvector: Alphanumeric and underscores (_). Hyphens (-) are not allowed.
#   - Pinecone:                 Lowercase alphanumeric and hyphens (-). Underscores (_) are not allowed.
#   - Qdrant:                   Alphanumeric, underscores (_), and hyphens (-) are all supported.
#   - Weaviate:                 PascalCase only (e.g., MyNewCollection). No special characters.
#   - Redis:                    Flexible; typically uses alphanumeric, _, -, and :.
VECTOR_STORE_COLLECTION=knowledge_memory
VECTOR_STORE_DIMENSION=1536
VECTOR_STORE_DISTANCE=Cosine
VECTOR_STORE_ON_DISK=false
# VECTOR_STORE_MAX_VECTORS=10000

# ====================
# Reflection Memory Configuration
# ====================
REFLECTION_VECTOR_STORE_COLLECTION=reflection_memory
DISABLE_REFLECTION_MEMORY=false

# ====================
# MCP Configuration
# ====================
# MCP_GLOBAL_TIMEOUT=30000

# ====================
# Knowledge Graph Configuration (optional)
# ====================
# NEO4J LOCAL CONFIGURATION (for local development)
# Local Neo4j configuration


# KNOWLEDGE_GRAPH_HOST=localhost
# KNOWLEDGE_GRAPH_PORT=7687
# KNOWLEDGE_GRAPH_URI=bolt://localhost:7687
# KNOWLEDGE_GRAPH_USERNAME=neo4j
# KNOWLEDGE_GRAPH_PASSWORD=your-local-password
# KNOWLEDGE_GRAPH_DATABASE=neo4j

# NEO4J CLOUD CONFIGURATION (for cloud deployment)

# KNOWLEDGE_GRAPH_URI=neo4j+s://your-instance.databases.neo4j.io:7687
# KNOWLEDGE_GRAPH_USERNAME=neo4j
# KNOWLEDGE_GRAPH_PASSWORD=your-password
# KNOWLEDGE_GRAPH_DATABASE=neo4j


# CONFIGURATION FOR EVENT MANAGEMENT

# # Enable or disable event filtering (true/false)
# EVENT_FILTERING_ENABLED=false

# # Comma-separated list of event types to filter out (block)
# # Example: tool:executionStarted,tool:executionCompleted,llm:thinking
# EVENT_FILTERED_TYPES=

# # Enable or disable event persistence (true/false)
# EVENT_PERSISTENCE_ENABLED=true

# # Path to store event log files (if using file storage)
# EVENT_PERSISTENCE_PATH=./data/events

# Enable or disable input refinement for better retrieval
ENABLE_QUERY_REFINEMENT=true 

memAgent/cipher.yml

# List of MCP servers to use
# mcpServers: 
#   filesystem:
#     type: stdio
#     command: npx
#     args:
#       - -y
#       - '@modelcontextprotocol/server-filesystem'
#       - .

# If not specified, please set it like this:
mcpServers: {}

# Choose ONLY ONE of the following LLM providers
llm:
  # provider: openai
  # model: gpt-4.1-mini
  # apiKey: $OPENAI_API_KEY
  # maxIterations: 50

  # provider: gemini
  # model: gemini-2.5-flash
  # apiKey: $GEMINI_API_KEY
  # maxIterations: 50

  # provider: anthropic
  # model: claude-3-5-haiku-20241022
  # apiKey: $ANTHROPIC_API_KEY
  # maxIterations: 50

  # provider: openrouter
  # model: google/gemini-2.5-pro
  # apiKey: $OPENROUTER_API_KEY
  # maxIterations: 50

  # provider: qwen
  # model: qwen3-14b
  # apiKey: $QWEN_API_KEY
  # maxIterations: 50
  # qwenOptions:
  #   enableThinking: false

  provider: gemini
  model: gemini-2.5-flash
  apiKey: $GEMINI_API_KEY
  maxIterations: 50
  
# --- AWS Bedrock LLM Configuration ---
  # provider: aws
  # model: us.anthropic.claude-3-5-sonnet-20241022-v2:0  # Or another Bedrock-supported model
  # maxIterations: 50
  # aws:
  #   region: $AWS_REGION
  #   accessKeyId: $AWS_ACCESS_KEY_ID
  #   secretAccessKey: $AWS_SECRET_ACCESS_KEY
  #   sessionToken: $AWS_SESSION_TOKEN   # Optional, for temporary credentials

# --- Azure OpenAI LLM Configuration ---
#   provider: azure
#   model: gpt-4o-mini  # Or your Azure deployment/model name
#   apiKey: $AZURE_OPENAI_API_KEY
#   maxIterations: 50
#   azure:
#     endpoint: $AZURE_OPENAI_ENDPOINT
#     deploymentName: gpt-4o-mini  # Optional, defaults to model name

# --- Ollama LLM Configuration (Sample, Commented Out) ---
  # provider: ollama
  # model: qwen3:8b      # Use the model you downloaded
  # maxIterations: 50
  # baseURL: $OLLAMA_BASE_URL

# --- LM Studio LLM Configuration (Sample, Commented Out) ---
  # provider: lmstudio
  # model: hermes-2-pro-llama-3-8b      # Use the model you have loaded
  # maxIterations: 50
  # baseURL: $LMSTUDIO_BASE_URL

# Embedding configuration: ONLY ONE of the following
OpenAI:

  # type: ollama
  # model: mxbai-embed-large
  # baseUrl: $OLLAMA_BASE_URL
  # dimensions: 1024

# Gemini:
embedding:
  type: gemini
  model: gemini-embedding-001
  apiKey: $GEMINI_API_KEY

# Ollama:
# embedding:
#   type: ollama
#   model: mxbai-embed-large
#   baseUrl: $OLLAMA_BASE_URL
#   dimensions: 1024

# LM Studio:
# embedding:
#   type: lmstudio
#   model: nomic-embed-text-v1.5
#   baseUrl: $LMSTUDIO_BASE_URL

# Voyage (for Anthropic/Claude users):
# embedding:
#   type: voyage
#   model: voyage-3-large     #(1024, 256, 512, 2048)
#   apiKey: $VOYAGE_API_KEY
#   dimensions: 1024

# Qwen:
# embedding:
#   type: qwen
#   model: text-embedding-v3
#   apiKey: $QWEN_API_KEY
#   dimensions: 1024          # (1024, 768 or 512)

# AWS Bedrock:
# embedding:
#   type: aws-bedrock
#   model: amazon.titan-embed-text-v2:0   # or cohere.embed-english-v3
#   region: $AWS_REGION
#   accessKeyId: $AWS_ACCESS_KEY_ID
#   secretAccessKey: $AWS_SECRET_ACCESS_KEY
#   sessionToken: $AWS_SESSION_TOKEN       # Optional, for temporary credentials
#   dimensions: 1024                       # 1024 (default), 512, or 256 for Titan V2
#   timeout: 30000
#   maxRetries: 3

# Azure OpenAI:
# embedding:
#   type: openai
#   model: text-embedding-3-small
#   apiKey: $AZURE_OPENAI_API_KEY
#   baseUrl: $AZURE_OPENAI_ENDPOINT        # e.g., https://your-resource.openai.azure.com
#   dimensions: 1536                       # Optional: depends on model
#   timeout: 30000
#   maxRetries: 3

# Disable embeddings entirely:
# embedding:
#   disabled: true

# Evaluation LLM configuration (non-thinking model for evaluation step)
# Ce LLM spécial évalue si le contenu détecté par le ReasoningContentDetector est suffisamment de bonne qualité pour être stocké dans reflection_memory (confiance > 0.7)
evalLlm:
  provider: gemini
  model: gemini-2.0-flash
  apiKey: $GEMINI_API_KEY

# System prompt - User customizable
# This prompt will be combined with built-in tool usage instructions

systemPrompt:
  enabled: true
  content: |
    You are an AI programming assistant focused on coding and reasoning tasks. You excel at:
    - Writing clean, efficient code
    - Debugging and problem-solving
    - Code review and optimization
    - Explaining complex technical concepts
    - Reasoning through programming challenges
  
    You should call each tool at most once per user request unless explicitly instructed otherwise.

Ubuntu/home/sheldon/.claude.json

//The rest of the code goes here...

  "mcpServers": {
    "cipher": {
      "type": "stdio",
      "command": "cipher",
      "args": [
        "--mode",
        "mcp"
      ],
      "env": {
        "GEMINI_API_KEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "MCP_SERVER_MODE": "aggregator",
        "SEARCH_MEMORY_TYPE": "both",
        "VECTOR_STORE_TYPE": "qdrant",
        "KNOWLEDGE_GRAPH_ENABLED": "true",
        "MAX_ITERATIONS": "30",
        "VECTOR_STORE_HOST": "localhost",
        "VECTOR_STORE_PORT": "6333",
        "VECTOR_STORE_URL": "http://localhost:6333",
        "VECTOR_STORE_COLLECTION": "knowledge_memory",
        "VECTOR_STORE_DIMENSION": "1536",
        "VECTOR_STORE_DISTANCE": "Cosine",
        "VECTOR_STORE_ON_DISK": "false",
        "REFLECTION_VECTOR_STORE_COLLECTION": "reflection_memory",
        "DISABLE_REFLECTION_MEMORY": "false",
        "ENABLE_QUERY_REFINEMENT": "true",
        "WEB_SEARCH_ENABLE": "true",
        "WEB_SEARCH_ENGINE": "duckduckgo",
        "WEB_SEARCH_SAFETY_MODE": "strict",
        "WEB_SEARCH_MAX_RESULTS": "2",
        "WEB_SEARCH_RATE_LIMIT": "10"
      }
    }
  }

Sheld0n-Cooper avatar Sep 26 '25 08:09 Sheld0n-Cooper

Sorry for the delay. After reviewing the code, there appear to be two possible causes for the error:

  1. In your .claude.json file, only Gemini_API_KEY is declared, and there seems to be an error initializing Gemini during startup.
  2. The issue might be related to how Cipher extracts memory from the conversation.

Solutions:

  1. I’ve submitted PR #255 to address this issue. Please pull the latest code and run it again.
  2. Try using Cipher with a different prompt to check whether it can successfully save memory in that scenario.

Please let me know if you need any further assistance.

willingWill17 avatar Sep 29 '25 04:09 willingWill17

This repository has been archived. No further work will be done. For production use, please visit https://byterover.dev/

IraBond avatar Nov 05 '25 21:11 IraBond

Вот полная инструкция по патчам и текущий статус:

Полная инструкция по патчам OpenAI SDK для Cipher MCP Проблема Cipher MCP v0.3.0 использует OpenAI Node.js SDK v4.104.0 для вызова LM Studio embedding API. SDK по умолчанию отправляет encoding_format: 'base64' и пытается декодировать ответ как base64. LM Studio игнорирует этот параметр и возвращает float-массив. SDK применяет Core.toFloat32Array() к float-массиву, что превращает 4096 значений в 1024 мусорных.

Почему патчи node_modules, а не бандла Cipher — бандл (dist/src/core/chunk-*.js), но embedding-код использует import OpenAI2 from "openai" — рантайм-импорт из node_modules/openai. Бандл НЕ содержит encoding_format или Float32Array — весь SDK-код загружается из node_modules.

Файлы для патча (2 файла, 2 патча в каждом = 4 изменения) Путь: C:\Users\Alexander\AppData\Roaming\npm\node_modules@byterover\cipher\node_modules\openai\resources\

Файл 1: embeddings.js (CJS — основной, Node.js загружает его) Файл 2: embeddings.mjs (ESM — на всякий случай)

Патч 1: Default encoding (строка ~47 в .js, ~21 в .mjs) ДО:

let encoding_format = hasUserProvidedEncodingFormat ? body.encoding_format : 'base64'; ПОСЛЕ:

let encoding_format = hasUserProvidedEncodingFormat ? body.encoding_format : 'float'; ЗАЧЕМ: SDK отправляет encoding_format: 'float' вместо 'base64'. LM Studio и так возвращает float, но теперь запрос корректный.

Патч 2: Response handler (строка ~59 в .js, ~32 в .mjs) ДО:

if (hasUserProvidedEncodingFormat) { ПОСЛЕ:

if (hasUserProvidedEncodingFormat || encoding_format !== 'base64') { ЗАЧЕМ: Когда encoding_format = 'float' (наш новый default), SDK пропускает base64-декодирование и возвращает ответ как есть. Без этого патча SDK всё равно пытается декодировать float-массив как base64.

После патча Перезапустить Kiro IDE (чтобы Cipher MCP процесс перезапустился и Node.js загрузил пропатченные файлы).

При обновлении Cipher (npm install -g @byterover/cipher) Патчи будут перезаписаны. Нужно применить заново. Задача 6 (start-services.ps1) будет содержать автопатч-функцию.

Патч CJS-версии embeddings.js был недостающим звеном. Проблема решена.

Итого что было сделано:

Найдена root cause: OpenAI SDK имеет ДВА файла (embeddings.js CJS + embeddings.mjs ESM), мы патчили только ESM, а Node.js загружал CJS Применены 4 патча (2 файла x 2 изменения): default encoding base64 -> float + расширенное условие response handler Cipher MCP теперь корректно записывает и ищет в Qdrant с 4096-мерными векторами

temporary-wanderer avatar Feb 08 '26 23:02 temporary-wanderer

Root Cause Found: isSignificantKnowledge() Significance Filter I experienced the exact same issue — Cipher 0.3.0, WSL2 Ubuntu 24.04, Qdrant local, Claude Code MCP aggregator mode. All cipher_extract_and_operate_memory calls returned extracted: 0, skipped: 1 while cipher_workspace_store worked intermittently. After extensive debugging, I found the root cause. It's not a dedup issue, not an API key issue, and not a Qdrant connectivity issue. The Problem Cipher has two hardcoded heuristic functions that run before embedding, before the LLM, and before dedup:

isSignificantKnowledge(content) — filters knowledge saves isWorkspaceSignificantContent(content) — filters workspace saves

These functions silently discard content they consider "non-significant", returning extracted: 0, skipped: 1 with no indication that the filter was the cause (identical response to dedup skip). The filter is at line ~23226 of dist/src/core/index.cjs: javascriptconst skipPatterns = [ /\b(my name|user['']?s? name|find my name|search.*name|who am i|what['']?s my name)\b/i, /\b(personal|profile|identity|username|login|password|email|address|phone)\b/i, // ... ]; The word email in the second regex causes all content mentioning email to be classified as "personal information" and silently discarded. This also affects address, phone, login, password, and profile — all of which appear frequently in legitimate technical content. Additionally, content that passes skipPatterns must then match technicalPatterns (a whitelist of English programming terms). Non-English content may fail this check even if it's highly technical. How I Confirmed This

Set CIPHER_LOG_LEVEL=debug in the MCP env block in ~/.claude.json Debug logs in /tmp/cipher-mcp.log showed:

ExtractAndOperateMemory: Skipping non-significant fact ExtractAndOperateMemory: No significant facts found after filtering

Content was being discarded before any embedding or LLM processing.

The Fix (Patch) Bypass the significance filter by making the functions always return true: bashCIPHER_CORE="$(dirname $(which cipher))/../lib/node_modules/@byterover/cipher/dist/src/core/index.cjs" CIPHER_APP="$(dirname $(which cipher))/../lib/node_modules/@byterover/cipher/dist/src/app/index.cjs"

Backup

cp "$CIPHER_CORE" "$CIPHER_CORE.bak" cp "$CIPHER_APP" "$CIPHER_APP.bak"

Patch

sed -i 's/function isSignificantKnowledge(content) {/function isSignificantKnowledge(content) { return true;/' "$CIPHER_CORE" sed -i 's/function isSignificantKnowledge(content) {/function isSignificantKnowledge(content) { return true;/' "$CIPHER_APP" sed -i 's/function isWorkspaceSignificantContent(content) {/function isWorkspaceSignificantContent(content) { return true;/' "$CIPHER_CORE" sed -i 's/function isWorkspaceSignificantContent(content) {/function isWorkspaceSignificantContent(content) { return true;/' "$CIPHER_APP" After patching: extracted: 1, confidence: 0.95 — knowledge memory works correctly. Note: This patch is overwritten by npm update -g @byterover/cipher and needs to be reapplied. Suggested Proper Fix The significance filter is too aggressive for real-world use. Some options:

Add an env var to disable it: e.g., DISABLE_SIGNIFICANCE_FILTER=true Fix the skipPatterns: Remove email, address, phone, login, password from the regex — these are common technical terms, not just PII Move the filter after LLM extraction: Let the LLM decide significance instead of regex heuristics At minimum: Log a warning (not just debug) when content is filtered, so users can diagnose the issue

Related Issues

#275 (MCP Timeout with RooCode) — likely the same root cause. The agent enters a retry loop because the significance filter keeps rejecting content, hitting max iterations.

Environment

Cipher: 0.3.0 (latest on npm as of 2026-03-13) OS: WSL2 Ubuntu 24.04 Node: v22.22.0 Qdrant: v1.17.0 (native binary, not Docker) MCP mode: aggregator LLM: OpenAI GPT-4o Embeddings: OpenAI text-embedding-3-small (dim 1536)

ThiagoMafra-Integrare avatar Mar 13 '26 19:03 ThiagoMafra-Integrare

For anyone still hitting this: I've put together a full write-up of the investigation, the workaround (before PR #296), and a Claude Code skill that encodes the fix into a deterministic save protocol.

Details here: https://github.com/ThiagoMafra-Integrare/cipher-significance-filter-fix

ThiagoMafra-Integrare avatar Mar 28 '26 20:03 ThiagoMafra-Integrare