Skip to content

terry1purcell/mem9

Β 
Β 

Repository files navigation

mem9

Persistent Memory for AI Agents.
Your agents forget everything between sessions. mem9 fixes that with persistent memory across sessions and machines, shared memory for multi-agent workflows, and hybrid recall with a visual dashboard.

For OpenClaw and ClawHub installs, start here: mem9.ai/openclaw-memory

Powered by TiDB Cloud Starter Go Report Card License Stars


πŸš€ Quick Start

Server-based memory via mem9-server.

  1. Deploy mnemo-server.

    cd server && MNEMO_DSN="user:pass@tcp(host:4000)/mnemos?parseTime=true" go run ./cmd/mnemo-server
  2. Install the plugin for your agent (pick one).

    Platform Install
    Claude Code /plugin marketplace add mem9-ai/mem9 then /plugin install mem9@mem9
    OpenCode Add "plugin": ["@mem9/opencode"] to opencode.json
    OpenClaw Add mnemo to openclaw.json plugins (see openclaw-plugin/README)
  3. Provision a tenant and set credentials.

    curl -s -X POST localhost:8080/v1alpha1/mem9s
    # β†’ {"id":"..."}
    
    export MEM9_API_URL="http://localhost:8080"
    export MEM9_API_KEY="..."

    All agents pointing at the same tenant ID share one memory pool.


The Problem

AI coding agents β€” Claude Code, OpenCode, OpenClaw, and others β€” often maintain separate local memory files. As a result:

  • 🧠 Amnesia β€” Agents forget everything when a session ends
  • 🏝️ Silos β€” One agent can't access what another learned yesterday
  • πŸ“ Local files β€” Memory is tied to a single machine, lost when you switch devices
  • 🚫 No team sharing β€” Your teammate's agent can't benefit from your agent's discoveries

mnemos gives every agent a shared, cloud-persistent memory with hybrid vector + keyword search β€” powered by TiDB Cloud Starter.

Why TiDB Cloud Starter?

mnemos uses TiDB Cloud Starter (formerly TiDB Cloud Serverless) as the backing store for mnemo-server:

Feature What it means for you
Free tier 25 GiB storage, 250M Request Units/month β€” enough for most individual and small team use
TiDB Cloud Zero Instant database provisioning via API β€” no signup required for first 30 days
Native VECTOR type Hybrid search (vector + keyword) without a separate vector database
Auto-embedding (EMBED_TEXT) TiDB generates embeddings server-side β€” no OpenAI key needed for semantic search
Zero ops No servers to manage, no scaling to worry about, automatic backups
MySQL compatible Migrate to self-hosted TiDB or MySQL anytime

This architecture keeps agent plugins stateless β€” all state lives in mnemo-server, backed by TiDB.

Supported Agents

mnemos provides native plugins for major AI coding agent platforms:

Platform Plugin How It Works Install Guide
Claude Code Hooks + Skills Auto-loads memories on session start, auto-saves on stop claude-plugin/README.md
OpenCode Plugin SDK system.transform injects memories, session.idle auto-captures opencode-plugin/README.md
OpenClaw Memory Plugin Replaces built-in memory slot (kind: "memory"), framework manages lifecycle openclaw-plugin/README.md
Any HTTP client REST API curl to mnemo-server API Reference

All plugins expose the same 5 tools: memory_store, memory_search, memory_get, memory_update, memory_delete.

Note

πŸ€– For AI Agents: Use the Quick Start above to deploy mnemo-server and provision an API key, then follow the platform-specific README for configuration details.

Stateless Agents, Cloud Memory

A key design principle: agent plugins carry zero state. All memory lives in mnemo-server, backed by TiDB/MySQL. This means:

  • Agent plugins stay stateless β€” deploy any number of agent instances freely; they all share the same memory pool via mnemo-server
  • Switch machines freely β€” your agent's memory follows you, not your laptop
  • Multi-agent collaboration β€” Claude Code, OpenCode, OpenClaw, and any HTTP client share memories when pointed at the same server
  • Centralized control β€” rate limits and audit live in one place

Related Repositories

The broader mem9 product surface is split across a few repositories and workstreams:

Repo / Name Where What it owns
mem9 current repo Core Go memory API, agent plugins, CLI, website, docs site, dashboard frontend, benchmark harnesses
mem9-node sibling repo, commonly ../mem9-node Node/Nest backend for dashboard analysis workflows, async jobs, and workers
mem9-benchmark benchmark-focused repo / workstream name you may hear internally Benchmark-heavy evaluation work; the benchmark harnesses that currently ship with mem9 live under benchmark/ in this repo
mem9-tester private repo, often checked out as ../mem9-tester Automated OpenClaw install / verification harness for SKILL.md flows, smoke tests, and artifact capture

Notes:

  • dashboard/app/ in this repo is the frontend half of the dashboard product. The backend half for async analysis lives in mem9-node, especially its apps/api and apps/worker.
  • mem9-tester is not part of the production runtime. It exists to validate installation / reconnect behavior and reduce fragile manual testing.
  • If someone says mem9-benchmark, they usually mean the benchmark work around mem9 evaluation. In this repo, that work currently starts in benchmark/.

API Reference

