Skip to main content
Glama

ZaiMem

CI Docker image License: MIT Next.js 16 TypeScript MCP PRs Welcome

โ–ถ LIVE DEMO Built with GLM 5.3 Flash Lead by Roman ยท Rommark.Dev Telegram Blog The Claw Blog Author of Z-Assist Project

๐ŸŒ Launch the live demo โ†’ โ€” no signup: open the app and a private zm_โ€ฆ token is generated for you instantly. Paste the magic prompt into any chat.z.ai agent chat and watch the memory, context boost and token savings appear in your dashboard.

Session memory & context enhancer for AI agents like chat.z.ai โ€” an MCP-powered web service that gives any chat.z.ai agent persistent vector memory, automatic context enhancement, token saving, and smart-skill orchestration โ€” with every user's data mirrored to their own private GitHub repo as a human-readable cloud database.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   1. visit    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  2. auto private token
โ”‚  ZaiMem web  โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  token issued &   โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     app      โ”‚               โ”‚  stored locally   โ”‚                         โ–ผ
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                                              โ”‚ 3. login โ†’ get MAGIC PROMPT โ”‚
                                                              โ”‚ (endpoint + key embedded)   โ”‚
                                                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 4. paste prompt into a new chat.z.ai AGENT-mode chat                                    โ”‚
