Local MCP memory server for OpenCode using SQLite + libSQL vector + FTS5.
Project description
mcp-code-vector-memory-sql
Local MCP memory server for OpenCode/VS Code, Cline, Roo Code, Claude Desktop, OpenHands, Aider, Cursor, Gider, Windsurf, PydanticAI, LangGraph, CrewA powered by SQLite + FTS5 + libSQL vector (optional). It provides session-aware memory with semantic search, optional FTS5 re-ranking, and optional local summaries (GGUF).
Inspired by:
mcp-memory-libsql(libSQL + vector search)@modelcontextprotocol/server-memory(knowledge-graph style memory)
Table of contents
- Why
- How it works
- Hybrid search (vectors + FTS + graph)
- Key features
- Install
- MCP setup
- Configuration
- Models (embeddings + local summaries)
- MCP tools
- Data model
- Comparison
- Docs
- Development
- License
Why
When you use an MCP client while coding, you often need memory that is:
- local-first (privacy by default)
- fast to query (semantic search)
- scoped to a session (avoid cross-project bleed)
- easy to run (SQLite, no services)
mcp-code-vector-memory-sql focuses on that workflow.
How it works
Hybrid search (vectors + FTS + graph)
mcp-code-vector-memory-sql combines multiple retrieval signals to get better "developer
memory" results:
- Vector search: semantic similarity (libSQL vector backend)
- FTS5: exact/fuzzy term matches, merged into results
- Graph: entity-centric lookup via
get_context_graph
If you want to understand the full retrieval pipeline and ranking details, see docs/HYBRID_SEARCH.md and docs/TUNING_GUIDE.md.
remember
- Resolve
session_id(input, MCP context, orCODE_MEMORY_SESSION_ID) - Filter sensitive content + skip recent duplicates
- Generate basic tags
- Store in libSQL (vectors + FTS5)
- Extract entities/relations and update the knowledge graph
search_memory
- Create an embedding for the query (if vector search is enabled)
- Retrieve candidates (oversample) and merge optional FTS hits
- Re-rank with recency/priority and optional FTS bonus
- Apply
top_p(recency filter) and return the top results
Key features
- Session-aware storage (
session_idis required for remember; boosts same-session search results) - Vector search with
fastembed(CPU) + libSQL vector (optional, when usingCODE_MEMORY_DB_URL) - FTS5 for exact/fuzzy matching and re-ranking
- Entity extraction (LLM + regex fallback) and knowledge graph
- Optional local NER via GGUF (
llama-cpp-python) - Sensitive-content filter + recent dedupe (hash window)
Install
Requirements: Python 3.10+.
From source:
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# or
.venv\\Scripts\\activate # Windows
pip install -e .
Optional extras:
pip install -e ".[ner]"
Run manually (useful for debugging):
python -m code_memory
Legacy entrypoint (kept for compatibility):
python main.py
MCP setup
Below are configuration examples for popular MCP clients.
OpenCode / VS Code
Example opencode.json:
{
"mcpServers": {
"mcp-code-vector-memory-sql": {
"command": "python",
"args": ["-m", "code_memory"],
"env": {
"CODE_MEMORY_DB_URL": "libsql://127.0.0.1:8080",
"CODE_MEMORY_LOG_DIR": "C:/Users/you/.cache/code-memory/logs"
}
}
}
}
If you install the package globally, you can use the console script:
{
"mcpServers": {
"mcp-code-vector-memory-sql": {
"command": "code-memory",
"args": [],
"env": {}
}
}
}
Cline configuration
Add this to your Cline MCP settings:
{
"mcpServers": {
"mcp-code-vector-memory-sql": {
"command": "python",
"args": ["-m", "code_memory"],
"env": {
"CODE_MEMORY_DB_URL": "libsql://127.0.0.1:8080",
"CODE_MEMORY_LOG_DIR": "/path/to/logs"
}
}
}
}
Claude Desktop with WSL configuration
If you run Claude Desktop on Windows and want the server inside WSL, configure
Claude Desktop to call wsl.exe and start the Python module there.
Example:
{
"mcpServers": {
"mcp-code-vector-memory-sql": {
"command": "wsl.exe",
"args": [
"bash",
"-lc",
"cd /path/to/your/repo && source .venv/bin/activate && python -m code_memory"
],
"env": {
"CODE_MEMORY_DB_URL": "libsql://127.0.0.1:8080",
"CODE_MEMORY_LOG_DIR": "/path/to/logs"
}
}
}
}
Notes:
- WSL uses Linux paths (for example
/home/you/...), notC:\\.... - If you do not use a venv in WSL, remove
source .venv/bin/activateand ensurepythoncan importcode_memory.
Configuration
Full reference (detailed explanations + more examples): docs/CONFIGURATION.md.
Common env vars (most people only change these)
| Variable | What it controls |
|---|---|
CODE_MEMORY_WORKSPACE |
Root folder for MCP resource://workspace and resource://readme |
CODE_MEMORY_DB_URL |
Required libSQL URL (libsql://...) |
CODE_MEMORY_EMBED_MODEL |
Embedding model name (fastembed) |
CODE_MEMORY_EMBED_DIM |
Embedding dimension (required for non-default models) |
| Vector search | Always enabled |
| FTS5 | Always enabled |
CODE_MEMORY_TOP_K |
Default max results returned by search_memory |
CODE_MEMORY_TOP_P |
Recency filter applied during re-ranking (0..1) |
Example configs
Project-local DB + logs:
{
"CODE_MEMORY_DB_URL": "libsql://127.0.0.1:8080",
"CODE_MEMORY_LOG_DIR": "C:/repo/.logs"
}
Tune search a bit:
Models (embeddings + local NER)
Detailed guide: docs/MODELS.md.
Embedding models (fastembed)
The default is BAAI/bge-small-en-v1.5 (fast, small, strong baseline).
Other popular options you can use with this server:
snowflake/snowflake-arctic-embed-s(quality-focused, still small)nomic-ai/nomic-embed-text-v1.5(larger, better for long inputs)
Note: some models (e.g. Qwen2.5-Embedding-0.6B) are not supported by
fastembed in this repo today. They require a different embedding backend.
Local NER models (GGUF)
Any GGUF model supported by llama-cpp-python can be used for local NER/entity extraction,
including small code-focused models like Qwen2.5-Coder-0.5B (very fast).
MCP tools
Full reference (inputs/outputs/examples): docs/API.md.
remember(content, session_id, kind, tags, priority, metadata_json)search_memory(query, session_id, limit, top_p)list_recent(limit)list_entities(memory_id)upsert_entity(name, entity_type, observations_json, memory_id)add_relation(source, target, relation_type, memory_id)get_entity(name)get_context_graph(query, limit)maintenance(action, confirm, session_id, older_than_days)diagnostics()health()
Data model
entities: both memory nodes (entity_type='memory') and extracted world-fact entitiesobservations: stored text (content + tags/metadata), linked to an entityrelations: directed edges between entities, optionally linked to an observationobservations.embedding: libSQL vector embedding column (best-effort; requires libSQL vector functions)observations_fts: FTS5 index synchronized via triggers (creates internal FTS5 tables)
Comparison
| Capability | mcp-code-vector-memory-sql | mcp-memory-libsql | @modelcontextprotocol/server-memory |
|---|---|---|---|
| Storage | SQLite | libSQL (SQLite compatible) | JSONL |
| Remote DB | No | Yes (libSQL/Turso) | No |
| Vector search | Yes (libSQL vector) | Yes (libSQL vector) | No |
| FTS re-rank | Yes (FTS5) | Not documented | Not documented |
| Session scoping | Yes (session_id) |
Not documented | Not documented |
| Knowledge graph | Yes | Yes | Yes |
| Local NER | Optional (GGUF) | Not documented | Not documented |
Note: comparison is based on the published READMEs of those projects.
Docs
- Docs index
- MCP tools API
- Configuration
- libSQL local backend
- Models
- Benchmarks
- Architecture
- Hybrid search
- Tuning guide
- Operations
Performance snapshot
Latest local benchmark artifacts are stored under docs/benchmarks/.
| Benchmark | Mean | Ops/sec |
|---|---|---|
insert |
0.972 ms | 1029 |
embed |
5.363 ms | 186 |
vector_search |
7.763 ms | 129 |
hybrid_search |
10.840 ms | 92 |
tags_fts |
0.131 ms | 7605 |
tags_like |
0.017 ms | 57367 |
Development
pip install -e ".[dev]"
pytest
License
TBD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_malconmikami_code_memory-0.1.0.tar.gz.
File metadata
- Download URL: iflow_mcp_malconmikami_code_memory-0.1.0.tar.gz
- Upload date:
- Size: 37.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b3784344210c7f076a9ffdba61ebd4c5637955a62ee733470f5b9cc1aac5c8a
|
|
| MD5 |
cf8a4cb365ff069ad41e78b21ada4523
|
|
| BLAKE2b-256 |
faadb44432b424ebf87e21f2d3b3e2cdd4dd6635c1d8e04bc497bcdbbc685cb0
|
File details
Details for the file iflow_mcp_malconmikami_code_memory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_malconmikami_code_memory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e784af3ae56a9edf5eb3a0e9794fcff5dbef6197c0c9df7c3ba9f5b1f1cd014a
|
|
| MD5 |
d498982f3c2337587d19a09df35d9ee7
|
|
| BLAKE2b-256 |
1e50d296c45c82c3329d225d261800594b45b4d3e4b3063ab3e03a4d40a78b48
|