Skip to main content
Glama
lvyuan1688

localmem-mcp-zh

by lvyuan1688

localmem-mcp-zh

🇨🇳 Local-first, zero-API Chinese AI memory MCP — SQLite + fastembed Chinese-optimized

Demo

localmem-mcp-zh gives any MCP-compatible client (Claude Code, Codex, Gemini CLI, Cursor, Windsurf, Cline …) a fully local, zero-cloud long-term memory. All memories are stored in a single SQLite file; search uses local cosine similarity + Chinese FTS5 + jieba tokenization weighted BM25, and retrieval costs zero tokens.

Inspired by OpenAgentHQ/localmem-mcp (6 ⭐, created 2026-08-14), the original is English-only. This repo makes Chinese optimizations:

  • jieba Chinese tokenization, avoiding the English unicode61 tokenizer failing on Chinese

  • Default embedding model BAAI/bge-small-zh-v1.5 (SOTA small model for Chinese retrieval)

  • All tool descriptions are bilingual (Chinese/English), making it easy for Chinese agents to understand intent

Why you need it

Most AI memory tools (Mem0, Zep, Graphiti) call an LLM on both the storage and retrieval paths. This repo only runs the embedding model once locally, then stays offline forever. Beyond privacy, cost matters even more: storing 10,000 memories and retrieving 10,000 times, localmem-mcp-zh makes 0 LLM calls.

Related MCP server: tartarus-mcp

Installation

pip install localmem-mcp-zh
# 或
uvx localmem-mcp-zh

The first run downloads the embedding model from Hugging Face (~90 MB), then it's fully offline afterwards.

Connecting clients

Claude Code / Codex / Gemini CLI

Add the following to your MCP config (~/.config/mcp/servers.json or your client's config file):

{
  "mcpServers": {
    "localmem-zh": {
      "command": "uvx",
      "args": ["localmem-mcp-zh"],
      "env": {
        "LOCALMEM_DB": "~/.localmem-mcp-zh/memories.db"
      }
    }
  }
}

Cursor / Windsurf / VS Code

Add a server with the same name in the IDE's MCP settings, with the same parameters as above.

Four tools

Tool

Purpose

store_memory

Save a persistent memory — decisions, preferences, facts, optionally with tags

search_memory

Search memories by semantics. "Which database?" can find "we chose SQLite"

recall_memory

Re-read a memory by id, or fetch the most recent few

memory_stats

Where the database is, how many entries are stored

Privacy

No network requests at all, except for the one-time embedding model download. Delete ~/.localmem-mcp-zh/memories.db and the memories are gone.

Development

git clone https://github.com/lvyuan1688/localmem-mcp-zh
cd localmem-mcp-zh
pip install -e ".[dev]"
pytest

License

MIT — see LICENSE.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    A local, fully-offline MCP memory server that enables persistent storage and retrieval of information using SQLite with both keyword and semantic vector search capabilities.
    10
    19 npm
    13
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A local-first MCP memory server providing persistent, searchable memory for AI agents, powered by SQLite.
    1 npm
    1
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Local-first AI Memory MCP server for AI agents to search and manage knowledge stored in Obsidian vaults, optimized for CJK languages with zero AI dependency.
    2
    MIT