โ”‚    โ†’ session auto-synced: vector memory, context enhancement, token saving, skills      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                                             โ”‚
                                     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                     โ–ผ
              5. pair GitHub PAT โ†’ private repo auto-created
                 โ†’ ALL data auto-synced (repo = user's cloud DB)

Features

  • Automated private tokens โ€” no signup: visit the app, get a zm_โ€ฆ token instantly, log in with it.

  • Magic prompt (universal) โ€” the dashboard generates a ready-to-paste activation prompt with your MCP endpoint and key embedded. Works in any MCP-capable agent: chat.z.ai, Claude Code, Cursor, Cline, Windsurf, Trae, Antigravity, zcode, Koda, Pi, Grok and more.

  • MCP server (JSON-RPC 2.0, streamable HTTP) โ€” 33 tools in 8 togglable tool packs, 4 resources, prompt templates, batch calls, session ids, CORS.

  • Document ingestion โ€” zaimem_ingest_file MCP tool + dashboard drag-and-drop upload (PDF / DOCX / TXT / MD / CSV / code): text is auto-chunked into ~600-token overlapping pieces, every chunk is embedded as a document memory tagged with its source filename, and re-ingestion is idempotent (same content hash โ†’ no-op; changed file โ†’ chunks replaced). Recall hits cite [doc:file.pdf ยท part i/N].

  • Pinned memories โ€” zaimem_remember {pinned: true} (or one click in the dashboard) marks a memory as always-in-force: it is injected into every zaimem_enhance_context block and gets a recall ranking boost.

  • Right to be forgotten โ€” zaimem_forget MCP tool with a two-phase preview โ†’ confirm flow: match by id, semantic query, kind, source filename (purge a whole document) or created-before date; dashboard rows also support inline edit (re-embeds instantly) and pin toggle.

  • Pre-created sessions & handoffs โ€” create a session before the work starts (title + brief + optional project), then copy its generated bootstrap prompt into a fresh agent chat in any IDE: the agent syncs onto that exact session with the brief, summary, key memories and open tasks baked in. Every existing session (even auto-created ones) has a Continue elsewhere prompt.

  • Projects โ€” agent teams โ€” a project is a shared workspace: team instructions, attached files/prompts and a shared memory namespace. Connect one or many agents (via the dashboard or zaimem_project_brief {project, agent, role}); agents see the roster, the brief, the files and everything teammates shared โ€” and leave structured zaimem_project_handoff notes (done / in_progress / blocked) so the next agent picks up cleanly. Like a team of devs with one shared brain.

  • Meeting intelligence (Tactiq-style, self-hosted) โ€” paste a Google Meet / Zoom / Teams transcript: ZaiMem chunks + embeds the full transcript, writes an LLM summary with every decision, extracts action items and pushes them onto the global tasks board. Ask across all meetings with zaimem_meeting_search ("what did we decide about X?").

  • Universal tools โ€” the zero-config staples from the MCP ecosystem, wired into memory: zaimem_web_search + zaimem_web_fetch (JS-rendered pages, optional auto-ingest as searchable memory), zaimem_calc (safe arithmetic, no code execution), zaimem_time (IANA timezones), zaimem_think (ledger-backed sequential-thinking scratchpad that survives compaction).

  • HEADROOM compression mode โ€” togglable (dashboard switch or zaimem_headroom {enabled}), inspired by headroomlabs-ai/headroom: when ON, every context injection is compressed harder (shorter excerpts, skill protocols withheld) to preserve context-window headroom, while originals stay full-fidelity in the store and remain retrievable via zaimem_doc_read / zaimem_recall. Lifetime tokens freed are counted per account.

  • Local vector memory โ€” 384-dim hashed word/bigram/char-4gram embeddings with cosine recall; auto-dedupe (0.94 duplicate / 0.80 merge thresholds), recency + keyword boosts, context-block assembly.

  • Token saver โ€” LLM-powered digests (with extractive fallback) compress long context; token accounting per action.

  • Smart skills (zcode-smart-skill integration) โ€” 8 builtin SKILL.md skills (smart, context-boost, token-frugal, meeting-notes, web-research, session-continuity, project-team, doc-memory), auto trigger detection, difficulty budgets (E5: 2/6/12), ledger pages (notes.md, tasks.json) with size budgets, handoff brief with TRUST clause, reflection schema. Every skill and every tool pack has an on/off switch in the Skills tab.

  • GitHub Cloud DB (free hosting) โ€” pair a GitHub PAT (pre-filled token link, 2 minutes, free โ€” private repos cost nothing) and a private repo is auto-created in YOUR account; every session, memory, project & file is auto-synced in real time (sha-based idempotent pushes, 4s debounced, full audit trail). Your memory stops consuming ZaiMem's local storage entirely โ€” the dashboard keeps the recommendation visible until you pair.

  • Scheduled daily backup โ€” an optional heartbeat push of a full snapshot ~every 24h (configurable via ZAIMEM_BACKUP_HOURS), even when nothing changed โ€” proof the backup pipeline is alive. Toggle it in the Cloud DB panel.

  • One-PAT account rescue โ€” fresh token / new account, but your old ZaiMem already synced to a private GitHub repo? Point the Cloud DB tab's rescue card at that repo (owner/name + PAT): memories are re-imported through the dedupe engine (safe to run twice), sessions come back with titles and summaries, and skills you don't have yet are added. Pairing not required, nothing deleted.

  • Global search (โŒ˜K) โ€” one query across all sessions, memories (vector + substring), ledger pages and skills, with jump-to-result navigation. Filter results by kind (sessions / memories / ledger / skills) and by date range (24 h โ†’ 1 year) right from the command bar.

Related MCP server: Nouva MCP Server

Quick start

โšก Fastest path: open the hosted instance โ€” nothing to install. The steps below are for running your own copy.

Clone & run locally

# 1. clone the repo
git clone https://github.com/romangalaxys10-spec/zaimem.git
cd zaimem

# 2. install dependencies (bun โ‰ฅ 1.2 recommended; npm/pnpm work too)
bun install

# 3. configure env
cp .env.example .env        # SQLite by default

# 4. create the database schema
bun run db:push

# 5. run
bun run dev                 # http://localhost:3000

Production build: bun run build โ†’ bun run start (standalone output on localhost:3000).

Deploy with Docker (public demo / self-host)

Every push to main publishes a fresh image to GHCR via Actions (docker.yml):

# pull the prebuilt image and run โ€” http://localhost:3000
docker pull ghcr.io/romangalaxys10-spec/zaimem:latest
docker run -d -p 3000:3000 -v zaimem-db:/app/db ghcr.io/romangalaxys10-spec/zaimem:latest

# or build & run from source in one command
docker compose up --build -d

# or without compose
docker build -t zaimem .
docker run -d -p 3000:3000 -v zaimem-db:/app/db zaimem

Image tags: latest (default branch), vX.Y.Z / vX.Y (git tags), short sha-*, and the branch name. Browse all tags on the package page.

The SQLite database lives in the zaimem-db volume (mounted at /app/db) and survives rebuilds. Healthcheck, restart policy and env knobs are pre-configured in docker-compose.yml.

Env var

Default

Purpose

DATABASE_URL

file:/app/db/custom.db

SQLite location (inside the volume)

ZAIMEM_BACKUP_HOURS

24

Scheduled cloud-DB backup interval (hours, 0.02โ€“168)

ZAIMEM_SCHEDULER

on

Set off to disable the background backup loop

Expose port 3000 through your reverse proxy / tunnel (Caddy, nginx, Cloudflare Tunnel) for a public demo โ€” all agent traffic goes through the single MCP endpoint /api/mcp.

First run

Then open the app โ†’ Get my private token โ†’ log in โ†’ copy the Magic Prompt โ†’ paste into a new chat.z.ai agent-mode chat.

MCP endpoint

POST /api/mcp
Authorization: Bearer <api-key>        # or ?token=<api-key>
Content-Type: application/json

The endpoint implements the Model Context Protocol over streamable HTTP (initialize, tools/list, tools/call, resources/*, prompts/*, batch arrays, MCP-Session-Id).

Tools

Tool

Purpose

zaimem_sync_session

Register/sync the current agent session

zaimem_remember

Store a memory (auto-dedupe + merge, optional pinned)

zaimem_forget

Right-to-be-forgotten: preview โ†’ confirm deletion by id/query/kind/source/date

zaimem_ingest_file

Ingest a whole document: chunk + embed + hash-dedupe, source citations

zaimem_recall

Vector + keyword recall with recency/importance boosts

zaimem_enhance_context

Build an injectable context block for the current message

zaimem_save_tokens

Digest/compress long content and bank the savings

zaimem_detect_skill

Detect a matching skill for the user's request

zaimem_list_skills

List registered skills (SKILL.md convention)

zaimem_get_skill

Fetch one skill's full SKILL.md protocol body

zaimem_ledger_write

Write a smart-skill ledger page (notes.md, tasks.json, โ€ฆ)

zaimem_ledger_read

Read a ledger page

zaimem_session_summary

Distill an end-of-session summary

zaimem_handoff_brief

Cross-session handoff brief (TRUST clause)

zaimem_remember_many

Batch-store up to 25 memories in one round-trip

zaimem_doc_read

Progressive document loading: outline or one chunk

zaimem_session_status

History pressure + activity report for a session

zaimem_brief_me

"What's new since you left" cross-session digest

zaimem_resume

Resume a session: summary + open tasks + checkpoint diff

zaimem_task_next

Global task board: pick the next open task

zaimem_session_create

Pre-create a custom session + get its bootstrap prompt

zaimem_session_prompt

Bootstrap prompt to continue any session elsewhere

zaimem_project_brief

Join a project team + get the full brief (roster, files, shared memory)

zaimem_project_handoff

Structured end-of-shift handoff to teammates

zaimem_ingest_meeting

Meeting transcript โ†’ chunks + summary + action items

zaimem_meetings_list

List ingested meetings with summaries

zaimem_meeting_search

"Ask my meetings" โ€” semantic search across transcripts

zaimem_web_search

Web search (zero API keys)

zaimem_web_fetch

Read a web page as text (+ optional auto-ingest)

zaimem_calc

Safe arithmetic calculator (shunting-yard, no code execution)

zaimem_time

Current time / timezone info

zaimem_think

Sequential-thinking scratchpad (ledger-backed chain)

zaimem_headroom

HEADROOM compression mode: status + toggle

Resources & prompts

  • zaimem://protocol โ€” operating protocol (markdown)

  • zaimem://memory โ€” recent memories (json)

  • zaimem://skills โ€” skill registry (json)

  • Prompt template zaimem-boot โ€” boot a ZaiMem-synced session with memory recall

Dashboard REST API

Route

Description

POST /api/auth/init

Issue an automated private token

POST /api/auth/login

Log in with the token (cookie session)

GET /api/auth/me

Current user + stats + config

GET/POST /api/sessions, GET/DELETE /api/sessions/[id]

Session management

GET /api/memories, POST /api/memories, DELETE /api/memories/[id]

Memory browsing & vector search

GET/PATCH /api/skills

Skills + MCP tool packs + headroom mode: GET returns all three, PATCH toggles ({id} skill ยท {packId} pack ยท {headroom} mode)

GET /api/stats

Usage statistics (tokens saved, actions)

GET/POST /api/github

Cloud DB status, pair / unpair / sync / toggle / restore / import (new-account rescue)

GitHub Cloud DB

Pair your PAT (classic, repo scope) from the dashboard's Cloud DB tab:

  1. PAT is validated against GET /user and stored AES-256-GCM encrypted (only last 4 chars are ever displayed).

  2. A private repo (default zaimem-cloud-db) is auto-created in your account.

  3. Every mutation (memories, sessions, ledger, skills, stats) triggers a debounced auto-sync.

  4. Pushes are idempotent โ€” unchanged files are skipped via git blob SHA comparison; your own files in the repo are never touched.

  5. New account? POST /api/github {action: "import", pat, repo, branch?} โ€” or the Cloud DB tab's rescue card โ€” re-syncs an existing cloud-DB repo into the current account (memories + sessions + skills, additive & dedupe-aware).

Repo layout:

index.json            # snapshot index + counts
README.md             # human-readable overview (regenerated)
memories.json         # all memories
vectors.jsonl         # 384-dim embeddings, one JSON per line
sessions/<slug>.json  # one file per session (turns, summary, metadata)
skills.json           # skill registry
stats.json            # usage statistics
sync/log.json         # sync audit trail

Tool packs โ€” capability switches

All 33 MCP tools belong to one of 8 packs. Flip a pack off in Skills โ†’ MCP tool packs and its tools vanish from tools/list; a direct call answers with a clear "pack is switched OFF" hint instead of executing. core-memory is locked โ€” it is the product:

Pack

Tools

Core memory (locked)

sync_session ยท remember ยท remember_many ยท recall ยท forget ยท enhance_context

Session continuity

session_status ยท brief_me ยท resume ยท task_next ยท session_summary ยท handoff_brief ยท session_create ยท session_prompt

Project agent teams

project_brief ยท project_handoff

Meeting intelligence

ingest_meeting ยท meetings_list ยท meeting_search

Document ingestion

ingest_file ยท doc_read

Web & utilities

web_search ยท web_fetch ยท calc ยท time ยท think

Smart skills & ledger

detect_skill ยท list_skills ยท get_skill ยท ledger_write ยท ledger_read

Token saver & headroom

save_tokens ยท headroom

Deployment

Vercel (auto-sync): every push to main deploys automatically via the Vercel deploy GitHub Actions workflow (prebuilt deploy with VERCEL_TOKEN / VERCEL_ORG_ID / VERCEL_PROJECT_ID repo secrets). Project: zaimem.vercel.app.

Database on Vercel: Vercel lambdas each own an ephemeral /tmp, so the default DATABASE_URL=file:/tmp/zaimem.db gives every instance a separate blank database (boot warning + schema bootstrap are built in: vercel-build.sh ships db/vercel-bootstrap.db and db.ts copies it into place on cold start). For real persistence and cross-instance consistency, set DATABASE_URL to any managed Postgres (Vercel Postgres / Neon / Supabase) โ€” the build detects a postgres:// URL and automatically generates + syncs prisma/schema.postgres.prisma. Zero raw SQL is used anywhere, so the provider switch is loss-free. scripts/vercel-smoke.sh sweeps production: HEALTH checks must always pass; state flows are db-dep until Postgres is connected.

Self-hosted / Docker: the long-running mode stays the reference deployment โ€” docker-compose.yml (or bun run build && bun start) keeps SQLite on a real disk, runs the GitHub backup scheduler in-process, and shares one rate-limit/session registry. GHCR semver images are built by CI on every release tag.

Architecture

src/
โ”œโ”€โ”€ app/api/โ€ฆ            # 12 route handlers (auth, sessions, memories, skills, stats, github, mcp)
โ”œโ”€โ”€ components/zaimem/โ€ฆ  # landing, dashboard, cloud-db, panels, magic-prompt builder
โ””โ”€โ”€ lib/zaimem/
    โ”œโ”€โ”€ vector.ts        # hashed n-gram embeddings + cosine engine
    โ”œโ”€โ”€ memory.ts        # remember/recall/enhance with dedupe & boosts
    โ”œโ”€โ”€ compress.ts      # token saver (LLM digest + extractive fallback)
    โ”œโ”€โ”€ skills.ts        # smart-skill engine (triggers, budgets, ledger, handoff)
    โ”œโ”€โ”€ mcp.ts           # MCP tool/resource/prompt registry & dispatcher
    โ”œโ”€โ”€ github.ts        # PAT validation, repo provisioning, idempotent sync, debounce queue
    โ”œโ”€โ”€ crypto.ts        # AES-256-GCM at-rest encryption, blob sha
    โ”œโ”€โ”€ auth.ts          # token issuance & session auth
    โ””โ”€โ”€ seed.ts          # builtin skills bootstrap

Stack: Next.js 16 (App Router) ยท React 19 ยท TypeScript ยท Tailwind CSS 4 ยท shadcn/ui ยท Prisma + SQLite ยท z-ai-web-dev-sdk.

Testing

npx tsx scripts/e2e-test.ts      # 156 checks โ€” auth, MCP tools & packs, sessions, projects, meetings, export, dedupe, GitHub guards โ€ฆ
npx tsx scripts/e2e-github-unit.ts   # 26 engine checks โ€” full sync engine vs mock GitHub API

The 9 live rescue-import checks skip hermetically unless ZAIMEM_E2E_PAT / ZAIMEM_E2E_REPO are set โ€” no credentials are ever hard-coded.

Security notes

  • Login tokens are stored as SHA-256 hashes โ€” plaintext tokens are never persisted (v1.7.2 migration + backfill).

  • GitHub PATs are encrypted at rest (AES-256-GCM, scrypt-derived key from ZAIMEM_SECRET) and never returned by the API; legacy rows are transparently re-encrypted on load.

  • Rate limiting: auth init 60 req / 5 min per IP; MCP endpoint 1200 req / min per token.

  • JSON-RPC hardening: batches capped at 25 requests; MCP sessions evicted after 24 h idle (10 k cap); verbose error scrubbing.

  • Security headers (v1.8): Content-Security-Policy (self-locked), HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy and COOP on every response. Frame directives are deliberately omitted (v1.8.1) so the dashboard embeds in chat sidebars, IDE panels and preview gateways โ€” safe because ZaiMem holds no cookies; auth is PAT via explicit Authorization headers that browsers never attach cross-site.

  • Strict type-checked builds (v1.8): next build fails on TypeScript errors โ€” enforced in CI.

  • Data portability (v1.8): GET /api/export downloads the full account (memories, sessions, ledger, skills, tool packs, project teams) as one JSON archive โ€” no vectors, no credentials.

  • The SQLite database and .env are local-only and excluded from version control. A full security audit (v1.7.2) is reproduced by scripts/sec-report-*.py.

โšก Built with

GLM 5.3 Flash โ€” z.ai

๐Ÿ‘‘ Lead by

Roman ยท Rommark.Dev

โœˆ๏ธ Telegram Blog

@VibeCodePrompterSystem

๐ŸŸข The Claw Blog

claw.rommark.dev

๐Ÿ›Ÿ Author of

Z-Assist Project

License

MIT ยฉ RyzenCode

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables any MCP client (zcode, Claude Code, Cursor) to give its model bi-temporal long-term memory, auditable evidence-cited retrieval, LLM-assisted document extraction, and deterministic A* skill planning with precondition/effect verification. All four capabilities share one portable SQLite store and can be mounted independently on demand.
    2
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI agents to capture, classify, promote, synthesize, and retrieve persistent knowledge from sources like Obsidian vaults, code, transcripts, and session logs, serving it through MCP tools and a REST API. Provides tiered, token-optimized memory so multiple agents share one compounding brain instead of starting from zero each session.
    14 npm
    MIT