Agent identity: X-Mnemo-Agent-Id header.

Method Path Description
POST /v1alpha1/mem9s Provision tenant (no auth). Returns { "id" }.
POST /v1alpha1/mem9s/{tenantID}/memories Legacy unified write endpoint. Tenant key travels in the URL path.
GET /v1alpha1/mem9s/{tenantID}/memories Legacy search endpoint for tenantID-configured clients.
GET /v1alpha1/mem9s/{tenantID}/memories/:id Legacy get-by-id endpoint.
PUT /v1alpha1/mem9s/{tenantID}/memories/:id Legacy update endpoint. Optional If-Match for version check.
DELETE /v1alpha1/mem9s/{tenantID}/memories/:id Legacy delete endpoint.
POST /v1alpha2/mem9s/memories Preferred unified write endpoint. Requires X-API-Key header.
GET /v1alpha2/mem9s/memories Preferred search endpoint. Requires X-API-Key header.
GET /v1alpha2/mem9s/memories/:id Preferred get-by-id endpoint. Requires X-API-Key header.
PUT /v1alpha2/mem9s/memories/:id Preferred update endpoint. Requires X-API-Key header.
DELETE /v1alpha2/mem9s/memories/:id Preferred delete endpoint. Requires X-API-Key header.

Self-Hosting

Environment Variables

Variable Required Default Description
MNEMO_DSN Yes β€” Database connection string
MNEMO_PORT No 8080 HTTP listen port
MNEMO_RATE_LIMIT No 100 Requests/sec per IP
MNEMO_RATE_BURST No 200 Burst size
MNEMO_EMBED_API_KEY No β€” Embedding provider API key
MNEMO_EMBED_BASE_URL No OpenAI Custom embedding endpoint
MNEMO_EMBED_MODEL No text-embedding-3-small Model name
MNEMO_EMBED_DIMS No 1536 Vector dimensions
MNEMO_ENCRYPT_TYPE No plain Encryption type for tenant DB passwords: plain, md5, or kms. ⚠️ One-time deployment decision β€” cannot be changed without re-provisioning all tenants.
MNEMO_ENCRYPT_KEY No β€” Encryption key (for md5) or KMS key ID (for kms). Required when MNEMO_ENCRYPT_TYPE is not plain.
MNEMO_DEBUG_LLM No false Log raw LLM responses for debugging parse errors. ⚠️ Dev/test only β€” responses may contain user data.

Build & Run

make build
cd server
MNEMO_DSN="user:pass@tcp(host:4000)/mnemos?parseTime=true" ./bin/mnemo-server

Docker

docker build -t mnemo-server ./server
docker run -e MNEMO_DSN="..." -p 8080:8080 mnemo-server

Repository Map

Path Role
server/ Core Go REST API and source of truth for spaces, memories, search, ingest, and tenant provisioning
cli/ Standalone Go CLI for exercising the mem9 API and import / ingest flows
openclaw-plugin/ OpenClaw memory plugin
opencode-plugin/ OpenCode plugin
claude-plugin/ Claude Code hooks + skills integration
site/ Public mem9.ai site. This includes the marketing site, docs page, and published onboarding documents like site/public/SKILL.md and site/public/beta/SKILL.md
dashboard/ Dedicated home for dashboard work: product docs plus the frontend app
dashboard/app/ Your Memory frontend SPA served under /your-memory
dashboard/app/src/pages/connect.tsx Dashboard connect / onboarding page
dashboard/app/src/pages/space.tsx Main Your Memory page for browsing, filtering, importing, exporting, and analyzing memories
dashboard/app/src/pages/pixel-farm.tsx Memory Farm, the lab-style interactive memory experience exposed at /your-memory/labs/memory-farm
dashboard/app/src/pages/pixel-farm-editor.tsx Dev-only editor for Memory Farm world / mask work
dashboard/app/src/lib/pixel-farm/ Memory Farm world generation, memory-to-world transforms, rendering, tiles, and runtime logic
dashboard/app/src/components/pixel-farm/ Memory Farm UI components
dashboard/docs/ Dashboard product specs, information architecture, data contract, and implementation plans
benchmark/ Benchmark harnesses and datasets for comparing OpenClaw native memory against mem9, including MR-NIAH and LoCoMo adapters
e2e/ Live end-to-end scripts against a running mem9 server
docs/ Architecture notes, design docs, and feature / experiment specs
docs/superpowers/specs/ Feature-level specs and experiments, including Pixel / Memory Farm design work
skills/ Shared setup / onboarding skills

Roadmap

Phase What Status
Phase 1 Core server + CRUD + auth + hybrid search + upsert + plugins βœ… Done
Phase 3 LLM-assisted conflict merge, auto-tagging πŸ”œ Planned
Phase 4 Web dashboard, bulk import/export, CLI wizard πŸ“‹ Planned

Vector Clock CRDT was deferred and removed from the roadmap.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

Apache-2.0


TiDB Starter
Built with TiDB Starter β€” zero-ops database with native vector search.

About

Unlimited memory for OpenClaw

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 62.1%
  • Go 20.5%
  • Python 6.8%
  • Shell 5.6%
  • Astro 3.6%
  • CSS 1.0%
  • Other 0.4%