MemPalace — Local-First AI Memory Palace Give your AI a memory. Mine projects and conversations into a searchable palace.
No API key required. Exposed via MCP (Model Context Protocol) and CLI.
Version: 3.5.0 | License: MIT
Forked from MemPalace/mempalace — đang được kiểm tra, nâng cấp và vận hành bởi @SlncTrZ (Trương Công Định)
Dự án này đang trong quá trình kiểm tra, sửa lỗi và nâng cấp . Một số thành phần có thể chưa ổn định hoặc đang được tái cấu trúc.
Khoản mục Bản gốc Bản này MCP Tools ~10 tools 30 tools — Palace R/W, Knowledge Graph, Navigation, Agent Diary, HooksStorage Backend Qdrant-only 3 backends — Qdrant (default), PgVector, SQLite ExactEmbedding Ollama-dependent ONNX local (zero-dep) + Ollama (optional)Knowledge Graph ❌ Không có Temporal entity-relationship graph (SQLite, valid_from/valid_to, invalidation) Palace Navigation ❌ Không có Room graph, BFS traversal, cross-wing tunnels, halls Agent Diary ❌ Không có AAAK-compressed diary per agent, read/write tools i18n ❌ Không có 15 ngôn ngữ (EN, VI, JA, KO, ZH, FR, DE, ES, RU, IT, PT-BR, HI, ID, BE, ZH-TW)Sources Framework ❌ Không có RFC 002 — extensible source adapters for mining Auto-Save Hooks ❌ Không có Stop hook (15 msg), PreCompact hook AAAK Dialect ❌ Không có Entity codes, emotion markers, 30× lossless compression Entity System ❌ Không có Auto-detect people/projects, entity code registry CLI 5 subcommands 12+ subcommands (init, mine, search, split, wake-up, compress, status, repair, mcp, hook, instructions)Modules 8 modules 32 modules — thêm repair, backups, sweeper, migrate, daemon, dynamics, exporter, fact_checker, format_miner, corpus_origin, dedup, hallways, ids, sync, wal, closet_llm, convo_scanner, diary_ingest, spellcheck, sourcesTests ~20 (lỗi import) 128 tests pass — protocol, backend registry, Qdrant, palace, config, AAAKHTTP Server ❌ Không có SSE transport + Qdrant query API + landing page Security API key trong code Pre-commit hook, env vars, .gitignore, không hardcoded IP CLI Entry Point Không rõ ràng mempalace + mempalace-mcp (pyproject.toml scripts)
┌──────────────────────────────────────────────────┐
│ MCP Client (Claude Code / Cline) │
│ ↓ stdio JSON-RPC │
├──────────────────────────────────────────────────┤
│ mcp_server.py — 30 MCP tools │
├──────────────────────────────────────────────────┤
│ CLI (mempalace) ←→ Palace (Qdrant) │
│ ↕ │
│ Knowledge Graph (SQLite, temporal) │
│ ↕ │
│ Palace Graph (room navigation, tunnels) │
├──────────────────────────────────────────────────┤
│ Backends: Qdrant | PgVector | SQLite Exact │
│ Embeddings: ONNX (local) | Ollama | external │
└──────────────────────────────────────────────────┘
Wings (projects/people)
└── Rooms (topics)
└── Closets (summaries)
└── Drawers (verbatim memories)
Halls → connect rooms within a wing
Tunnels → connect rooms across wings
Tool Description mempalace_statusPalace overview — total drawers, wing & room counts mempalace_list_wingsList all wings with drawer counts mempalace_list_roomsList rooms within a wing (or all) mempalace_get_taxonomyFull taxonomy: wing → room → drawer count mempalace_searchSemantic search — query, wing/room filter, distance threshold mempalace_check_duplicateCheck if content already exists before filing mempalace_get_drawerFetch a single drawer by ID (full content + metadata) mempalace_list_drawersList drawers with pagination, wing/room filter mempalace_get_aaak_specGet the AAAK specification — ⚠️ lossy summary, not lossless compression
Tool Description mempalace_add_drawerFile verbatim content into a wing/room mempalace_update_drawerUpdate an existing drawer's content / metadata mempalace_delete_drawerDelete a drawer by ID (irreversible) mempalace_syncPrune drawers from deleted/moved source files
Knowledge Graph (Temporal Facts) Tool Description mempalace_kg_queryQuery entity relationships (outgoing/incoming/both) with temporal filter mempalace_kg_addAdd a fact: subject → predicate → object (optional valid_from/valid_to) mempalace_kg_invalidateMark a fact as no longer true mempalace_kg_timelineChronological timeline of facts for an entity (or all) mempalace_kg_statsKnowledge graph overview: entities, triples, current vs expired
Navigation (Palace Graph) Tool Description mempalace_traverseWalk the palace graph from a room (BFS, max_hops) mempalace_find_tunnelsFind rooms bridging two wings mempalace_create_tunnelCreate a cross-wing tunnel mempalace_list_tunnelsList all explicit tunnels (optional wing filter) mempalace_delete_tunnelDelete a tunnel by ID mempalace_follow_tunnelsFollow tunnels from a room to connected wings mempalace_graph_statsGraph overview: rooms, tunnels, edges between wings
Tool Description mempalace_diary_writeWrite to agent diary in AAAK format mempalace_diary_readRead recent diary entries
Tool Description mempalace_hook_settingsGet/set hook behavior (silent_save, desktop_toast) mempalace_memories_filed_awayCheck if a recent checkpoint was saved mempalace_reconnectForce reconnect after external writes
mempalace init < dir> Initialize a new palace
mempalace mine < dir> Mine a project (default mode)
mempalace mine < dir> --mode convos Mine conversation exports
mempalace search " query" Search your memories
mempalace split < dir> Split large transcript files
mempalace wake-up Load palace into context
mempalace compress Compress palace storage
mempalace status Show palace status
mempalace repair Qdrant snapshot backup & recovery
mempalace check-qdrant Check Qdrant backend health
mempalace mcp Show MCP setup command
mempalace hook run Run hook logic (for harness)
mempalace instructions < name> Output skill instructions pip install -e " .[dev]" # Or: pip install mempalace Variable Default Description MEMPALACE_HOME~/.mempalacePalace data directory MEMPALACE_EMBEDDING_DEVICEautoEmbedding device: cpu, cuda, dml, coreml PALACE_BACKENDqdrantStorage backend: qdrant, pgvector, sqlite_exact PALACE_PATH(auto) Explicit palace path QDRANT_URLhttp://localhost:6333Qdrant server URL (qdrant backend) OLLAMA_URLhttp://localhost:11434Ollama server URL (optional)
Backend Purpose Qdrant (default)Vector DB — local Qdrant or remote server PgVector PostgreSQL vector extension — for existing Postgres deployments PgVector PostgreSQL vector extension — for existing Postgres deployments SQLite Exact Exact (brute-force) search — debug, tiny palaces, CI
Local ONNX model (default) — zero-dependency, no API keyOllama — nomic-embed-text:latest (768d) or other modelsExternal embedding API (custom adapters) Module Description cli.pyCLI entry point — 12+ subcommands mcp_server.pyMCP server handler (imports from mcp_tools.py) mcp_tools.py30 MCP tool definitions + handlers (tách từ monolith) miner.pyProject file ingest — chunks by paragraph convo_miner.pyConversation ingest — exchange pairs, room detection searcher.pySemantic search with filters layers.py4-layer memory stack (L0 identity → L3 deep search) dialect.pyAAAK compression — entity codes, 30× lossless ratio knowledge_graph.pyTemporal entity-relationship graph (SQLite) palace_graph.pyRoom-based navigation graph (BFS, tunnels) entity_registry.pyEntity code registry — AAAK codes, ambiguous names entity_detector.pyAuto-detect people/projects from file content normalize.pyConvert 5 chat formats to standard transcript onboarding.pyGuided first-run setup backups.pyPalace backup & restore repair.pyRebuild corrupted vector indices sweeper.pyClean up stale/expired drawers migrate.pySchema migration across versions
python -m pytest tests/ -v Script Purpose scripts/pre_commit_check.pyPre-commit API key scanner
See SECURITY.md for API key protection and pre-commit hook setup.
AAAK Dialect — Lossy Summary, không phải nén lossless AAAK (dialect.py) là định dạng tóm tắt có cấu trúc (structured summary) , không phải nén lossless:
Nén (Compression) : Xử lý cục bộ bằng Python (dialect.py) — dùng regex, keyword mapping, emotion dictionary, entity extraction. Không gọi LLM. Giải nén (Decompression) : Format được thiết kế để LLM đọc trực tiếp — không có decoder. LLM suy diễn lại ngữ cảnh từ các token còn lại, dẫn đến hallucination.Dữ liệu gốc : Verbatim content được lưu riêng trong drawers (ChromaDB/Qdrant). AAAK chỉ là summary layer để định hướng tra cứu, không thay thế dữ liệu gốc.Xem docstring đầu file mempalace/dialect.py để biết chi tiết. Hạn chế Mô tả CLI monolith cli.py ~1.8k lines — nhiều subcommand trong 1 fileThiếu type hints Hầu hết các module chưa có type annotations đầy đủ Test coverage Chỉ ~9% — cần integration tests với Qdrant thật Documentation Chưa có API docs tự động (Sphinx/MkDocs) Chưa publish PyPI Chưa có release trên PyPI
MIT