End-to-end example: Claude API + memdb-claude-memory-tool adapter.
Demonstrates that memory persists across separate conversations: in turn 1 we
tell Claude something; in turn 2 (a brand-new tool_runner invocation with no
shared message history) Claude recalls it via the MemDB-backed memory tool.
- Connectivity check against
MEMDB_URL/health. - Creates a
MemDBMemoryToolinstance scoped to onecube_id/user_id. - Session 1 — sends "Remember that I prefer TypeScript over Python." Claude
issues
memory_savetool calls; the adapter forwards them to MemDB. - Session 2 — fresh
tool_runnercall (no in-memory chat history): asks "What language do I prefer?". Claude issuesmemory_recall; MemDB returns the stored preference; Claude answers from it.
- Python 3.10+
- MemDB running locally (
http://localhost:8080):cd ~/deploy/server-config && docker compose up -d
- An Anthropic API key.
cp .env.example .env
# edit .env — set ANTHROPIC_API_KEY at minimum
export $(grep -v '^#' .env | xargs)pip install -r requirements.txt
python3 chat_with_memory.pyMemDB reachable at http://localhost:8080
Session 1 (store preference):
Claude: I've stored your preference for TypeScript over Python.
Session 2 (fresh thread, recall):
Claude: You prefer TypeScript over Python.
The second answer comes from MemDB — there is no shared context between the
two tool_runner calls.
| Variable | Default | Purpose |
|---|---|---|
ANTHROPIC_API_KEY |
required | Anthropic API key for Claude |
MEMDB_URL |
http://localhost:8080 |
MemDB REST API base URL |
CUBE_ID |
python-chat-demo |
Memory cube identifier |
USER_ID |
python-chat-demo |
User identifier inside the cube |
MEMDB_SERVICE_SECRET |
empty | X-Internal-Service header value (only needed if MemDB has AUTH_ENABLED=true) |