Skip to main content
Glama
Zifu Memory
by tanbopiao

紫府 · Zifu Memory

Verifiable, replayable, scope-aware memory service for AI agents — via MCP.

Most agent memory systems are editable notebooks: an LLM pipeline rewrites memories (add / update / delete) and the previous state is gone. Zifu Memory is an auditable chronicle: an append-only event stream with fingerprinted snapshots, replay to any point in time, contract-governed facts, and scope-based access control.

Three pillars

  1. Persistent — append-only event stream as the source of truth; nothing is silently rewritten.

  2. Replayable — rebuild the full state at any timestamp from snapshots plus the event stream; every fact carries a source pointer and fingerprint.

  3. Cross-session, cross-node — scoped memory (session / user / agent / org) with session handoff and resume packs; sync-ready for federated nodes.

Related MCP server: strata

Install

pip install zifu-memory

Wire into your MCP client

{
  "mcpServers": {
    "zifu": { "command": "zifu-mcp", "args": [] }
  }
}

Data directory: set ZIFU_HOME (defaults to ~/.zifu).

Tools (17)

Tool

What it does

zifu_write

Append a memory (passes the fail-closed gate: credentials / OTPs / phone / ID numbers are rejected) and return a source pointer

zifu_search

Keyword lookup (entity-level digest)

zifu_semantic

Semantic search (pluggable embedder; zero-dependency char-bigram core by default)

zifu_hybrid

Keyword + semantic merged search

zifu_events

Time-window event stream reader

zifu_state

Current state

zifu_replay

Rebuild state at any timestamp (verifiable)

zifu_export

Pack a cold backup

zifu_retention

Tiered retention report (7d fine / 90d hourly / older: ledger + fingerprints)

zifu_assert

Contract 1+2: register a fact with a source pointer; duplicate IDs are deterministic errors

zifu_replace

Contract 2: revise a fact, history preserved

zifu_retire

Retire a fact (mark only, never delete)

zifu_facts

List the fact ledger

zifu_inject

Contract 3: deterministic context packing under a hard budget

zifu_view

Contract 5: consistent view (state + active facts at a timestamp)

zifu_handoff

End-of-session handoff summary (session-boundary free)

zifu_resume

New-session resume pack (handoffs first, then facts, then recent events)

The five contracts

  1. Source pointer first — every registered fact must point to a resolvable event (file + timestamp + fingerprint).

  2. Duplicate IDs are errors — revising goes through replace, history kept.

  3. Hard injection budget — context assembly is deterministic and reproducible.

  4. Idempotent replay — replaying the ledger any number of times yields the same state.

  5. Consistent views — fork a consistent snapshot of state + facts at any time.

Scope model (fail-closed)

session < user < agent < org

Writers tag memories with a scope; readers declare their identity. Without an identity you only see org-level memories. Legacy data defaults to org.

Design notes

  • Zero-dependency core (standard library only); the MCP shell needs mcp>=1.0,<2.

  • The semantic layer is a pluggable slot: the default char-bigram TF-IDF core works offline; swap in a real embedding model without changing the retrieval logic.

  • Forgetting is tiered, not deleted: fine-grained snapshots for 7 days, hourly snapshots for 90 days, event ledger + fingerprints forever.

License

Apache-2.0

Available Tools

17 tools
zifu_assertA

契约1+2:带来源指针登记事实(指针来自 zifu_write 的返回)。同 ID 重复登记是确定性错误;改口走 zifu_replace。

Inputs: entity (required), fact_id (required), pointer (required), statement (required). Returns: result

zifu_eventsA

按时间窗顺序读事件流(正本)。reader 自报身份按分级读取;缺省只读 org 级。

Inputs: reader, since_ts, until_ts. Returns: result

zifu_exportB

打包冷备(供后续推魔搭私有仓)。

Inputs: no named parameters. Returns: result

zifu_factsA

列事实账本(status: active/replaced/retired,缺省全部)。

Inputs: status. Returns: result

zifu_handoffB

会话收尾:写交接摘要(会话边界无关,供后续会话接续)。scope 不能是 session 级。

