memoryai-mcp 2.4.2 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +362 -362
- package/dist/claude-setup.js +21 -21
- package/dist/index.js +14 -6
- package/dist/kiro-setup.d.ts +13 -7
- package/dist/kiro-setup.js +84 -76
- package/package.json +46 -46
package/README.md
CHANGED
|
@@ -1,362 +1,362 @@
|
|
|
1
|
-
# memoryai-mcp
|
|
2
|
-
|
|
3
|
-
MCP server for [MemoryAI](https://memoryai.dev) — a living brain for your AI agent.
|
|
4
|
-
|
|
5
|
-
Your AI agent gets persistent memory that works like a real brain:
|
|
6
|
-
- Remembers what matters, forgets what doesn't
|
|
7
|
-
- Strengthens memories you use often (Hebbian learning)
|
|
8
|
-
- Consolidates knowledge while idle (Sleep cycles)
|
|
9
|
-
- Protects core identity (DNA memories never fade)
|
|
10
|
-
- Adapts to your emotional state
|
|
11
|
-
|
|
12
|
-
**Install once. Everything auto from there.**
|
|
13
|
-
|
|
14
|
-
Automation level by platform:
|
|
15
|
-
- **Mechanism-level (hands-off, guaranteed):** OpenAI Proxy, Kiro (Agent Hooks), Claude Code (HTTP hooks via `memoryai-claude-setup`).
|
|
16
|
-
- **Soft (rules-file, depends on the model following instructions):** Cursor, Windsurf, VS Code Copilot. MCP tools are available; add the rules file shown below.
|
|
17
|
-
|
|
18
|
-
## Quick Start (2 minutes)
|
|
19
|
-
|
|
20
|
-
### 1. Run setup — that's it
|
|
21
|
-
|
|
22
|
-
You don't need to provision a key first. The setup command auto-provisions a
|
|
23
|
-
free key for you if you don't pass one:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# Claude Code
|
|
27
|
-
npx -y -p memoryai-mcp memoryai-claude-setup
|
|
28
|
-
|
|
29
|
-
# Kiro
|
|
30
|
-
npx -y -p memoryai-mcp memoryai-kiro-setup
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Already have a key? Pass it to skip provisioning: `HM_API_KEY=hm_sk_... npx -y -p memoryai-mcp memoryai-claude-setup`.
|
|
34
|
-
|
|
35
|
-
<details>
|
|
36
|
-
<summary>Manual key provisioning (optional)</summary>
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
curl -X POST https://memoryai.dev/v1/admin/provision \
|
|
40
|
-
-H "Content-Type: application/json" \
|
|
41
|
-
-d '{"name": "my-agent", "tos_accepted": true}'
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Save the `api_key` from the response.
|
|
45
|
-
|
|
46
|
-
</details>
|
|
47
|
-
|
|
48
|
-
### 2. Other tools (MCP config)
|
|
49
|
-
|
|
50
|
-
For tools without a one-command installer, choose your platform below. Config once — memory works automatically forever.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## IDE Setup
|
|
55
|
-
|
|
56
|
-
### Claude Code (CLI) — one command, fully automatic
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
HM_API_KEY=hm_sk_your_key_here npx -y -p memoryai-mcp memoryai-claude-setup
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
This wires three HTTP hooks into `~/.claude/settings.json` plus the MCP server.
|
|
63
|
-
Claude Code injects each hook's context directly into the model — **memory then
|
|
64
|
-
works at the mechanism level, no agent cooperation required**:
|
|
65
|
-
|
|
66
|
-
- **SessionStart** → loads DNA + recent context when a session opens
|
|
67
|
-
- **UserPromptSubmit** → recalls relevant memory before each prompt
|
|
68
|
-
- **Stop** → stores decisions/preferences automatically when a turn ends
|
|
69
|
-
|
|
70
|
-
Re-running is safe (idempotent merge). For a project-only install set
|
|
71
|
-
`MEMORYAI_SCOPE=project`. After setup, restart Claude Code and just work — you
|
|
72
|
-
never call a memory tool by hand.
|
|
73
|
-
|
|
74
|
-
<details>
|
|
75
|
-
<summary>Manual setup (MCP only, soft automation via CLAUDE.md)</summary>
|
|
76
|
-
|
|
77
|
-
If you prefer not to use hooks, add the MCP server to `~/.claude/settings.json`:
|
|
78
|
-
|
|
79
|
-
```json
|
|
80
|
-
{
|
|
81
|
-
"mcpServers": {
|
|
82
|
-
"memoryai": {
|
|
83
|
-
"command": "npx",
|
|
84
|
-
"args": ["-y", "memoryai-mcp"],
|
|
85
|
-
"env": {
|
|
86
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
87
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Then create `~/.claude/CLAUDE.md`:
|
|
95
|
-
|
|
96
|
-
```markdown
|
|
97
|
-
## Memory Protocol
|
|
98
|
-
At the start of every conversation, call `memory_bootstrap` to load context from MemoryAI.
|
|
99
|
-
Before context gets large (>100K tokens), call `memory_compact` to save important context.
|
|
100
|
-
Use `memory_store` to save important decisions, preferences, and facts.
|
|
101
|
-
Use `memory_recall` to search past memories when relevant.
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Note: without hooks, memory depends on the model following CLAUDE.md (soft
|
|
105
|
-
automation). The hook setup above is the guaranteed, mechanism-level path.
|
|
106
|
-
|
|
107
|
-
</details>
|
|
108
|
-
|
|
109
|
-
### Kiro — one command, fully automatic
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
HM_API_KEY=hm_sk_your_key_here npx -y -p memoryai-mcp memoryai-kiro-setup
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Writes `.kiro/settings/mcp.json` (with autoApprove), `.kiro/steering/memoryai.md`,
|
|
116
|
-
and two Agent Hooks (`promptSubmit` → recall, `agentStop` → store/compact) so
|
|
117
|
-
memory is automatic at the event level.
|
|
118
|
-
|
|
119
|
-
### Cursor — `~/.cursor/mcp.json`
|
|
120
|
-
|
|
121
|
-
```json
|
|
122
|
-
{
|
|
123
|
-
"mcpServers": {
|
|
124
|
-
"memoryai": {
|
|
125
|
-
"command": "npx",
|
|
126
|
-
"args": ["-y", "memoryai-mcp"],
|
|
127
|
-
"env": {
|
|
128
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
129
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Auto-bootstrap — create `.cursor/rules/memoryai.mdc`:
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
At the start of every session, call memory_bootstrap to load context.
|
|
140
|
-
After completing tasks, call memory_compact to save context.
|
|
141
|
-
Store important decisions and preferences with memory_store.
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### VS Code — `.vscode/mcp.json`
|
|
145
|
-
|
|
146
|
-
```json
|
|
147
|
-
{
|
|
148
|
-
"servers": {
|
|
149
|
-
"memoryai": {
|
|
150
|
-
"command": "npx",
|
|
151
|
-
"args": ["-y", "memoryai-mcp"],
|
|
152
|
-
"env": {
|
|
153
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
154
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Kiro — `.kiro/settings/mcp.json`
|
|
162
|
-
|
|
163
|
-
```json
|
|
164
|
-
{
|
|
165
|
-
"mcpServers": {
|
|
166
|
-
"memoryai": {
|
|
167
|
-
"command": "npx",
|
|
168
|
-
"args": ["-y", "memoryai-mcp"],
|
|
169
|
-
"env": {
|
|
170
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
171
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Windsurf — `~/.codeium/windsurf/mcp_config.json`
|
|
179
|
-
|
|
180
|
-
```json
|
|
181
|
-
{
|
|
182
|
-
"mcpServers": {
|
|
183
|
-
"memoryai": {
|
|
184
|
-
"command": "npx",
|
|
185
|
-
"args": ["-y", "memoryai-mcp"],
|
|
186
|
-
"env": {
|
|
187
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
188
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Claude Desktop — `claude_desktop_config.json`
|
|
196
|
-
|
|
197
|
-
macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
198
|
-
Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
199
|
-
|
|
200
|
-
```json
|
|
201
|
-
{
|
|
202
|
-
"mcpServers": {
|
|
203
|
-
"memoryai": {
|
|
204
|
-
"command": "npx",
|
|
205
|
-
"args": ["-y", "memoryai-mcp"],
|
|
206
|
-
"env": {
|
|
207
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
208
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Antigravity — `~/.antigravity/mcp.json`
|
|
216
|
-
|
|
217
|
-
```json
|
|
218
|
-
{
|
|
219
|
-
"mcpServers": {
|
|
220
|
-
"memoryai": {
|
|
221
|
-
"command": "npx",
|
|
222
|
-
"args": ["-y", "memoryai-mcp"],
|
|
223
|
-
"env": {
|
|
224
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
225
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Any MCP-compatible tool
|
|
233
|
-
|
|
234
|
-
```json
|
|
235
|
-
{
|
|
236
|
-
"mcpServers": {
|
|
237
|
-
"memoryai": {
|
|
238
|
-
"command": "npx",
|
|
239
|
-
"args": ["-y", "memoryai-mcp"],
|
|
240
|
-
"env": {
|
|
241
|
-
"HM_ENDPOINT": "https://memoryai.dev",
|
|
242
|
-
"HM_API_KEY": "hm_sk_your_key_here"
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## Auto-Bootstrap (Make It Fully Automatic)
|
|
252
|
-
|
|
253
|
-
After MCP config, add a system rule so your agent auto-loads memory every session:
|
|
254
|
-
|
|
255
|
-
| Platform | Rule File | Content |
|
|
256
|
-
|----------|-----------|---------|
|
|
257
|
-
| Claude Code | `~/.claude/CLAUDE.md` | See above |
|
|
258
|
-
| Cursor | `.cursor/rules/memoryai.mdc` | See above |
|
|
259
|
-
| Kiro | `.kiro/rules/memoryai.md` | Same content |
|
|
260
|
-
| Windsurf | `.windsurfrules` | Same content |
|
|
261
|
-
| VS Code | `.github/copilot-instructions.md` | Same content |
|
|
262
|
-
|
|
263
|
-
Rule content (copy-paste for any platform):
|
|
264
|
-
|
|
265
|
-
```
|
|
266
|
-
## Memory Protocol
|
|
267
|
-
At the start of every conversation, call `memory_bootstrap` to load context from MemoryAI.
|
|
268
|
-
Before context gets large, call `memory_compact` to save important context.
|
|
269
|
-
Use `memory_store` to save important decisions, preferences, and facts.
|
|
270
|
-
Use `memory_recall` to search past memories when relevant.
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
---
|
|
274
|
-
|
|
275
|
-
## How It Works
|
|
276
|
-
|
|
277
|
-
```
|
|
278
|
-
Open IDE → MCP auto-connects → Agent reads rules → Calls bootstrap
|
|
279
|
-
→ Loads your identity, preferences, recent work
|
|
280
|
-
→ Works normally (auto-stores important stuff)
|
|
281
|
-
→ Context getting full? Auto-compacts
|
|
282
|
-
→ Close IDE → Sleep workers consolidate overnight
|
|
283
|
-
→ Open IDE next day → Bootstrap loads everything back
|
|
284
|
-
→ Cycle repeats. Memory grows smarter over time.
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
**You do nothing.** The agent handles everything automatically.
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## Tools Available
|
|
292
|
-
|
|
293
|
-
| Tool | What It Does |
|
|
294
|
-
|------|-------------|
|
|
295
|
-
| `memory_bootstrap` | Wake up with full context (identity + recent + preferences) |
|
|
296
|
-
| `memory_store` | Save a memory (fact, decision, preference, identity) |
|
|
297
|
-
| `memory_recall` | Search memories by meaning (semantic + graph + FTS) |
|
|
298
|
-
| `memory_compact` | Save conversation context before it's lost |
|
|
299
|
-
| `memory_recover` | Recover session after a break |
|
|
300
|
-
| `memory_health` | Check context pressure (safe/warning/critical) |
|
|
301
|
-
| `memory_explore` | Explore connections between memories |
|
|
302
|
-
| `memory_clusters` | View topic clusters in your knowledge graph |
|
|
303
|
-
| `learn` | Store action + result + lesson learned |
|
|
304
|
-
| `entity_list` | List tracked entities (files, people, packages) |
|
|
305
|
-
| `reasoning_store` | Deep reasoning memory (Pro+) |
|
|
306
|
-
| `reasoning_recall` | Recall reasoned insights (Pro+) |
|
|
307
|
-
| `snapshot_create` | Backup memory state |
|
|
308
|
-
| `snapshot_restore` | Restore from backup |
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
## Context Guard (Built-in)
|
|
313
|
-
|
|
314
|
-
Context Guard monitors your session and prevents context loss:
|
|
315
|
-
|
|
316
|
-
| State | Meaning | Agent Action |
|
|
317
|
-
|-------|---------|-------------|
|
|
318
|
-
| SAFE | Context < 40% full | Continue normally |
|
|
319
|
-
| COMPACT_SOON | Context 40-55% full | Prepare to compact |
|
|
320
|
-
| COMPACT_NOW | Context > 55% full | Must compact immediately |
|
|
321
|
-
|
|
322
|
-
The agent handles this automatically when rules are configured. No manual intervention needed.
|
|
323
|
-
|
|
324
|
-
---
|
|
325
|
-
|
|
326
|
-
## What Gets Remembered (DNA System)
|
|
327
|
-
|
|
328
|
-
| Memory Type | Example | Persistence |
|
|
329
|
-
|-------------|---------|-------------|
|
|
330
|
-
| `preference` | "I prefer Python over Java" | **Forever** (DNA-protected) |
|
|
331
|
-
| `decision` | "Chose PostgreSQL for this project" | **Forever** (DNA-protected) |
|
|
332
|
-
| `identity` | "Senior backend engineer, 10 years" | **Forever** (DNA-protected) |
|
|
333
|
-
| `fact` | "API endpoint is /v1/users" | Decays if unused |
|
|
334
|
-
| `goal` | "Launch v2.0 by June" | Decays if unused |
|
|
335
|
-
|
|
336
|
-
DNA memories (preference/decision/identity) **never decay, never get deleted, never get overwritten** by any background process. They define who you are.
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## Pricing
|
|
341
|
-
|
|
342
|
-
| Plan | Features | Price |
|
|
343
|
-
|------|----------|-------|
|
|
344
|
-
| Free | Basic store/recall, 100 memories | Free |
|
|
345
|
-
| Pro | Full brain (reasoning, consolidation, personality) | Paid |
|
|
346
|
-
| ProMax | Multi-agent mesh, advanced features | Paid |
|
|
347
|
-
|
|
|
348
|
-
|
|
349
|
-
Get started free: https://memoryai.dev
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
## Links
|
|
354
|
-
|
|
355
|
-
- Website: https://memoryai.dev
|
|
356
|
-
- Python SDK: `pip install hmc-memory`
|
|
357
|
-
- npm MCP: `npx memoryai-mcp`
|
|
358
|
-
- GitHub: https://github.com/memoryai-dev/memoryai
|
|
359
|
-
|
|
360
|
-
## License
|
|
361
|
-
|
|
362
|
-
MIT
|
|
1
|
+
# memoryai-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [MemoryAI](https://memoryai.dev) — a living brain for your AI agent.
|
|
4
|
+
|
|
5
|
+
Your AI agent gets persistent memory that works like a real brain:
|
|
6
|
+
- Remembers what matters, forgets what doesn't
|
|
7
|
+
- Strengthens memories you use often (Hebbian learning)
|
|
8
|
+
- Consolidates knowledge while idle (Sleep cycles)
|
|
9
|
+
- Protects core identity (DNA memories never fade)
|
|
10
|
+
- Adapts to your emotional state
|
|
11
|
+
|
|
12
|
+
**Install once. Everything auto from there.**
|
|
13
|
+
|
|
14
|
+
Automation level by platform:
|
|
15
|
+
- **Mechanism-level (hands-off, guaranteed):** OpenAI Proxy, Kiro (Agent Hooks), Claude Code (HTTP hooks via `memoryai-claude-setup`).
|
|
16
|
+
- **Soft (rules-file, depends on the model following instructions):** Cursor, Windsurf, VS Code Copilot. MCP tools are available; add the rules file shown below.
|
|
17
|
+
|
|
18
|
+
## Quick Start (2 minutes)
|
|
19
|
+
|
|
20
|
+
### 1. Run setup — that's it
|
|
21
|
+
|
|
22
|
+
You don't need to provision a key first. The setup command auto-provisions a
|
|
23
|
+
free key for you if you don't pass one:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Claude Code
|
|
27
|
+
npx -y -p memoryai-mcp memoryai-claude-setup
|
|
28
|
+
|
|
29
|
+
# Kiro
|
|
30
|
+
npx -y -p memoryai-mcp memoryai-kiro-setup
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Already have a key? Pass it to skip provisioning: `HM_API_KEY=hm_sk_... npx -y -p memoryai-mcp memoryai-claude-setup`.
|
|
34
|
+
|
|
35
|
+
<details>
|
|
36
|
+
<summary>Manual key provisioning (optional)</summary>
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
curl -X POST https://memoryai.dev/v1/admin/provision \
|
|
40
|
+
-H "Content-Type: application/json" \
|
|
41
|
+
-d '{"name": "my-agent", "tos_accepted": true}'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Save the `api_key` from the response.
|
|
45
|
+
|
|
46
|
+
</details>
|
|
47
|
+
|
|
48
|
+
### 2. Other tools (MCP config)
|
|
49
|
+
|
|
50
|
+
For tools without a one-command installer, choose your platform below. Config once — memory works automatically forever.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## IDE Setup
|
|
55
|
+
|
|
56
|
+
### Claude Code (CLI) — one command, fully automatic
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
HM_API_KEY=hm_sk_your_key_here npx -y -p memoryai-mcp memoryai-claude-setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This wires three HTTP hooks into `~/.claude/settings.json` plus the MCP server.
|
|
63
|
+
Claude Code injects each hook's context directly into the model — **memory then
|
|
64
|
+
works at the mechanism level, no agent cooperation required**:
|
|
65
|
+
|
|
66
|
+
- **SessionStart** → loads DNA + recent context when a session opens
|
|
67
|
+
- **UserPromptSubmit** → recalls relevant memory before each prompt
|
|
68
|
+
- **Stop** → stores decisions/preferences automatically when a turn ends
|
|
69
|
+
|
|
70
|
+
Re-running is safe (idempotent merge). For a project-only install set
|
|
71
|
+
`MEMORYAI_SCOPE=project`. After setup, restart Claude Code and just work — you
|
|
72
|
+
never call a memory tool by hand.
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary>Manual setup (MCP only, soft automation via CLAUDE.md)</summary>
|
|
76
|
+
|
|
77
|
+
If you prefer not to use hooks, add the MCP server to `~/.claude/settings.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"mcpServers": {
|
|
82
|
+
"memoryai": {
|
|
83
|
+
"command": "npx",
|
|
84
|
+
"args": ["-y", "memoryai-mcp"],
|
|
85
|
+
"env": {
|
|
86
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
87
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Then create `~/.claude/CLAUDE.md`:
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
## Memory Protocol
|
|
98
|
+
At the start of every conversation, call `memory_bootstrap` to load context from MemoryAI.
|
|
99
|
+
Before context gets large (>100K tokens), call `memory_compact` to save important context.
|
|
100
|
+
Use `memory_store` to save important decisions, preferences, and facts.
|
|
101
|
+
Use `memory_recall` to search past memories when relevant.
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Note: without hooks, memory depends on the model following CLAUDE.md (soft
|
|
105
|
+
automation). The hook setup above is the guaranteed, mechanism-level path.
|
|
106
|
+
|
|
107
|
+
</details>
|
|
108
|
+
|
|
109
|
+
### Kiro — one command, fully automatic
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
HM_API_KEY=hm_sk_your_key_here npx -y -p memoryai-mcp memoryai-kiro-setup
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Writes `.kiro/settings/mcp.json` (with autoApprove), `.kiro/steering/memoryai.md`,
|
|
116
|
+
and two Agent Hooks (`promptSubmit` → recall, `agentStop` → store/compact) so
|
|
117
|
+
memory is automatic at the event level.
|
|
118
|
+
|
|
119
|
+
### Cursor — `~/.cursor/mcp.json`
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"mcpServers": {
|
|
124
|
+
"memoryai": {
|
|
125
|
+
"command": "npx",
|
|
126
|
+
"args": ["-y", "memoryai-mcp"],
|
|
127
|
+
"env": {
|
|
128
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
129
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Auto-bootstrap — create `.cursor/rules/memoryai.mdc`:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
At the start of every session, call memory_bootstrap to load context.
|
|
140
|
+
After completing tasks, call memory_compact to save context.
|
|
141
|
+
Store important decisions and preferences with memory_store.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### VS Code — `.vscode/mcp.json`
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"servers": {
|
|
149
|
+
"memoryai": {
|
|
150
|
+
"command": "npx",
|
|
151
|
+
"args": ["-y", "memoryai-mcp"],
|
|
152
|
+
"env": {
|
|
153
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
154
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Kiro — `.kiro/settings/mcp.json`
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"mcpServers": {
|
|
166
|
+
"memoryai": {
|
|
167
|
+
"command": "npx",
|
|
168
|
+
"args": ["-y", "memoryai-mcp"],
|
|
169
|
+
"env": {
|
|
170
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
171
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Windsurf — `~/.codeium/windsurf/mcp_config.json`
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"mcpServers": {
|
|
183
|
+
"memoryai": {
|
|
184
|
+
"command": "npx",
|
|
185
|
+
"args": ["-y", "memoryai-mcp"],
|
|
186
|
+
"env": {
|
|
187
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
188
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Claude Desktop — `claude_desktop_config.json`
|
|
196
|
+
|
|
197
|
+
macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
198
|
+
Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"mcpServers": {
|
|
203
|
+
"memoryai": {
|
|
204
|
+
"command": "npx",
|
|
205
|
+
"args": ["-y", "memoryai-mcp"],
|
|
206
|
+
"env": {
|
|
207
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
208
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Antigravity — `~/.antigravity/mcp.json`
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"mcpServers": {
|
|
220
|
+
"memoryai": {
|
|
221
|
+
"command": "npx",
|
|
222
|
+
"args": ["-y", "memoryai-mcp"],
|
|
223
|
+
"env": {
|
|
224
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
225
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Any MCP-compatible tool
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"mcpServers": {
|
|
237
|
+
"memoryai": {
|
|
238
|
+
"command": "npx",
|
|
239
|
+
"args": ["-y", "memoryai-mcp"],
|
|
240
|
+
"env": {
|
|
241
|
+
"HM_ENDPOINT": "https://memoryai.dev",
|
|
242
|
+
"HM_API_KEY": "hm_sk_your_key_here"
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Auto-Bootstrap (Make It Fully Automatic)
|
|
252
|
+
|
|
253
|
+
After MCP config, add a system rule so your agent auto-loads memory every session:
|
|
254
|
+
|
|
255
|
+
| Platform | Rule File | Content |
|
|
256
|
+
|----------|-----------|---------|
|
|
257
|
+
| Claude Code | `~/.claude/CLAUDE.md` | See above |
|
|
258
|
+
| Cursor | `.cursor/rules/memoryai.mdc` | See above |
|
|
259
|
+
| Kiro | `.kiro/rules/memoryai.md` | Same content |
|
|
260
|
+
| Windsurf | `.windsurfrules` | Same content |
|
|
261
|
+
| VS Code | `.github/copilot-instructions.md` | Same content |
|
|
262
|
+
|
|
263
|
+
Rule content (copy-paste for any platform):
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
## Memory Protocol
|
|
267
|
+
At the start of every conversation, call `memory_bootstrap` to load context from MemoryAI.
|
|
268
|
+
Before context gets large, call `memory_compact` to save important context.
|
|
269
|
+
Use `memory_store` to save important decisions, preferences, and facts.
|
|
270
|
+
Use `memory_recall` to search past memories when relevant.
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## How It Works
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
Open IDE → MCP auto-connects → Agent reads rules → Calls bootstrap
|
|
279
|
+
→ Loads your identity, preferences, recent work
|
|
280
|
+
→ Works normally (auto-stores important stuff)
|
|
281
|
+
→ Context getting full? Auto-compacts
|
|
282
|
+
→ Close IDE → Sleep workers consolidate overnight
|
|
283
|
+
→ Open IDE next day → Bootstrap loads everything back
|
|
284
|
+
→ Cycle repeats. Memory grows smarter over time.
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**You do nothing.** The agent handles everything automatically.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Tools Available
|
|
292
|
+
|
|
293
|
+
| Tool | What It Does |
|
|
294
|
+
|------|-------------|
|
|
295
|
+
| `memory_bootstrap` | Wake up with full context (identity + recent + preferences) |
|
|
296
|
+
| `memory_store` | Save a memory (fact, decision, preference, identity) |
|
|
297
|
+
| `memory_recall` | Search memories by meaning (semantic + graph + FTS) |
|
|
298
|
+
| `memory_compact` | Save conversation context before it's lost |
|
|
299
|
+
| `memory_recover` | Recover session after a break |
|
|
300
|
+
| `memory_health` | Check context pressure (safe/warning/critical) |
|
|
301
|
+
| `memory_explore` | Explore connections between memories |
|
|
302
|
+
| `memory_clusters` | View topic clusters in your knowledge graph |
|
|
303
|
+
| `learn` | Store action + result + lesson learned |
|
|
304
|
+
| `entity_list` | List tracked entities (files, people, packages) |
|
|
305
|
+
| `reasoning_store` | Deep reasoning memory (Pro+) |
|
|
306
|
+
| `reasoning_recall` | Recall reasoned insights (Pro+) |
|
|
307
|
+
| `snapshot_create` | Backup memory state |
|
|
308
|
+
| `snapshot_restore` | Restore from backup |
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Context Guard (Built-in)
|
|
313
|
+
|
|
314
|
+
Context Guard monitors your session and prevents context loss:
|
|
315
|
+
|
|
316
|
+
| State | Meaning | Agent Action |
|
|
317
|
+
|-------|---------|-------------|
|
|
318
|
+
| SAFE | Context < 40% full | Continue normally |
|
|
319
|
+
| COMPACT_SOON | Context 40-55% full | Prepare to compact |
|
|
320
|
+
| COMPACT_NOW | Context > 55% full | Must compact immediately |
|
|
321
|
+
|
|
322
|
+
The agent handles this automatically when rules are configured. No manual intervention needed.
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## What Gets Remembered (DNA System)
|
|
327
|
+
|
|
328
|
+
| Memory Type | Example | Persistence |
|
|
329
|
+
|-------------|---------|-------------|
|
|
330
|
+
| `preference` | "I prefer Python over Java" | **Forever** (DNA-protected) |
|
|
331
|
+
| `decision` | "Chose PostgreSQL for this project" | **Forever** (DNA-protected) |
|
|
332
|
+
| `identity` | "Senior backend engineer, 10 years" | **Forever** (DNA-protected) |
|
|
333
|
+
| `fact` | "API endpoint is /v1/users" | Decays if unused |
|
|
334
|
+
| `goal` | "Launch v2.0 by June" | Decays if unused |
|
|
335
|
+
|
|
336
|
+
DNA memories (preference/decision/identity) **never decay, never get deleted, never get overwritten** by any background process. They define who you are.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Pricing
|
|
341
|
+
|
|
342
|
+
| Plan | Features | Price |
|
|
343
|
+
|------|----------|-------|
|
|
344
|
+
| Free | Basic store/recall, 100 memories | Free |
|
|
345
|
+
| Pro | Full brain (reasoning, consolidation, personality) | Paid |
|
|
346
|
+
| ProMax | Multi-agent mesh, advanced features | Paid |
|
|
347
|
+
| Enterprise | Everything + deep graph traversal + on-prem | Custom |
|
|
348
|
+
|
|
349
|
+
Get started free: https://memoryai.dev
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Links
|
|
354
|
+
|
|
355
|
+
- Website: https://memoryai.dev
|
|
356
|
+
- Python SDK: `pip install hmc-memory`
|
|
357
|
+
- npm MCP: `npx memoryai-mcp`
|
|
358
|
+
- GitHub: https://github.com/memoryai-dev/memoryai
|
|
359
|
+
|
|
360
|
+
## License
|
|
361
|
+
|
|
362
|
+
MIT
|
package/dist/claude-setup.js
CHANGED
|
@@ -69,19 +69,19 @@ function ensureHook(settings, event, handler) {
|
|
|
69
69
|
settings.hooks[event].push({ hooks: [handler] });
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
72
|
-
const CLAUDE_MD = `
|
|
73
|
-
# MemoryAI — Persistent Memory (automatic)
|
|
74
|
-
|
|
75
|
-
MemoryAI is wired into this Claude Code via HTTP hooks, so memory works
|
|
76
|
-
automatically at the mechanism level — you don't have to call tools by hand:
|
|
77
|
-
|
|
78
|
-
- Relevant past context is injected before each prompt (UserPromptSubmit hook).
|
|
79
|
-
- Session-start context (preferences, decisions, recent work) loads on open.
|
|
80
|
-
- Decisions and preferences are stored automatically when each turn ends.
|
|
81
|
-
|
|
82
|
-
The MemoryAI MCP server is also connected for advanced use. You may call
|
|
83
|
-
\`memory_recall\` explicitly when you need deeper history, but for everyday work
|
|
84
|
-
the hooks handle it. Never store secrets or credentials.
|
|
72
|
+
const CLAUDE_MD = `
|
|
73
|
+
# MemoryAI — Persistent Memory (automatic)
|
|
74
|
+
|
|
75
|
+
MemoryAI is wired into this Claude Code via HTTP hooks, so memory works
|
|
76
|
+
automatically at the mechanism level — you don't have to call tools by hand:
|
|
77
|
+
|
|
78
|
+
- Relevant past context is injected before each prompt (UserPromptSubmit hook).
|
|
79
|
+
- Session-start context (preferences, decisions, recent work) loads on open.
|
|
80
|
+
- Decisions and preferences are stored automatically when each turn ends.
|
|
81
|
+
|
|
82
|
+
The MemoryAI MCP server is also connected for advanced use. You may call
|
|
83
|
+
\`memory_recall\` explicitly when you need deeper history, but for everyday work
|
|
84
|
+
the hooks handle it. Never store secrets or credentials.
|
|
85
85
|
`;
|
|
86
86
|
const MCP_BLOCK = (apiKey, endpoint) => ({
|
|
87
87
|
command: "npx",
|
|
@@ -199,14 +199,14 @@ async function main() {
|
|
|
199
199
|
else {
|
|
200
200
|
console.log(` skip ${claudeMdPath} (note already present)`);
|
|
201
201
|
}
|
|
202
|
-
console.log(`
|
|
203
|
-
Done. MemoryAI runs automatically in Claude Code — nothing else to do.
|
|
204
|
-
- Context is recalled before each prompt and injected for you.
|
|
205
|
-
- Decisions/preferences are stored when each turn ends.
|
|
206
|
-
|
|
207
|
-
Next steps:
|
|
208
|
-
1. Restart Claude Code (loads the hooks + MCP server).
|
|
209
|
-
2. Just work normally. Memory persists across sessions on its own.
|
|
202
|
+
console.log(`
|
|
203
|
+
Done. MemoryAI runs automatically in Claude Code — nothing else to do.
|
|
204
|
+
- Context is recalled before each prompt and injected for you.
|
|
205
|
+
- Decisions/preferences are stored when each turn ends.
|
|
206
|
+
|
|
207
|
+
Next steps:
|
|
208
|
+
1. Restart Claude Code (loads the hooks + MCP server).
|
|
209
|
+
2. Just work normally. Memory persists across sessions on its own.
|
|
210
210
|
`);
|
|
211
211
|
rl.close();
|
|
212
212
|
}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { z } from "zod";
|
|
|
11
11
|
const API_URL = process.env.MEMORYAI_ENDPOINT || process.env.HM_ENDPOINT || "http://localhost:8420";
|
|
12
12
|
const API_KEY = process.env.MEMORYAI_API_KEY || process.env.HM_API_KEY || "";
|
|
13
13
|
const REQUEST_TIMEOUT_MS = 30_000; // P2 #6: 30s default timeout for API requests
|
|
14
|
-
const MCP_VERSION = "2.4.
|
|
14
|
+
const MCP_VERSION = "2.4.3";
|
|
15
15
|
// Context Guard — per-IDE settings via env vars.
|
|
16
16
|
// HM_COMPACT_AT and HM_CRITICAL_AT are now ABSOLUTE token counts (e.g. "100000",
|
|
17
17
|
// "150000"). The legacy meaning ("30" = 30%) is detected automatically: any
|
|
@@ -24,6 +24,13 @@ const MCP_VERSION = "2.4.1";
|
|
|
24
24
|
const CG_CONTEXT_CAP = parseInt(process.env.MEMORYAI_CONTEXT_CAP || process.env.HM_CONTEXT_CAP || "0", 10);
|
|
25
25
|
const CG_COMPACT_RAW = parseInt(process.env.MEMORYAI_COMPACT_AT || process.env.HM_COMPACT_AT || "0", 10);
|
|
26
26
|
const CG_CRITICAL_RAW = parseInt(process.env.MEMORYAI_CRITICAL_AT || process.env.HM_CRITICAL_AT || "0", 10);
|
|
27
|
+
// Model hint for server-side window auto-detection. When set, the server
|
|
28
|
+
// resolves the context window from the model name and picks the adaptive
|
|
29
|
+
// trigger percentage (<=200K → 95%, >200K → 30%). Falls back to the model
|
|
30
|
+
// the caller passes per-request, then to the 200K default.
|
|
31
|
+
// e.g. MEMORYAI_MODEL=claude-opus-4-6[1m] → 1M window → 30% trigger
|
|
32
|
+
// MEMORYAI_MODEL=claude-sonnet-4-6 → 200K window → 95% trigger
|
|
33
|
+
const CG_MODEL = (process.env.MEMORYAI_MODEL || process.env.HM_MODEL || "").trim() || null;
|
|
27
34
|
// Heuristic: small numbers are legacy percentages; large numbers are absolute tokens.
|
|
28
35
|
// Threshold "<= 100" is generous enough to catch any sensible % (max 95%) and
|
|
29
36
|
// well below any sensible absolute count (min would be ~10K tokens).
|
|
@@ -152,7 +159,7 @@ function err(e) {
|
|
|
152
159
|
return { content, isError: true };
|
|
153
160
|
}
|
|
154
161
|
// --- MCP Server ---
|
|
155
|
-
const server = new McpServer({ name: "memoryai", version: "2.4.
|
|
162
|
+
const server = new McpServer({ name: "memoryai", version: "2.4.3" }, {
|
|
156
163
|
capabilities: { tools: {} },
|
|
157
164
|
instructions: "MemoryAI persistent memory. Call memory_bootstrap on session start. After decisions/preferences, call memory_store. Context compaction is automatic via piggybacking — follow any [Context Guard] directives in tool responses.",
|
|
158
165
|
});
|
|
@@ -1013,12 +1020,13 @@ server.tool("context_guard_check", "[CORE] Check context pressure — returns re
|
|
|
1013
1020
|
model: z.string().optional().describe("Model name for auto-detecting context window size (e.g. claude-sonnet-4-6)"),
|
|
1014
1021
|
}, async (args) => {
|
|
1015
1022
|
try {
|
|
1016
|
-
// Use env var HM_CONTEXT_CAP as default if max_tokens not provided
|
|
1023
|
+
// Use env var HM_CONTEXT_CAP as default if max_tokens not provided.
|
|
1024
|
+
// 0 → server auto-detects the window from the model name.
|
|
1017
1025
|
const maxTokens = args.max_tokens || CG_CONTEXT_CAP || 0;
|
|
1018
1026
|
const payload = {
|
|
1019
1027
|
estimated_tokens: args.estimated_tokens,
|
|
1020
1028
|
max_tokens: maxTokens,
|
|
1021
|
-
model: args.model ||
|
|
1029
|
+
model: args.model || CG_MODEL,
|
|
1022
1030
|
};
|
|
1023
1031
|
// Per-IDE threshold overrides. Absolute (CG_*_AT_TOKENS) is preferred —
|
|
1024
1032
|
// server treats it as the authoritative trigger. Decimal % is the
|
|
@@ -1097,7 +1105,7 @@ server.tool("ide_turn_check", "[CORE] Server-authoritative context check for IDE
|
|
|
1097
1105
|
max_tokens: args.max_tokens ?? CG_CONTEXT_CAP ?? 200_000,
|
|
1098
1106
|
avg_tokens_per_turn: args.avg_tokens_per_turn ?? 8000,
|
|
1099
1107
|
skip_below_turns: args.skip_below_turns ?? 10,
|
|
1100
|
-
model: args.model ??
|
|
1108
|
+
model: args.model ?? CG_MODEL,
|
|
1101
1109
|
};
|
|
1102
1110
|
// Per-IDE threshold overrides. Absolute first (preferred), % fallback.
|
|
1103
1111
|
if (CG_COMPACT_AT_TOKENS > 0)
|
|
@@ -1210,7 +1218,7 @@ server.tool("bot_guard_check", "Advanced: Bot context guard — checks context p
|
|
|
1210
1218
|
const payload = {
|
|
1211
1219
|
estimated_tokens: args.estimated_tokens,
|
|
1212
1220
|
max_tokens: args.max_tokens || CG_CONTEXT_CAP || 200000,
|
|
1213
|
-
model: args.model ||
|
|
1221
|
+
model: args.model || CG_MODEL,
|
|
1214
1222
|
};
|
|
1215
1223
|
if (args.compress_threshold)
|
|
1216
1224
|
payload.compress_threshold = args.compress_threshold;
|
package/dist/kiro-setup.d.ts
CHANGED
|
@@ -4,13 +4,19 @@
|
|
|
4
4
|
* Zero-dependency setup script that creates, in the current project:
|
|
5
5
|
* - .kiro/settings/mcp.json (MCP server wiring)
|
|
6
6
|
* - .kiro/steering/memoryai.md (always-on instructions, soft fallback)
|
|
7
|
-
* - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit →
|
|
8
|
-
* - .kiro/hooks/memoryai-auto-capture.kiro.hook (agentStop → store/compact)
|
|
7
|
+
* - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit → recall + guard)
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* ONE hook only (v0.2.4+). It fires on promptSubmit — BEFORE the answer — and
|
|
10
|
+
* does three things in a single pass: recall relevant memory, persist anything
|
|
11
|
+
* memorable from the previous turn, and run the context-guard release check.
|
|
12
|
+
*
|
|
13
|
+
* Why not a second agentStop hook? The old design had a separate
|
|
14
|
+
* memoryai-auto-capture.kiro.hook on agentStop. agentStop fires AFTER the
|
|
15
|
+
* reply and forces a fresh askAgent reasoning pass whose only job is to "stay
|
|
16
|
+
* silent" — which leaks a stray "." into the chat and burns ~1.5 credits per
|
|
17
|
+
* idle turn. Folding the capture/guard logic into the promptSubmit hook fixes
|
|
18
|
+
* both problems: the background work finishes before the model answers, so the
|
|
19
|
+
* reply is clean and nothing fires on an idle turn-end. The setup below also
|
|
20
|
+
* deletes any pre-0.2.4 auto-capture hook left on disk.
|
|
15
21
|
*/
|
|
16
22
|
export {};
|
package/dist/kiro-setup.js
CHANGED
|
@@ -4,17 +4,23 @@
|
|
|
4
4
|
* Zero-dependency setup script that creates, in the current project:
|
|
5
5
|
* - .kiro/settings/mcp.json (MCP server wiring)
|
|
6
6
|
* - .kiro/steering/memoryai.md (always-on instructions, soft fallback)
|
|
7
|
-
* - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit →
|
|
8
|
-
* - .kiro/hooks/memoryai-auto-capture.kiro.hook (agentStop → store/compact)
|
|
7
|
+
* - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit → recall + guard)
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* ONE hook only (v0.2.4+). It fires on promptSubmit — BEFORE the answer — and
|
|
10
|
+
* does three things in a single pass: recall relevant memory, persist anything
|
|
11
|
+
* memorable from the previous turn, and run the context-guard release check.
|
|
12
|
+
*
|
|
13
|
+
* Why not a second agentStop hook? The old design had a separate
|
|
14
|
+
* memoryai-auto-capture.kiro.hook on agentStop. agentStop fires AFTER the
|
|
15
|
+
* reply and forces a fresh askAgent reasoning pass whose only job is to "stay
|
|
16
|
+
* silent" — which leaks a stray "." into the chat and burns ~1.5 credits per
|
|
17
|
+
* idle turn. Folding the capture/guard logic into the promptSubmit hook fixes
|
|
18
|
+
* both problems: the background work finishes before the model answers, so the
|
|
19
|
+
* reply is clean and nothing fires on an idle turn-end. The setup below also
|
|
20
|
+
* deletes any pre-0.2.4 auto-capture hook left on disk.
|
|
15
21
|
*/
|
|
16
22
|
import { createInterface } from "node:readline";
|
|
17
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
23
|
+
import { existsSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
|
|
18
24
|
import { join, dirname } from "node:path";
|
|
19
25
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
20
26
|
function ask(question, fallback) {
|
|
@@ -92,71 +98,61 @@ const MCP_CONFIG = (apiKey, endpoint) => JSON.stringify({
|
|
|
92
98
|
},
|
|
93
99
|
},
|
|
94
100
|
}, null, 2) + "\n";
|
|
95
|
-
const STEERING = `---
|
|
96
|
-
inclusion: always
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
# MemoryAI — Persistent Memory (mostly automatic)
|
|
100
|
-
|
|
101
|
-
You have MemoryAI tools via MCP.
|
|
102
|
-
- **Auto-Recall** (on every prompt) loads memory
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
So you normally do NOT need to manage memory by hand. This file is a fallback
|
|
106
|
-
for cases the
|
|
107
|
-
|
|
108
|
-
## What the
|
|
109
|
-
- Session-start \`memory_bootstrap\`, per-prompt \`memory_recall\`.
|
|
110
|
-
-
|
|
111
|
-
- \`
|
|
112
|
-
|
|
113
|
-
Don't duplicate these on your own unless
|
|
114
|
-
|
|
115
|
-
## Memory types
|
|
116
|
-
- \`decision\` — architectural/technical decisions (DNA-protected, never decays)
|
|
117
|
-
- \`preference\` — user preferences and conventions (DNA-protected)
|
|
118
|
-
- \`fact\` — codebase facts, API details, configs
|
|
119
|
-
- \`pitfall\` — a mistake + its lesson (DNA-protected)
|
|
120
|
-
- \`procedure\` — a reusable workflow (DNA-protected)
|
|
121
|
-
- \`error\` / \`goal\` — lessons and current objectives
|
|
122
|
-
|
|
123
|
-
## Rules
|
|
124
|
-
- Recall only when past context is actually needed — not on every trivial message.
|
|
125
|
-
- Store important outcomes, not every interaction. Dedup is automatic.
|
|
126
|
-
- Integrate recalled info naturally; never show raw tool output.
|
|
127
|
-
- Never store secrets, credentials, tokens, or full API keys.
|
|
128
|
-
- Use \`zone: "critical"\` for things that must never be forgotten.
|
|
129
|
-
- Use \`retention: "forever"\` for permanent project knowledge.
|
|
101
|
+
const STEERING = `---
|
|
102
|
+
inclusion: always
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
# MemoryAI — Persistent Memory (mostly automatic)
|
|
106
|
+
|
|
107
|
+
You have MemoryAI tools via MCP. ONE Agent Hook automates the common path:
|
|
108
|
+
- **Auto-Recall** (on every prompt, before you answer) loads memory, persists
|
|
109
|
+
anything memorable from the previous turn, and runs the context-guard check.
|
|
110
|
+
|
|
111
|
+
So you normally do NOT need to manage memory by hand. This file is a fallback
|
|
112
|
+
for cases the hook doesn't cover, plus the rules for HOW to use memory well.
|
|
113
|
+
|
|
114
|
+
## What the hook already handles
|
|
115
|
+
- Session-start \`memory_bootstrap\`, per-prompt \`memory_recall\`.
|
|
116
|
+
- \`memory_store\` for decisions/preferences/facts/pitfalls/procedures.
|
|
117
|
+
- \`ide_turn_check\` → \`context_guard_compact\` when context fills.
|
|
118
|
+
|
|
119
|
+
Don't duplicate these on your own unless the hook clearly didn't run.
|
|
120
|
+
|
|
121
|
+
## Memory types
|
|
122
|
+
- \`decision\` — architectural/technical decisions (DNA-protected, never decays)
|
|
123
|
+
- \`preference\` — user preferences and conventions (DNA-protected)
|
|
124
|
+
- \`fact\` — codebase facts, API details, configs
|
|
125
|
+
- \`pitfall\` — a mistake + its lesson (DNA-protected)
|
|
126
|
+
- \`procedure\` — a reusable workflow (DNA-protected)
|
|
127
|
+
- \`error\` / \`goal\` — lessons and current objectives
|
|
128
|
+
|
|
129
|
+
## Rules
|
|
130
|
+
- Recall only when past context is actually needed — not on every trivial message.
|
|
131
|
+
- Store important outcomes, not every interaction. Dedup is automatic.
|
|
132
|
+
- Integrate recalled info naturally; never show raw tool output.
|
|
133
|
+
- Never store secrets, credentials, tokens, or full API keys.
|
|
134
|
+
- Use \`zone: "critical"\` for things that must never be forgotten.
|
|
135
|
+
- Use \`retention: "forever"\` for permanent project knowledge.
|
|
130
136
|
`;
|
|
131
|
-
// ── Agent
|
|
132
|
-
//
|
|
137
|
+
// ── Agent Hook — event-level automation (the real "zero-action" layer) ──
|
|
138
|
+
// ONE hook on promptSubmit. Fires BEFORE the answer so all background work
|
|
139
|
+
// (recall + persist + guard) finishes first and the reply stays clean. This
|
|
140
|
+
// replaces the old two-hook design (auto-recall + auto-capture); the
|
|
141
|
+
// agentStop auto-capture hook is retired because it leaked a stray "." and
|
|
142
|
+
// cost ~1.5 credits per idle turn.
|
|
133
143
|
const HOOK_AUTO_RECALL = JSON.stringify({
|
|
134
144
|
enabled: true,
|
|
135
145
|
name: "MemoryAI Auto-Recall",
|
|
136
|
-
description: "Before answering each user message
|
|
137
|
-
version: "
|
|
146
|
+
description: "Before answering each user message: load relevant memory, persist anything memorable from the previous turn, and run the context-guard check. One hook, fires on promptSubmit so all background work finishes before the reply — zero user action.",
|
|
147
|
+
version: "2",
|
|
138
148
|
when: { type: "promptSubmit" },
|
|
139
149
|
then: {
|
|
140
150
|
type: "askAgent",
|
|
141
|
-
prompt: "Before responding,
|
|
142
|
-
"1. If this is the first turn of the session, call memory_bootstrap once to load preferences, decisions, and recent project context.\n" +
|
|
143
|
-
"2. If the
|
|
144
|
-
"3. If the
|
|
145
|
-
"
|
|
146
|
-
},
|
|
147
|
-
}, null, 2) + "\n";
|
|
148
|
-
const HOOK_AUTO_CAPTURE = JSON.stringify({
|
|
149
|
-
enabled: true,
|
|
150
|
-
name: "MemoryAI Auto-Capture",
|
|
151
|
-
description: "Fully automatic: persist memorable events to MemoryAI after every turn, and persist session state silently when pressure thresholds hit. No user action ever required — the IDE host handles window eviction on its own and the auto-recall hook rehydrates context afterwards.",
|
|
152
|
-
version: "5",
|
|
153
|
-
when: { type: "agentStop" },
|
|
154
|
-
then: {
|
|
155
|
-
type: "askAgent",
|
|
156
|
-
prompt: "Run two background tasks SILENTLY. Do not tell the user about either task, do not change your normal reply, do not suggest /compact or 'open a new conversation' — those are not user actions in this design.\n\n" +
|
|
157
|
-
"1. PERSIST: If the turn produced a decision, preference, important project fact, lesson from a mistake (pitfall), or reusable procedure, call memory_store with the correct memory_type. Skip greetings and trivia. Dedup is automatic. Never store secrets.\n\n" +
|
|
158
|
-
"2. RELEASE CHECK: Count the assistant turns in this conversation, then call ide_turn_check with turn_count = (your count) and max_tokens = 200000. Read the response's action_prompt field and follow it VERBATIM. Every action_prompt in this design tells you to act SILENTLY — call context_guard_compact when asked, do nothing when asked. Never message the user from this hook.\n\n" +
|
|
159
|
-
"The design: MemoryAI persists to DB on threshold; the IDE host (Kiro auto-summarize, Claude Code /clear, Cursor /reset) evicts the window on its own schedule; the auto-recall hook on the next user message rehydrates context. From the user's view, nothing ever happens — the chat just keeps working.",
|
|
151
|
+
prompt: "Before responding, run these background tasks SILENTLY — integrate naturally, never show raw tool output, never tell the user a memory system exists unless asked:\n\n" +
|
|
152
|
+
"1. RECALL: If this is the first turn of the session, call memory_bootstrap once to load preferences, decisions, and recent project context. If the user's message references past work, decisions, preferences, or anything that might be stored (\"what did we\", \"last time\", \"our approach\", \"why did we\", or a question about the project), call memory_recall with a focused query. Trivial small-talk: skip recall.\n\n" +
|
|
153
|
+
"2. PERSIST: If the PREVIOUS turn produced a decision, preference, important project fact, lesson from a mistake (pitfall), or reusable procedure, call memory_store with the correct memory_type. Skip greetings and trivia. Dedup is automatic. Never store secrets.\n\n" +
|
|
154
|
+
"3. RELEASE CHECK: Count the assistant turns in this conversation. If the count is 15 or higher, call ide_turn_check with turn_count = (your count) and max_tokens = 200000, then follow the response's action_prompt field VERBATIM. Below turn 15, skip the guard. Every action_prompt acts SILENTLY — call context_guard_compact when asked, do nothing when asked. The ONLY message you may ever surface is the single \"context is full\" notice, and only when the action_prompt explicitly contains it, once per session.\n\n" +
|
|
155
|
+
"Then answer the user normally using whatever you recalled.",
|
|
160
156
|
},
|
|
161
157
|
}, null, 2) + "\n";
|
|
162
158
|
async function main() {
|
|
@@ -179,16 +175,28 @@ async function main() {
|
|
|
179
175
|
writeIfMissing(join(cwd, ".kiro", "settings", "mcp.json"), MCP_CONFIG(apiKey, endpoint), ".kiro/settings/mcp.json");
|
|
180
176
|
writeIfMissing(join(cwd, ".kiro", "steering", "memoryai.md"), STEERING, ".kiro/steering/memoryai.md");
|
|
181
177
|
writeIfMissing(join(cwd, ".kiro", "hooks", "memoryai-auto-recall.kiro.hook"), HOOK_AUTO_RECALL, ".kiro/hooks/memoryai-auto-recall.kiro.hook");
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
178
|
+
// Retire the pre-0.2.4 agentStop hook if it exists. It fired AFTER every
|
|
179
|
+
// turn, forced an askAgent pass that leaked a stray "." into chat, and cost
|
|
180
|
+
// ~1.5 credits per idle turn. Its logic now lives in the auto-recall hook.
|
|
181
|
+
const legacyCapture = join(cwd, ".kiro", "hooks", "memoryai-auto-capture.kiro.hook");
|
|
182
|
+
if (existsSync(legacyCapture)) {
|
|
183
|
+
try {
|
|
184
|
+
rmSync(legacyCapture);
|
|
185
|
+
console.log(" remove .kiro/hooks/memoryai-auto-capture.kiro.hook (retired agentStop hook)");
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
console.log(" warn could not remove legacy memoryai-auto-capture.kiro.hook");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
console.log(`
|
|
192
|
+
Done. MemoryAI now runs automatically — you don't have to do anything.
|
|
193
|
+
- Auto-Recall hook (before each answer) loads memory, persists what matters,
|
|
194
|
+
and runs the context-guard check — all silently.
|
|
195
|
+
|
|
196
|
+
Next steps:
|
|
197
|
+
1. Restart Kiro (loads the MCP server + hook)
|
|
198
|
+
2. Just work normally. Memory persists across sessions on its own.
|
|
199
|
+
3. Optional check: ask "What do you remember about this project?"
|
|
192
200
|
`);
|
|
193
201
|
rl.close();
|
|
194
202
|
}
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "memoryai-mcp",
|
|
3
|
-
"version": "2.4.
|
|
4
|
-
"description": "MCP server for MemoryAI v2.3 — One brain. Every AI you use. Forever. Persistent memory and context guard tools for IDEs and bots.",
|
|
5
|
-
"homepage": "https://memoryai.dev",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/memoryai-dev/memoryai"
|
|
9
|
-
},
|
|
10
|
-
"type": "module",
|
|
11
|
-
"main": "dist/index.js",
|
|
12
|
-
"bin": {
|
|
13
|
-
"memoryai-mcp": "dist/index.js",
|
|
14
|
-
"memoryai-kiro-setup": "dist/kiro-setup.js",
|
|
15
|
-
"memoryai-claude-setup": "dist/claude-setup.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"start": "node dist/index.js",
|
|
20
|
-
"dev": "tsx src/index.ts"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"mcp",
|
|
24
|
-
"memory",
|
|
25
|
-
"ai",
|
|
26
|
-
"llm",
|
|
27
|
-
"context"
|
|
28
|
-
],
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=18.0.0"
|
|
32
|
-
},
|
|
33
|
-
"files": [
|
|
34
|
-
"dist",
|
|
35
|
-
"README.md",
|
|
36
|
-
"LICENSE"
|
|
37
|
-
],
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@modelcontextprotocol/sdk": "^1.12.0"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/node": "^22.19.15",
|
|
43
|
-
"tsx": "^4.0.0",
|
|
44
|
-
"typescript": "^5.5.0"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "memoryai-mcp",
|
|
3
|
+
"version": "2.4.4",
|
|
4
|
+
"description": "MCP server for MemoryAI v2.3 — One brain. Every AI you use. Forever. Persistent memory and context guard tools for IDEs and bots.",
|
|
5
|
+
"homepage": "https://memoryai.dev",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/memoryai-dev/memoryai"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"bin": {
|
|
13
|
+
"memoryai-mcp": "dist/index.js",
|
|
14
|
+
"memoryai-kiro-setup": "dist/kiro-setup.js",
|
|
15
|
+
"memoryai-claude-setup": "dist/claude-setup.js"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"dev": "tsx src/index.ts"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"mcp",
|
|
24
|
+
"memory",
|
|
25
|
+
"ai",
|
|
26
|
+
"llm",
|
|
27
|
+
"context"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.0.0"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.12.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^22.19.15",
|
|
43
|
+
"tsx": "^4.0.0",
|
|
44
|
+
"typescript": "^5.5.0"
|
|
45
|
+
}
|
|
46
|
+
}
|