You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: update hooks to nested format for Claude Code schema compatibility
Migrate hook installer from the deprecated flat format to the current
nested schema (matcher group -> hooks array -> handler objects). Add
legacy format detection and auto-migration so existing users upgrading
do not end up with duplicate or broken entries.
Copy file name to clipboardExpand all lines: README.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Uses the `mem0ai` package directly as a library, supports both Claude's OAT toke
15
15
16
16
Python >= 3.10 and [uv](https://docs.astral.sh/uv/getting-started/installation/).
17
17
18
-
> **Authentication:** The default setup uses Claude (Anthropic) as the LLM for fact extraction. No API key needed — the server automatically uses your Claude Code session token. For fully local setups, set `MEM0_PROVIDER=ollama`. See [Authentication](#authentication) for advanced options.
18
+
> **Authentication:** The default setup uses Claude (Anthropic) as the LLM for fact extraction. No API key needed, the server automatically uses your Claude Code session token. For fully local setups, set `MEM0_PROVIDER=ollama`. See [Authentication](#authentication) for advanced options.
19
19
20
20
## Quick Start
21
21
@@ -31,9 +31,9 @@ claude mcp add --scope user --transport stdio mem0 \
31
31
32
32
All defaults work out of the box: Qdrant on `localhost:6333`, Ollama embeddings on `localhost:11434` with `bge-m3` (1024 dims). Override any default via `--env` (see [Configuration](#configuration)).
33
33
34
-
`uvx` automatically downloads, installs, and runs the server in an isolated environment — no manual installation needed. Claude Code launches it on demand when the MCP connection starts.
34
+
`uvx` automatically downloads, installs, and runs the server in an isolated environment, no manual installation needed. Claude Code launches it on demand when the MCP connection starts.
35
35
36
-
The server auto-reads your OAT token from `~/.claude/.credentials.json` — no manual token configuration needed.
36
+
The server auto-reads your OAT token from `~/.claude/.credentials.json`, no manual token configuration needed.
37
37
38
38
### Fully Local (Ollama)
39
39
@@ -84,21 +84,21 @@ Add these rules to your project's `CLAUDE.md` (or `~/.claude/CLAUDE.md` for glob
84
84
```markdown
85
85
# MCP Servers
86
86
87
-
-**mem0**: Persistent memory across sessions. At the start of each session, `search_memories` for relevant context before asking the user to re-explain anything. Use `add_memory` whenever you discover project architecture, coding conventions, debugging insights, key decisions, or user preferences. Use `update_memory` when prior context changes. Save information like: "This project uses PostgreSQL with Prisma", "Tests run with pytest -v", "Auth uses JWT validated in middleware". When in doubt, save it — future sessions benefit from over-remembering.
87
+
-**mem0**: Persistent memory across sessions. At the start of each session, `search_memories` for relevant context before asking the user to re-explain anything. Use `add_memory` whenever you discover project architecture, coding conventions, debugging insights, key decisions, or user preferences. Use `update_memory` when prior context changes. Save information like: "This project uses PostgreSQL with Prisma", "Tests run with pytest -v", "Auth uses JWT validated in middleware". When in doubt, save it, future sessions benefit from over-remembering.
88
88
```
89
89
90
-
This gives Claude Code behavioral instructions to actively search and save memories during the session. For best results, combine with [Claude Code Hooks](#claude-code-hooks) — the CLAUDE.md rules tell Claude *how to use* memory tools mid-session, while hooks handle the *automatic* injection and saving at session boundaries.
90
+
This gives Claude Code behavioral instructions to actively search and save memories during the session. For best results, combine with [Claude Code Hooks](#claude-code-hooks), the CLAUDE.md rules tell Claude *how to use* memory tools mid-session, while hooks handle the *automatic* injection and saving at session boundaries.
91
91
92
92
## Claude Code Hooks
93
93
94
-
Session hooks automate memory at session boundaries — injecting memories on startup and saving summaries on exit. This happens automatically without manual tool calls.
94
+
Session hooks automate memory at session boundaries, injecting memories on startup and saving summaries on exit. This happens automatically without manual tool calls.
95
95
96
96
| Hook | Event | What it does |
97
97
|------|-------|--------------|
98
98
|`mem0-hook-context`| SessionStart (`startup`, `compact`) | Searches mem0 for project-relevant memories and injects them as `additionalContext`|
99
99
|`mem0-hook-stop`| Stop | Reads the last ~3 user/assistant exchanges from the transcript and saves a summary to mem0 via `infer=True`|
100
100
101
-
Both hooks are non-fatal — if mem0 is unreachable or any error occurs, Claude Code continues normally.
101
+
Both hooks are non-fatal, if mem0 is unreachable or any error occurs, Claude Code continues normally.
102
102
103
103
### Install
104
104
@@ -114,7 +114,7 @@ Or install globally (all projects):
114
114
mem0-install-hooks --global
115
115
```
116
116
117
-
This adds the hook entries to `.claude/settings.json`. The installer is idempotent — running it twice won't create duplicates.
117
+
This adds the hook entries to `.claude/settings.json`. The installer is idempotent, running it twice won't create duplicates.
118
118
119
119
### How it works
120
120
@@ -136,10 +136,10 @@ Hooks and CLAUDE.md are complementary layers that work best together:
136
136
137
137
| Layer | Role | When |
138
138
|-------|------|------|
139
-
|**Hooks**| Automated data flow — injects stored memories on startup, saves session summaries on exit | Session boundaries (start/stop) |
140
-
|**CLAUDE.md**| Behavioral instructions — tells Claude to actively search and save memories during the session | Throughout the session |
139
+
|**Hooks**| Automated data flow, injects stored memories on startup, saves session summaries on exit | Session boundaries (start/stop) |
140
+
|**CLAUDE.md**| Behavioral instructions, tells Claude to actively search and save memories during the session | Throughout the session |
141
141
142
-
Hooks alone give you passive recall (memories appear at startup) and passive saving (summaries saved at exit). CLAUDE.md instructions add active mid-session behavior — Claude searches for relevant memories when encountering new topics, and saves important discoveries immediately rather than waiting for session end.
142
+
Hooks alone give you passive recall (memories appear at startup) and passive saving (summaries saved at exit). CLAUDE.md instructions add active mid-session behavior, Claude searches for relevant memories when encountering new topics, and saves important discoveries immediately rather than waiting for session end.
143
143
144
144
For the best experience, use both. Hooks ensure memories flow in and out automatically at session boundaries, while CLAUDE.md ensures Claude actively engages with memory tools during the session.
145
145
@@ -154,9 +154,9 @@ The server resolves an Anthropic token using a prioritized fallback chain:
154
154
| 3 |`ANTHROPIC_API_KEY` env var | Standard pay-per-use API key |
155
155
| 4 | Disabled | Warns and disables Anthropic LLM features |
156
156
157
-
**In Claude Code, priority 2 always wins** — the credentials file exists as long as you're logged in. This means `ANTHROPIC_API_KEY` (priority 3) is never reached. To override the OAT token in Claude Code, use `MEM0_ANTHROPIC_TOKEN` (priority 1). `ANTHROPIC_API_KEY` is only useful for non-Claude-Code deployments (Docker, CI, standalone).
157
+
**In Claude Code, priority 2 always wins**, the credentials file exists as long as you're logged in. This means `ANTHROPIC_API_KEY` (priority 3) is never reached. To override the OAT token in Claude Code, use `MEM0_ANTHROPIC_TOKEN` (priority 1). `ANTHROPIC_API_KEY` is only useful for non-Claude-Code deployments (Docker, CI, standalone).
158
158
159
-
**OAT tokens** (`sk-ant-oat...`) use your Claude subscription. The server automatically detects the token type and configures the SDK accordingly. OAT tokens are automatically refreshed before expiry: the server proactively checks the token lifetime and refreshes via the Anthropic OAuth endpoint when nearing expiry (default: 30 minutes). On authentication failures, a 3-step defensive strategy kicks in — piggybacking on Claude Code's credentials file, self-refreshing via OAuth, and wait-and-retry — so long-running sessions survive token rotation seamlessly.
159
+
**OAT tokens** (`sk-ant-oat...`) use your Claude subscription. The server automatically detects the token type and configures the SDK accordingly. OAT tokens are automatically refreshed before expiry: the server proactively checks the token lifetime and refreshes via the Anthropic OAuth endpoint when nearing expiry (default: 30 minutes). On authentication failures, a 3-step defensive strategy kicks in, piggybacking on Claude Code's credentials file, self-refreshing via OAuth, and wait-and-retry, so long-running sessions survive token rotation seamlessly.
160
160
161
161
**API keys** (`sk-ant-api...`) use standard pay-per-use billing.
0 commit comments