memoryai-mcp 0.7.0 → 1.5.0

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 CHANGED
@@ -1,31 +1,37 @@
1
1
  # memoryai-mcp
2
2
 
3
- MCP server for [MemoryAI](https://memoryai.dev) — a brain for your AI agent.
3
+ MCP server for [MemoryAI](https://memoryai.dev) — a living brain for your AI agent.
4
4
 
5
- Gives your IDE agent long-term memory that persists across sessions. Memories are processed through 4 stages, just like the human brain:
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
6
11
 
7
- - ⚡ **Instant Recall** What's on the tip of your tongue. Always ready.
8
- - 🔍 **Deep Search** — Scans memory by meaning, not just keywords.
9
- - 🧠 **Reasoning** — Connects the dots across memories, synthesizes precise answers. *(Pro)*
10
- - 📦 **Archive** — Compressed long-term storage. Nothing truly forgotten.
12
+ **Install once. Everything auto from there.**
11
13
 
12
- The more you recall a memory, the stronger it gets. Unused ones gently age — but can always be recovered.
14
+ ## Quick Start (2 minutes)
13
15
 
14
- ## Install
16
+ ### 1. Get an API Key
15
17
 
16
18
  ```bash
17
- npx memoryai-mcp
19
+ curl -X POST https://memoryai.dev/v1/admin/provision \
20
+ -H "Content-Type: application/json" \
21
+ -d '{"name": "my-agent", "tos_accepted": true}'
18
22
  ```
19
23
 
20
- Or install globally:
24
+ Save the `api_key` from the response. You'll need it below.
21
25
 
22
- ```bash
23
- npm install -g memoryai-mcp
24
- ```
26
+ ### 2. Pick Your IDE/Tool
27
+
28
+ Choose your platform below. Config once — memory works automatically forever.
29
+
30
+ ---
25
31
 
26
32
  ## IDE Setup
27
33
 
28
- ### Cursor (`~/.cursor/mcp.json`)
34
+ ### Claude Code (CLI) — `~/.claude/settings.json`
29
35
 
30
36
  ```json
31
37
  {
@@ -42,7 +48,42 @@ npm install -g memoryai-mcp
42
48
  }
43
49
  ```
44
50
 
45
- ### VS Code (`.vscode/mcp.json`)
51
+ Then create `~/.claude/CLAUDE.md` for auto-bootstrap:
52
+
53
+ ```markdown
54
+ ## Memory Protocol
55
+ At the start of every conversation, call `memory_bootstrap` to load context from MemoryAI.
56
+ Before context gets large (>100K tokens), call `memory_compact` to save important context.
57
+ Use `memory_store` to save important decisions, preferences, and facts.
58
+ Use `memory_recall` to search past memories when relevant.
59
+ ```
60
+
61
+ ### Cursor — `~/.cursor/mcp.json`
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "memoryai": {
67
+ "command": "npx",
68
+ "args": ["-y", "memoryai-mcp"],
69
+ "env": {
70
+ "HM_ENDPOINT": "https://memoryai.dev",
71
+ "HM_API_KEY": "hm_sk_your_key_here"
72
+ }
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ Auto-bootstrap — create `.cursor/rules/memoryai.mdc`:
79
+
80
+ ```
81
+ At the start of every session, call memory_bootstrap to load context.
82
+ After completing tasks, call memory_compact to save context.
83
+ Store important decisions and preferences with memory_store.
84
+ ```
85
+
86
+ ### VS Code — `.vscode/mcp.json`
46
87
 
47
88
  ```json
48
89
  {
@@ -59,7 +100,7 @@ npm install -g memoryai-mcp
59
100
  }
60
101
  ```
61
102
 
62
- ### Claude Desktop (`claude_desktop_config.json`)
103
+ ### Kiro `.kiro/settings/mcp.json`
63
104
 
64
105
  ```json
65
106
  {
@@ -76,7 +117,7 @@ npm install -g memoryai-mcp
76
117
  }
77
118
  ```
78
119
 
79
- ### Windsurf (`~/.codeium/windsurf/mcp_config.json`)
120
+ ### Windsurf `~/.codeium/windsurf/mcp_config.json`
80
121
 
81
122
  ```json
82
123
  {
@@ -93,7 +134,10 @@ npm install -g memoryai-mcp
93
134
  }
94
135
  ```
95
136
 
96
- ### Kiro (`.kiro/settings/mcp.json`)
137
+ ### Claude Desktop — `claude_desktop_config.json`
138
+
139
+ macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
140
+ Windows: `%APPDATA%\Claude\claude_desktop_config.json`
97
141
 
98
142
  ```json
99
143
  {
@@ -110,60 +154,149 @@ npm install -g memoryai-mcp
110
154
  }
111
155
  ```
112
156
 
113
- ### OpenClaw (`openclaw.yaml`)
157
+ ### Antigravity — `~/.antigravity/mcp.json`
114
158
 
115
- ```yaml
116
- mcp:
117
- servers:
118
- memoryai:
119
- command: npx
120
- args: ["-y", "memoryai-mcp"]
121
- env:
122
- HM_ENDPOINT: "https://memoryai.dev"
123
- HM_API_KEY: "hm_sk_..."
159
+ ```json
160
+ {
161
+ "mcpServers": {
162
+ "memoryai": {
163
+ "command": "npx",
164
+ "args": ["-y", "memoryai-mcp"],
165
+ "env": {
166
+ "HM_ENDPOINT": "https://memoryai.dev",
167
+ "HM_API_KEY": "hm_sk_your_key_here"
168
+ }
169
+ }
170
+ }
171
+ }
124
172
  ```
125
173
 
126
- ## Tools
174
+ ### Any MCP-compatible tool
127
175
 
128
- | Tool | Description |
129
- |------|-------------|
130
- | `memory_bootstrap` | Load context at session start — wake up with full memory |
131
- | `memory_store` | Store information in persistent memory |
132
- | `memory_recall` | Search memories by semantic query |
133
- | `memory_compact` | Consolidate context into key memories (like brain during sleep) |
134
- | `memory_recover` | Recover session context after a break |
135
- | `memory_health` | Check how full your working memory is |
136
- | `memory_explore` | Explore connections between memories |
137
- | `memory_clusters` | View topic clusters |
138
- | `learn` | Store action + result + lesson |
139
- | `entity_list` | List tracked entities (files, people, packages) |
140
- | `reasoning_store/recall` | Deep reasoning memory (Pro+) |
141
- | `snapshot_create/restore` | Backup and restore memory state |
176
+ ```json
177
+ {
178
+ "mcpServers": {
179
+ "memoryai": {
180
+ "command": "npx",
181
+ "args": ["-y", "memoryai-mcp"],
182
+ "env": {
183
+ "HM_ENDPOINT": "https://memoryai.dev",
184
+ "HM_API_KEY": "hm_sk_your_key_here"
185
+ }
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Auto-Bootstrap (Make It Fully Automatic)
142
194
 
143
- ## Auto-Bootstrap
195
+ After MCP config, add a system rule so your agent auto-loads memory every session:
144
196
 
145
- Add to your project rules so the agent auto-loads memory each session:
197
+ | Platform | Rule File | Content |
198
+ |----------|-----------|---------|
199
+ | Claude Code | `~/.claude/CLAUDE.md` | See above |
200
+ | Cursor | `.cursor/rules/memoryai.mdc` | See above |
201
+ | Kiro | `.kiro/rules/memoryai.md` | Same content |
202
+ | Windsurf | `.windsurfrules` | Same content |
203
+ | VS Code | `.github/copilot-instructions.md` | Same content |
204
+
205
+ Rule content (copy-paste for any platform):
146
206
 
147
- **Cursor** (`.cursor/rules/memoryai.mdc`):
148
207
  ```
149
- At the start of every session, call memory_bootstrap to load context.
150
- After completing tasks, call memory_compact to save context.
208
+ ## Memory Protocol
209
+ At the start of every conversation, call `memory_bootstrap` to load context from MemoryAI.
210
+ Before context gets large, call `memory_compact` to save important context.
211
+ Use `memory_store` to save important decisions, preferences, and facts.
212
+ Use `memory_recall` to search past memories when relevant.
151
213
  ```
152
214
 
153
- ## Get an API Key
215
+ ---
154
216
 
155
- ```bash
156
- curl -X POST https://memoryai.dev/v1/admin/provision \
157
- -H "Content-Type: application/json" \
158
- -d '{"name": "my-agent", "tos_accepted": true}'
217
+ ## How It Works
218
+
219
+ ```
220
+ Open IDE → MCP auto-connects Agent reads rules → Calls bootstrap
221
+ → Loads your identity, preferences, recent work
222
+ → Works normally (auto-stores important stuff)
223
+ → Context getting full? Auto-compacts
224
+ → Close IDE → Sleep workers consolidate overnight
225
+ → Open IDE next day → Bootstrap loads everything back
226
+ → Cycle repeats. Memory grows smarter over time.
159
227
  ```
160
228
 
161
- Or visit https://memoryai.dev to create one instantly.
229
+ **You do nothing.** The agent handles everything automatically.
230
+
231
+ ---
232
+
233
+ ## Tools Available
234
+
235
+ | Tool | What It Does |
236
+ |------|-------------|
237
+ | `memory_bootstrap` | Wake up with full context (identity + recent + preferences) |
238
+ | `memory_store` | Save a memory (fact, decision, preference, identity) |
239
+ | `memory_recall` | Search memories by meaning (semantic + graph + FTS) |
240
+ | `memory_compact` | Save conversation context before it's lost |
241
+ | `memory_recover` | Recover session after a break |
242
+ | `memory_health` | Check context pressure (safe/warning/critical) |
243
+ | `memory_explore` | Explore connections between memories |
244
+ | `memory_clusters` | View topic clusters in your knowledge graph |
245
+ | `learn` | Store action + result + lesson learned |
246
+ | `entity_list` | List tracked entities (files, people, packages) |
247
+ | `reasoning_store` | Deep reasoning memory (Pro+) |
248
+ | `reasoning_recall` | Recall reasoned insights (Pro+) |
249
+ | `snapshot_create` | Backup memory state |
250
+ | `snapshot_restore` | Restore from backup |
251
+
252
+ ---
253
+
254
+ ## Context Guard (Built-in)
255
+
256
+ Context Guard monitors your session and prevents context loss:
257
+
258
+ | State | Meaning | Agent Action |
259
+ |-------|---------|-------------|
260
+ | SAFE | Context < 40% full | Continue normally |
261
+ | COMPACT_SOON | Context 40-55% full | Prepare to compact |
262
+ | COMPACT_NOW | Context > 55% full | Must compact immediately |
263
+
264
+ The agent handles this automatically when rules are configured. No manual intervention needed.
265
+
266
+ ---
267
+
268
+ ## What Gets Remembered (DNA System)
269
+
270
+ | Memory Type | Example | Persistence |
271
+ |-------------|---------|-------------|
272
+ | `preference` | "I prefer Python over Java" | **Forever** (DNA-protected) |
273
+ | `decision` | "Chose PostgreSQL for this project" | **Forever** (DNA-protected) |
274
+ | `identity` | "Senior backend engineer, 10 years" | **Forever** (DNA-protected) |
275
+ | `fact` | "API endpoint is /v1/users" | Decays if unused |
276
+ | `goal` | "Launch v2.0 by June" | Decays if unused |
277
+
278
+ DNA memories (preference/decision/identity) **never decay, never get deleted, never get overwritten** by any background process. They define who you are.
279
+
280
+ ---
281
+
282
+ ## Pricing
283
+
284
+ | Plan | Features | Price |
285
+ |------|----------|-------|
286
+ | Free | Basic store/recall, 100 memories | Free |
287
+ | Pro | Full brain (reasoning, consolidation, personality) | Paid |
288
+ | ProMax | Multi-agent mesh, advanced features | Paid |
289
+ | God | Everything + deep graph traversal | Internal |
290
+
291
+ Get started free: https://memoryai.dev
292
+
293
+ ---
162
294
 
163
295
  ## Links
164
296
 
165
297
  - Website: https://memoryai.dev
166
- - Python SDK: https://pypi.org/project/hmc-memory/
298
+ - Python SDK: `pip install hmc-memory`
299
+ - npm MCP: `npx memoryai-mcp`
167
300
  - GitHub: https://github.com/memoryai-dev/memoryai
168
301
 
169
302
  ## License
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ function err(e) {
36
36
  return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
37
37
  }
38
38
  // --- MCP Server ---
39
- const server = new McpServer({ name: "memoryai", version: "0.5.0" }, { capabilities: { tools: {} } });
39
+ const server = new McpServer({ name: "memoryai", version: "0.9.0" }, { capabilities: { tools: {} } });
40
40
  // 1. memory_store
41
41
  server.tool("memory_store", "Store information in persistent memory. Use when you learn something important — project context, user preferences, architectural decisions, patterns, or bugs.", {
42
42
  content: z.string().describe("What to remember"),
@@ -800,6 +800,76 @@ server.tool("session_handoff_status", "Check current session handoff status —
800
800
  return err(e);
801
801
  }
802
802
  });
803
+ // ─── Context Guard v6 Tools ─────────────────────────────────────────
804
+ // context_guard_check — universal guard check with DNA count
805
+ server.tool("context_guard_check", "Check context window health using Context Guard v6 — dynamic thresholds, DNA memory count, bootstrap readiness. Replaces memory_health with richer data.", {
806
+ estimated_tokens: z.number().describe("Current token count in context window"),
807
+ max_tokens: z.number().optional().describe("Max context window size (auto-detected from model if omitted)"),
808
+ model: z.string().optional().describe("Model name for auto-detecting context window size (e.g. claude-sonnet-4-6)"),
809
+ }, async (args) => {
810
+ try {
811
+ const r = (await api("POST", "/v1/context/guard/check", {
812
+ estimated_tokens: args.estimated_tokens,
813
+ max_tokens: args.max_tokens || 0,
814
+ model: args.model || null,
815
+ }));
816
+ const pct = r.usage_percent;
817
+ const barLen = 20;
818
+ const filled = Math.round(pct / 100 * barLen);
819
+ const bar = "\u2588".repeat(filled) + "\u2591".repeat(barLen - filled);
820
+ return ok(`Context Guard v6:\n` +
821
+ `[${bar}] ${pct.toFixed(1)}%\n` +
822
+ `Recommendation: ${r.recommendation.toUpperCase()}${r.should_compact ? " — compact now" : ""}\n` +
823
+ `Urgency: ${r.urgency}\n` +
824
+ `Thresholds: compact=${r.compact_at_tokens.toLocaleString()}, critical=${r.critical_at_tokens.toLocaleString()}\n` +
825
+ `DNA memories: ${r.dna_memories} | Hot: ${r.hot_memories} | Stale: ${r.stale_memories}\n` +
826
+ `Bootstrap ready: ${r.bootstrap_ready ? "yes" : "no"}\n` +
827
+ (r.last_compact_minutes_ago != null ? `Last compact: ${r.last_compact_minutes_ago.toFixed(0)} min ago` : "No compacts yet"));
828
+ }
829
+ catch (e) {
830
+ return err(e);
831
+ }
832
+ });
833
+ // context_guard_compact — compact with DNA protection
834
+ server.tool("context_guard_compact", "Compact session context with DNA protection — DNA memories are never overwritten. Returns task_id for async polling or result for blocking mode.", {
835
+ content: z.string().describe("Session transcript or content to compact"),
836
+ task_context: z.string().optional().describe("Task description for tagging"),
837
+ blocking: z.boolean().optional().describe("Wait for result (true) or return task_id (false, default)"),
838
+ }, async (args) => {
839
+ try {
840
+ const r = (await api("POST", "/v1/context/guard/compact", {
841
+ content: args.content,
842
+ task_context: args.task_context || null,
843
+ blocking: args.blocking || false,
844
+ }));
845
+ if (r.status === "queued") {
846
+ return ok(`Compact queued (task_id=${r.task_id}). Poll with guard_status.`);
847
+ }
848
+ return ok(`Compact ${r.status}: ${r.chunks_created} chunks stored, ${r.chunks_deduplicated} deduplicated.\n` +
849
+ r.message);
850
+ }
851
+ catch (e) {
852
+ return err(e);
853
+ }
854
+ });
855
+ // context_guard_bootstrap — DNA-first session bootstrap
856
+ server.tool("context_guard_bootstrap", "Bootstrap a new session with DNA-first context — identity/preferences first, then recent activity, then task-relevant memories.", {
857
+ task: z.string().describe("Task description for the new session"),
858
+ limit: z.number().optional().describe("Max memories to include (default: 10)"),
859
+ }, async (args) => {
860
+ try {
861
+ const r = (await api("POST", "/v1/context/guard/bootstrap", {
862
+ task: args.task,
863
+ limit: args.limit || 10,
864
+ }));
865
+ return ok(`Bootstrap complete: ${r.memories_restored} memories (${r.dna_memories} DNA)\n` +
866
+ `Tokens used: ${r.tokens_used}\n\n` +
867
+ r.context_block);
868
+ }
869
+ catch (e) {
870
+ return err(e);
871
+ }
872
+ });
803
873
  async function main() {
804
874
  const transport = new StdioServerTransport();
805
875
  await server.connect(transport);
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * memoryai-kiro-setup
4
+ * Zero-dependency setup script that creates .kiro/settings/mcp.json
5
+ * and .kiro/steering/memoryai.md in the current project directory.
6
+ */
7
+ export {};
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * memoryai-kiro-setup
4
+ * Zero-dependency setup script that creates .kiro/settings/mcp.json
5
+ * and .kiro/steering/memoryai.md in the current project directory.
6
+ */
7
+ import { createInterface } from "node:readline";
8
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
9
+ import { join } from "node:path";
10
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
11
+ function ask(question, fallback) {
12
+ const suffix = fallback ? ` [${fallback}]` : "";
13
+ return new Promise((resolve) => {
14
+ rl.question(`${question}${suffix}: `, (answer) => {
15
+ resolve(answer.trim() || fallback || "");
16
+ });
17
+ });
18
+ }
19
+ function writeIfMissing(filePath, content, label) {
20
+ if (existsSync(filePath)) {
21
+ console.log(` skip ${label} (already exists)`);
22
+ return false;
23
+ }
24
+ const dir = filePath.substring(0, filePath.lastIndexOf("/"));
25
+ mkdirSync(dir, { recursive: true });
26
+ writeFileSync(filePath, content, "utf-8");
27
+ console.log(` create ${label}`);
28
+ return true;
29
+ }
30
+ const MCP_CONFIG = (apiKey, endpoint) => JSON.stringify({
31
+ mcpServers: {
32
+ memoryai: {
33
+ command: "npx",
34
+ args: ["-y", "memoryai-mcp"],
35
+ env: {
36
+ HM_API_KEY: apiKey,
37
+ HM_ENDPOINT: endpoint,
38
+ },
39
+ },
40
+ },
41
+ }, null, 2) + "\n";
42
+ const STEERING = `---
43
+ inclusion: always
44
+ ---
45
+
46
+ # MemoryAI — Persistent Memory Instructions
47
+
48
+ You have access to MemoryAI tools via MCP. Use them to maintain long-term memory across sessions.
49
+
50
+ ## Session Start
51
+
52
+ Call \`memory_bootstrap\` at the beginning of every session to load prior context.
53
+ If bootstrap returns nothing, call \`memory_recover\` to check for recent session state.
54
+
55
+ ## During Work
56
+
57
+ - Before answering questions about past decisions, architecture, or preferences: call \`memory_recall\` with a relevant query.
58
+ - After making a significant decision, completing a task, or learning something about the codebase: call \`memory_store\` with appropriate \`memory_type\`:
59
+ - \`decision\` — architectural or technical decisions (DNA-protected, never decays)
60
+ - \`preference\` — user preferences and conventions (DNA-protected, never decays)
61
+ - \`fact\` — codebase facts, API details, configs
62
+ - \`error\` — lessons learned from mistakes
63
+ - \`goal\` — current objectives and milestones
64
+ - After learning from a mistake or unexpected result: call \`learn\` with action, result, and lesson fields.
65
+
66
+ ## Entity Tracking
67
+
68
+ When you create, modify, or reference important files, packages, or people:
69
+ 1. Call \`entity_list\` to check if already tracked
70
+ 2. If not tracked, call \`memory_store\` with \`memory_type=entity\`
71
+
72
+ ## Memory Health
73
+
74
+ If a session is running long, call \`memory_health\` to check working memory usage.
75
+ If above 80%, call \`memory_compact\` proactively to consolidate context.
76
+
77
+ ## Session End
78
+
79
+ When wrapping up or when the agent is about to stop:
80
+ 1. Call \`memory_compact\` to consolidate the session's context into durable memories
81
+ 2. Call \`memory_store\` with a brief summary of what was accomplished
82
+
83
+ ## Rules
84
+
85
+ - Recall only when past context is actually needed — not on every message
86
+ - Store important outcomes after completing tasks, not after every interaction
87
+ - Present memories naturally — integrate recalled info into responses, don't show raw API output
88
+ - Use \`zone: "critical"\` for decisions that must never be forgotten
89
+ - Use \`retention: "forever"\` for permanent project knowledge
90
+ `;
91
+ async function main() {
92
+ const cwd = process.cwd();
93
+ console.log(`\nMemoryAI Kiro Setup`);
94
+ console.log(`Project: ${cwd}\n`);
95
+ const apiKey = process.env.HM_API_KEY || (await ask("MemoryAI API key (hm_sk_...)"));
96
+ if (!apiKey) {
97
+ console.error("Error: API key is required. Set HM_API_KEY or enter it above.");
98
+ process.exit(1);
99
+ }
100
+ const endpoint = await ask("Endpoint", process.env.HM_ENDPOINT || "https://memoryai.dev");
101
+ console.log("");
102
+ writeIfMissing(join(cwd, ".kiro", "settings", "mcp.json"), MCP_CONFIG(apiKey, endpoint), ".kiro/settings/mcp.json");
103
+ writeIfMissing(join(cwd, ".kiro", "steering", "memoryai.md"), STEERING, ".kiro/steering/memoryai.md");
104
+ console.log(`
105
+ Done. Next steps:
106
+ 1. Restart Kiro
107
+ 2. Ask: "What do you remember about this project?"
108
+ 3. The agent should call memory_bootstrap automatically
109
+ `);
110
+ rl.close();
111
+ }
112
+ main().catch((err) => {
113
+ console.error(err);
114
+ process.exit(1);
115
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memoryai-mcp",
3
- "version": "0.7.0",
4
- "description": "MCP server for MemoryAI v0.7 — Brain with 11 biological behaviors. DNA-protected memories (preference/decision/identity), Hebbian learning, Sleep consolidation.",
3
+ "version": "1.5.0",
4
+ "description": "MCP server for MemoryAI v1.5Living Brain for AI Agents. 5 biological behaviors (Remember, Forget, Connect, Sleep, Shield), DNA-protected memories, Hebbian learning, Multi-Agent Mesh, Personality synthesis, Causal reasoning.",
5
5
  "homepage": "https://memoryai.dev",
6
6
  "repository": {
7
7
  "type": "git",
@@ -10,7 +10,8 @@
10
10
  "type": "module",
11
11
  "main": "dist/index.js",
12
12
  "bin": {
13
- "memoryai-mcp": "dist/index.js"
13
+ "memoryai-mcp": "dist/index.js",
14
+ "memoryai-kiro-setup": "dist/kiro-setup.js"
14
15
  },
15
16
  "scripts": {
16
17
  "build": "tsc",