Inputs: summary (required), session_id (required), scope, entity, +2 more. Returns: result

zifu_hybridB

混合检索:关键词命中 + 文义 top-k 合并去重。reader 自报身份按分级读取。

Inputs: query (required), top_k, reader. Returns: result

zifu_injectC

契约3:硬预算装配上下文(字符预算,确定性结果,可复算)。query 提供时按文义相关性排序。

Inputs: query, budget. Returns: result

zifu_replaceB

契约2:改口走 replace,旧事实标记 replaced 并留痕,历史不删。

Inputs: entity (required), old_id (required), reason (required), new_statement (required). Returns: result

zifu_replayA

从最近快照+事件流重建指定时刻状态(可核验)。at_ts 缺省为当前时刻。

Inputs: at_ts. Returns: result

zifu_resumeA

新会话开场:拉接续包——可见交接摘要优先+active 事实+近期可见事件,硬预算内确定性装配。 reader 自报身份(session_id/agent_id/user_id);无身份只给 org 级(fail-closed)。

Inputs: reader (required), budget, recent_limit. Returns: result

zifu_retentionB

分层保留报告(7天细粒度/90天整点/更久只留事件册与指纹)。

Inputs: no named parameters. Returns: result

zifu_retireB

事实退役:只标记不删除(账本只追加)。

Inputs: reason (required), fact_id (required). Returns: result

zifu_semanticB

文义检索:按意思找记忆(字符二元文义匹配,可插拔向量芯)。reader 自报身份按分级读取。

Inputs: query (required), top_k, reader. Returns: result

zifu_stateC

当前记忆状态。

Inputs: no named parameters. Returns: result

zifu_viewC

契约5:一致视图——该时刻状态重建 + 当时仍有效的事实。

Inputs: at_ts. Returns: result

zifu_writeA

写入一条经验记忆。source: internal=体系内部动作(正本完整) / external=外部观测(采样带证据)。 scope 分级: org=人人可读(缺省) / agent=仅该agent / user=仅该user名下 / session=仅该会话。 写入前过紫府闸。返回事件与来源指针(契约1:来源指针先行)。

Inputs: kind (required), entity (required), payload (required), scope, +4 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 17 tools

    Disambiguation3/5

    The retrieval trio (zifu_search / zifu_semantic / zifu_hybrid) is clearly delineated, and the fact-ledger ops (assert/replace/retire) are well separated. However zifu_write vs zifu_assert overlap (raw experience vs pointer-bearing fact), and zifu_state ("current memory state") is vague next to zifu_facts, zifu_events and zifu_view, making misselection plausible.

    Naming Consistency4/5

    All 17 tools share the zifu_ prefix and snake_case, which is highly predictable. The only deviation is grammatical: some names are verbs (write, search, assert, replace, retire, inject, replay) while others are nouns (facts, events, state, retention, handoff) or adjectives (semantic, hybrid).

    Tool Count4/5

    17 tools is on the heavy side but each maps to a concrete lifecycle stage of a memory system (ingest, three retrieval modes, ledger mutation, context assembly, session handoff/resume, maintenance). Nothing looks redundant enough to cut outright, though the three retrieval variants could arguably be collapsed into one parameterized tool.

    Completeness4/5

    Coverage is broad: ingest, retrieval, fact correction via replace/retire, budgeted context assembly (inject/resume), point-in-time reconstruction (view/replay), export and retention. The notable gap is that experience memories written by zifu_write have no update or correction path — only facts can be replaced — and there is no explicit delete/purge (deliberate append-only, but agents may hit that dead end).

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides AI agents with persistent, searchable memory that survives across conversations using semantic search, temporal versioning, and smart organization. Enables long-term context retention and cross-session continuity for AI assistants.
      14
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to read and write a durable, append-only memory with verified provenance, supporting search, record capture, and context preparation across sessions and machines.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to maintain persistent memory across sessions with verifiable source receipts, supporting explicit remember, recall, inspect, correct, and forget operations.
      58
      Apache 2.0