memalyze

io.github.mahaoboy由 GitHub 帳號 mahaoboy 發布v0.1.0更新於 Nov 1, 2026

Self-hosted agent memory: redaction before write, append-only audit, local embeddings.

已驗證STDIO僅桌面知識與記憶安全與監控

概覽

AI 產生的概覽

自架的離線代理記憶伺服器,寫入前先脫敏、每次讀取都留稽核,並使用本機嵌入模型。

可以做什麼
  • 儲存記憶,在去重、索引與嵌入之前先做脫敏,並回報觸發了哪些規則
  • 依向量相似度檢索記憶,並以關鍵字補足;向量路徑不可用時降級為純關鍵字搜尋
  • 依 id 軟刪除記憶,重複刪除也安全
  • 用簡單的 echo 工具確認 MCP 連線正常
  • 透過命令列把僅可追加的稽核日誌匯出為 CSV 或 JSON,並產生一致的資料庫快照
適用情境
適合需要把代理記憶留在本機或自有伺服器、不能依賴雲端 API 或執行時下載模型,且要能回答「誰在何時讀了哪些資料」的情境。對合規或離線環境,以及希望工具面盡量小的使用者較合適。
執行需求
以本機靜態二進位透過 stdio 執行,或使用 Claude Desktop 的 MCPB 安裝包,或以 Docker 搭配 Streamable HTTP 執行。本機嵌入需要 Ollama 端點(預設 qwen3-embedding:0.6b 模型(約 640 MB)。從原始碼建置需要 Go 1.27+。透過環境變數設定,例如 MEMALYZE_DB、MEMALYZE_OLLAMA_URL 與 MEMALYZE_HTTP_TOKEN。
安裝前請注意
脫敏預設不可逆,也可設為 dry-run 或關閉,設定不當可能存入明文或丟掉原本想保留的內容。稽核日誌禁止更新但不禁止刪除,能取得資料庫檔案的人可以刪列。除非開啟 MEMALYZE_AUDIT_QUERY_PLAIN,檢索文字只存雜湊。沒有依使用者認證:每個行程一個權杖,actor 取自 MEMALYZE_ACTOR。MCPB 安裝包尚未在真實桌面上驗證。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 memalyze,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

memalyze

MCP-native, self-hosted memory for AI agents — with the governance an enterprise will actually ask for.

One static binary. Local embeddings. No cloud, no graph database, no Python stack. Redaction happens before anything is written; every read is audited.

Website · MCP Registry · v0.1.0

bash
./memalyze          # MCP over stdio, for Claude Code / Cline / any harness

v0.1.0 is out — static binaries for linux/darwin/windows, checksums published alongside.

[memalyze governance demo]


The problem

Every agent framework ships its own memory: a vector table here, a JSON file there, a "notes" folder somewhere else. Three things follow, and all three hurt in production:

  1. You cannot audit it. "Which customer's data did the agent read last Tuesday?" has no answer, so security review stops the project.
  2. You cannot deploy it offline. Most options either call a cloud API or download model weights from HuggingFace at runtime — both fail inside a bank, a hospital, or a factory.
  3. You cannot keep it small. Twenty-three tools, a graph database, and a Python dependency tree later, the "memory feature" is a second product to operate.

memalyze is the middleware that fixes those three, and nothing else.

What is different

Cloud memory APIsFramework built-insPersonal note appsmemalyze
Where data livesvendor cloudinside the frameworklocal Markdownyour server / your laptop
How to connectproprietary APItied to one frameworkMCPMCP, any harness, stdio or HTTP
Redaction before write❌❌❌✅ 8 rule families, configurable, irreversible by default
Read auditpartial❌❌✅ append-only*, per-actor, exportable
Offline❌partial⚠️ model download needed✅ local embeddings, no network
DeploymentSaaSwith the framework173 Python packages✅ one static binary / one compose file
Tool surface——23 tools4 tools

* A database trigger rejects UPDATE on audit_log; DELETE is not blocked, so anyone with the database file can remove rows. It is append-only at the SQL level, not WORM — export to object-lock or syslog storage if deletions are inside your threat model (SECURITY.md).

Not another mem0, and not Basic Memory either: those are good at remembering. memalyze assumes remembering is becoming a commodity and competes on governance, offline operation, and a deliberately small surface.

30-second demo

No Ollama, no network, no MCP client:

bash
./examples/demo/demo.sh# or: go run ./cmd/memalyze demo

It writes a memory containing a phone number, an e-mail and a resident ID, then shows:

  • what is actually stored ([REDACTED:phone], not 13800138000);
  • that searching for the original number returns 0 hits;
  • that a business-word search still hits, returning the redacted text;
  • the audit rows for the two writes and the two reads.

Details and transcripts: docs/s15-redaction-audit.md.

Quick start

1. Binary + local embedding model

Prebuilt, checksum-verified (Linux/macOS; Windows: take the .exe from the release page):

bash
curl -fsSL https://raw.githubusercontent.com/mahaoboy/memalyze/main/scripts/install.sh | shollama pull qwen3-embedding:0.6b      # ~640 MB, 1024-dim, strong on Chinesememalyze --version

From source (Go 1.27+): make build, then ./memalyze --version.

2. Wire it into a harness

Claude Code (project scope):

bash
claude mcp add --scope project memalyze -- "$(pwd)/memalyze"cp examples/claude-code/CLAUDE.md ./CLAUDE.md   # makes Claude search before answering

Cline: copy examples/cline/cline_mcp_settings.json and .clinerules. Generic harness: examples/custom-harness/ — one prompt contract plus pseudocode. All options: examples/README.md.

3. Or one-click in Claude Desktop (MCPB)

Download the bundle for your platform from the v0.1.0 release and open it. Claude Desktop shows an install sheet and asks where to keep memalyze.db.

PlatformFile
macOS Apple Siliconmemalyze-0.1.0-darwin-arm64.mcpb
macOS Intelmemalyze-0.1.0-darwin-amd64.mcpb
Windows x64memalyze-0.1.0-windows-amd64.mcpb
Linux x64memalyze-0.1.0-linux-amd64.mcpb

The binary inside is the same v0.1.0 build as above. These bundles are new and have not been opened on a real macOS/Windows desktop yet — if the install sheet does not appear, use the plain binary. The server is also listed in the MCP Registry.

4. Or run it in Docker (memalyze + Ollama + model pull)

bash
printf 'MEMALYZE_HTTP_TOKEN=%s\n' "$(openssl rand -hex 24)" > .envdocker compose up -d --buildcurl -s http://127.0.0.1:8080/healthz     # {"status":"ok","version":"dev"}

Point a Streamable-HTTP MCP client at http://127.0.0.1:8080/mcp with Authorization: Bearer $MEMALYZE_HTTP_TOKEN. See docs/s16-docker.md.

Tools

Four, on purpose. Every extra tool is a decision the model has to make.

ToolWhat it doesNotable semantics
memory_addstore a memoryduplicates return the existing id; embedding failure keeps the memory (embedding_failed=true); returns redacted + rule names
memory_searchretrievevector first, keyword backfill, degraded + degrade_reason when the vector path is unavailable; empty query lists recent
memory_deletesoft deleteidempotent for already-deleted ids; unknown id returns a tool error
echowiring checkproves the MCP link works; no business logic

There is no memory_context tool: memory_search already returns text you can paste into a prompt, and two overlapping tools make model choice worse (D-017).

Governance

Redaction (write path). Rules run in memory.Service.Add before dedup, FTS and embedding — so plaintext never reaches the main table, the full-text index or a vector.

RuleExample inputStored as
private_key_block-----BEGIN RSA PRIVATE KEY-----…[REDACTED:private_key]
id_card_cn110101199003071234[REDACTED:id_card]
bank_card6222021234567890123[REDACTED:bank_card]
jwteyJhbGciOi…[REDACTED:jwt]
api_key_known_prefixsk-…, ghp_…, AKIA…[REDACTED:api_key]
credential_assignmentapi_key=abcdef123456api_key=[REDACTED:credential]
email[email protected][REDACTED:email]
phone_cn+86 13800138000[REDACTED:phone]

Modes: enforce (default), dry-run (count only, for tuning), off (debugging). Custom rule packs are JSON: examples/redaction-rules.json.

Audit (read path). Append-only audit_log (a database trigger rejects UPDATE): actor, tenant, scope, action, memory id, timestamp, result count, degraded, redaction count. The search text itself is stored as SHA-256 + length unless you explicitly set MEMALYZE_AUDIT_QUERY_PLAIN=1.

bash
memalyze audit export --from 2026-10-01 --to 2026-10-31 --format csv --out audit.csvmemalyze audit export --tenant acme --format json

What is not here yet: per-user authentication (one token per process, actor from env), audit retention/purge, reversible redaction, audit UI.

Retrieval, measured

Numbers from S8 on a 60-memory Chinese corpus, 16 queries, measured not assumed (docs/s8-retrieval-report.md):

Approachrecall@3MRR
qwen3-embedding:0.6b (default)0.940.92
CJK bigram FTS5 (keyword backfill)0.88—
nomic-embed-text0.47—

Two counter-intuitive findings that shaped the design: SQLite FTS5's default tokenizer cannot search Chinese at all (0.19 recall until we stored bigram text), and RRF fusion scored worse than vector-only, so v0.1 does not fuse. See D-012.

Latency (S14, cold start fixed): warmup 37.8 s in background, then search 1.14 s with degraded=false; after five idle minutes a fresh process answers in 1.52 s. If the vector path is unavailable, search degrades to keyword in ≤3 s instead of hanging (D-015/D-018).

How it works

harness (Claude Code / Cline / your agent)   │  MCP: stdio or Streamable HTTP   ▼internal/mcp     4 tools, argument conversion only   ▼internal/memory  redact → dedup → store → embed; search: vector → keyword → degraded   ├── internal/govern     rule engine (8 families, JSON configurable)   ├── internal/store      interface; sqlite impl (memories, embeddings, audit_log)   ├── internal/embed      float32 BLOB codec, cosine; Ollama client   └── internal/search     CJK bigram tokenizer + FTS5 MATCH builder
  • SQLite (WAL) with ULID ids, partial unique index for dedup, soft delete, TTL.
  • Vectors are float32 little-endian BLOBs; search is brute-force cosine (fine under ~10k memories, and the honest limit of a single-binary design).
  • Schema migrations are versioned via PRAGMA user_version (v1 → v2 adds the audit table).

Operations

bash
memalyze audit export --from 2026-10-01 --format csv --out audit.csv   # who read whatmemalyze backup --out /var/backups/memalyze-$(date +%F).db             # consistent snapshotmemalyze health --url http://127.0.0.1:8080/healthz                    # probe

Configuration

All through environment variables; defaults work out of the box.

VariableDefaultMeaning
MEMALYZE_DB./memalyze.dbSQLite path
MEMALYZE_TENANTdefaultdefault tenant for tool calls
MEMALYZE_OLLAMA_URLhttp://127.0.0.1:11434local embedding endpoint
MEMALYZE_EMBED_MODELqwen3-embedding:0.6bembedding model
MEMALYZE_QUERY_TIMEOUT3svector-path budget before degrading
MEMALYZE_KEEP_ALIVE30mOllama model residency
MEMALYZE_REDACT_MODEenforceenforce / dry-run / off
MEMALYZE_REDACT_RULES(built-in)path to a JSON rule pack
MEMALYZE_AUDITonappend audit rows
MEMALYZE_ACTORlocalactor recorded in audit
MEMALYZE_AUDIT_QUERY_PLAINoffstore query text (default: hash only)
MEMALYZE_HTTP_ADDR(empty = stdio)e.g. :8080 for Streamable HTTP
MEMALYZE_HTTP_TOKEN(empty)Bearer token; required when binding off-loopback

Status

Honest snapshot — this is an early-stage project, not a 1.0.

MilestoneState
M0 立项与定位 (S1–S4)✅
M1 备料与技术验证 (S5–S8)✅
M2 核心链路 (S9–S14)✅
M3 打磨与文档 (S15–S19)✅ S15 governance, S16 Docker, S17 docs, S18 tests+CI, S19 examples
M4 发布 (S20–S23)🟡 S20 ✅, S21 ✅ (v0.1.0 public), S22 GitHub ✅ / HN·Reddit·V2EX pending, S23 ⬜
M5 复盘 (S24)⬜ needs real users
M5 复盘 (S24)⬜

Known gaps: no per-user auth, no audit retention, the Docker image has not been built in CI (no daemon in the dev environment), brute-force vector scan, Chinese-first defaults (English works, but the tokenizer is tuned for CJK).

Docs

DocWhat it covers
docs/s15-redaction-audit.mdrules, modes, audit schema, demo transcript
docs/s16-docker.mdcompose stack, token policy, verification status
docs/s16-systemd.mdhardened systemd unit, env file, backup/restore
docs/s8-retrieval-report.mdthe 11 retrieval approaches and why this one won
docs/s13-context-injection.mdthe prompt contract that makes models search
docs/s14-end-to-end.mdreal harness, two sessions, cold-start numbers
docs/s21-distribution.mdrelease artifacts, channels, post-release checklist
docs/s21-submissions.mdcopy-paste entries for MCP directories and ClawHub
docs/s23-feedback-log.mdlive feedback log (currently empty, honestly)
docs/s24-review.mdthe milestone review template (not yet filled)
SECURITY.mdthreat model: what is defended, what is out of scope

Pilot

Two-week pilot: we install memalyze in your environment, tune the redaction rules to your data, review the audit export with you, and write down the threat-model gaps we find. No fee; you keep the deployment and the notes.

Request a pilot · Integration notes

Non-goals

  • Not a SaaS: you self-host, we do not hold your data.
  • Not an agent framework: it never takes over the harness.
  • Not a knowledge graph: no entity extraction pipeline, no graph database.
  • Not feature-maximal: four tools, one binary, and a hard "no" to anything that needs an operator.

License

AGPL-3.0-or-later (LICENSE). Commercial licensing for embedding in closed products: open an issue titled commercial license.

Contributions: see CONTRIBUTING.md. Security reports: see SECURITY.md.

來源:README.md,提交 cd42806

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:該軟體包類型無法在沙箱中執行。

版本歷史

1
  1. v0.1.0最新Oct 25, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分