memlawb

memlawb

Zero-knowledge, self-hostable MCP server providing encrypted durable memory for AI agents, with tools to save, recall, search, list, and delete memories.

Category
访问服务器

README

memlawb

CI npm License: MIT OR Apache-2.0

Open-source, self-hostable, zero-knowledge agent memory. The memory layer of the agent stack — give any agent durable memory it can carry across sessions, stored on a server that cannot read it.

Part of the Gitlawb stack: opengateway (inference) · node (code) · openclaude (agent) · memlawb (memory).


Why

Agents forget everything between sessions. The existing fix — syncing memory to a vendor's cloud — means a third party can read everything your agent learns about you and your code. memlawb is the alternative:

  • Zero-knowledge. Memory is encrypted on your machine before upload. The server stores and serves only ciphertext (AES-256-GCM, key derived from your passphrase). We host it but we cannot read it.
  • Self-hostable. One binary, pluggable storage (filesystem, S3/Tigris/R2, more coming). Run it on our cloud or your own.
  • Provider-neutral. A built-in MCP server gives Claude Code, Cursor, opencode, and SDK agents memory tools (memory_save/recall/search/ list/delete); a simple sync API any agent can speak is underneath.
  • Delta sync. Deterministic encryption means only changed entries upload, even though the server never sees plaintext.
  • Secret-aware. A client-side scanner refuses to upload entries that look like they contain live credentials — before they're ever encrypted or sent.

How it works

agent / CLI / MCP
   │   plaintext in, plaintext out
   ▼  [ client/crypto.ts — encrypt with key derived from your passphrase ]
   │   ciphertext
   ▼
memlawb server  (crypto-blind — only ever sees ciphertext)
   ▼
BlobStore: fs | s3 (Tigris/R2/AWS) | ipfs/git (planned)

The server is crypto-blind: it does delta sync, dedup, and storage entirely over ciphertext. The encryption key never leaves the client.

Quick start (self-host)

bun install

# 1. run the server (filesystem storage, single-user open mode)
ALLOW_UNAUTHENTICATED=true STORE=fs DATA_DIR=./data bun run src/index.ts

# 2. sync a memory directory, end-to-end encrypted
export MEMLAWB_URL=http://localhost:8080
export MEMLAWB_PASSPHRASE='your-zero-knowledge-passphrase'   # never sent to the server

bun run bin/memlawb.ts push ./my-memories user:me   # encrypt + upload
bun run bin/memlawb.ts pull ./restored      user:me   # download + decrypt

What lands on the server is ciphertext — grep your data dir for any plaintext and you'll find nothing.

⚠️ Zero-knowledge means no recovery. If you lose your passphrase, the host cannot help you — the data is unreadable to everyone but the key holder. Back up your passphrase.

Use as a library

import { MemlawbClient } from '@gitlawb/memlawb'

const memory = new MemlawbClient({
  url: 'https://memory.gitlawb.com',
  apiKey: process.env.MEMLAWB_API_KEY,
  passphrase: process.env.MEMLAWB_PASSPHRASE, // stays local
})

await memory.push('user:me', { 'MEMORY.md': '# what I know about the user...' })
const { entries } = await memory.pull('user:me')

Use from any agent (MCP)

memlawb ships an MCP server in the same package, so any MCP-capable agent gets durable encrypted memory by adding one config block. Add to your client's MCP config (Claude Code shown):

{
  "mcpServers": {
    "memlawb": {
      "command": "bunx",
      "args": ["-y", "@gitlawb/memlawb", "mcp"],
      "env": {
        "MEMLAWB_URL": "https://memory.gitlawb.com",
        "MEMLAWB_API_KEY": "mk_live_...",
        "MEMLAWB_PASSPHRASE": "your-zero-knowledge-passphrase",
        "MEMLAWB_NAMESPACE": "user:me"
      }
    }
  }
}

The MCP server runs locally, holds the passphrase, and encrypts/decrypts in-process — so the remote server still only ever sees ciphertext. Tools:

Tool Purpose
memory_save(key, content) persist a durable fact
memory_recall(query) rank stored memories by relevance (local)
memory_search(query) literal keyword/substring search
memory_list() list entry keys
memory_delete(key) remove an entry

For self-host, omit MEMLAWB_API_KEY and point MEMLAWB_URL at your server.

Teaching the agent to use memory

Tools alone don't make an agent use memory well — it needs the discipline (recall before answering, save only durable facts, don't duplicate). That lives in one place, skills/memlawb-memory/SKILL.md:

  • Claude Code: install it as a skill (drop the folder in your skills dir) and the agent reads it when memory is relevant.
  • Any MCP client: the server exposes the same text as the memory_guide prompt and a short version in its startup instructions, so Cursor / opencode / SDK agents get the protocol without a separate file.

API

All bodies are ciphertext; the server validates sizes/hashes without decrypting.

Method Route Purpose
GET /health liveness + active store
GET /api/memory/:ns full data (ciphertext entries + checksums)
GET /api/memory/:ns?view=hashes per-key checksums only (for delta)
PUT /api/memory/:ns delta upsert { entries, deletions? }
DELETE /api/memory/:ns?key=<entryKey> remove one entry

A namespace (user:me, repo:owner/name, agent:intern) is the unit of scoping. Entry keys mirror the memdir layout (MEMORY.md, feedback/x.md).

Configuration

See .env.example. Key knobs: STORE (fs|s3), ALLOW_UNAUTHENTICATED, STATIC_API_KEYS / Supabase auth, and per-namespace size/count limits.

Security model

  • Encryption: AES-256-GCM; key = scrypt(passphrase, salt=sha256("memlawb:"+namespace)).
  • Integrity: the entry key is GCM additional-authenticated-data, so a blob is bound to its key and can't be swapped or replayed.
  • Determinism: synthetic-IV nonce enables delta sync; the only leak is whether two entries are byte-identical.
  • Defense in depth: a client-side secret scanner runs before encryption and (by default) blocks uploads containing live-looking credentials. Override with MEMLAWB_SCAN=warn|off.
  • Tenancy: each API key maps to an owner who controls exactly their own user:<owner> namespace subtree (strict segment match, no substring escapes); per-account quotas and per-owner rate limits are enforced server-side.
  • Upgrade path: a version byte on every blob allows migrating to XChaCha20-Poly1305 + Argon2id without breaking existing data.

See PLAN.md for the full roadmap (MCP server, openclaude drop-in, git-backed signed history, sharing/forking, billing).

Status

Beta. The crypto-blind server, client crypto, CLI, MCP server, secret scanner, per-account quotas, and rate limiting are implemented and tested (bun test — 50 tests). Hosted free beta at memory.gitlawb.com. Next: self-service console for API keys, the openclaude native drop-in, and the Postgres index for horizontal scale (the hosted beta runs a single machine deliberately — see PLAN.md §7).

Development

bun install
bun test            # run the suite
bun run type-check  # tsc --noEmit
bun run check       # biome lint + format check

For contributors, the codebase splits cleanly along the trust boundary:

client/   the zero-knowledge client — encrypts here; holds the key
src/      the crypto-blind server — only ever sees ciphertext
src/mcp/  the MCP server (memory tools) over the client
bin/      the CLI (push | pull | mcp | serve)

The cardinal rule: plaintext, passphrases, and derived keys never reach the server. See CONTRIBUTING.md for the full guide.

Contributing

Issues and PRs welcome. Please read CONTRIBUTING.md (dev setup, design principles, Conventional Commits, DCO sign-off) and our Code of Conduct.

Security

memlawb is security software. Please report vulnerabilities privately — do not open a public issue. See SECURITY.md for the process and the threat model.

License

Dual-licensed under MIT or Apache-2.0, at your option. Contributions are accepted under the same dual license (see the SPDX headers and CONTRIBUTING.md).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选