project-memory-mcp 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,MAAM,EACN,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAItB,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IAC9C,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,QAAgB;IAC5C,IAAI,CAAC;QACH,8CAA8C;QAC9C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC7C,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,GAAG,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,QAAgB;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAEpC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,QAAQ,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c,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,GAAG,cAAc,OAAO,CAAC;IAE1C,MAAM,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAEvC,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;QACtE,IAAI,OAAO,EAAE,CAAC;YACZ,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;YACnC,KAAK,CAAC,QAAQ,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC3C,MAAM,eAAe,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;IAChD,CAAC;YAAS,CAAC;QACT,MAAM,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
@@ -0,0 +1,392 @@
1
+ import { z } from "zod";
2
+ import { newId, normalizeTags, safeSnippet, scoreItem, tokenize, validateType, } from "./domain.js";
3
+ import { autoCompactStore, compactStoreInPlace } from "./maintenance.js";
4
+ import { withStore } from "./storage.js";
5
+ import { nowIso } from "./runtime.js";
6
+ const projectRootInput = z
7
+ .string()
8
+ .min(1)
9
+ .optional()
10
+ .describe("Target project root path. Use this when server is shared across multiple projects.");
11
+ function storeOptions(projectRoot) {
12
+ return projectRoot ? { projectRoot } : undefined;
13
+ }
14
+ const HELP_TEXT = `
15
+ Project Memory MCP quick help
16
+
17
+ Common prompts:
18
+ - Call memory_status and show the output. → confirms project + .ai path.
19
+ - Call memory_get_bundle with {"prompt":"<your task>"} → load context.
20
+ - When you finish work, Call memory_save with {"title":"...", "content":"...", "tags":["..."], "source":"claude"} → saves the new fact/decision immediately.
21
+ - Prefer approvals? Call memory_propose with {"items":[...]} then memory_approve_proposal.
22
+ - Need to find info later? Call memory_search with {"query":"...", "includeContent":true}.
23
+ - Keep the store lean: Call memory_compact with {"maxItems":250} (archives oldest items).
24
+
25
+ Every tool accepts optional projectRoot. More details: README.md or docs/LOCAL_SETUP.md.
26
+ `.trim();
27
+ export function registerTools(server) {
28
+ server.registerTool("memory_help", {
29
+ description: "Show quick-start instructions and sample prompts for all memory tools.",
30
+ inputSchema: {},
31
+ }, async () => ({
32
+ content: [{ type: "text", text: HELP_TEXT }],
33
+ }));
34
+ server.registerTool("memory_status", {
35
+ description: "Show which project root and memory file this server call resolves to.",
36
+ inputSchema: {
37
+ projectRoot: projectRootInput,
38
+ },
39
+ }, async ({ projectRoot }) => {
40
+ const { store, projectRoot: resolvedProjectRoot, memoryFilePath } = await withStore(async () => false, storeOptions(projectRoot));
41
+ const status = {
42
+ projectRoot: resolvedProjectRoot,
43
+ memoryFilePath,
44
+ revision: store.revision || 0,
45
+ counts: {
46
+ items: Array.isArray(store.items) ? store.items.length : 0,
47
+ proposals: Array.isArray(store.proposals) ? store.proposals.length : 0,
48
+ },
49
+ };
50
+ return {
51
+ content: [{ type: "text", text: JSON.stringify(status, null, 2) }],
52
+ };
53
+ });
54
+ server.registerTool("memory_search", {
55
+ description: "Search project memory items by keyword and/or tags (approved items only).",
56
+ inputSchema: {
57
+ query: z.string().min(1).describe("Keyword query (case-insensitive)"),
58
+ limit: z.number().int().min(1).max(50).default(10),
59
+ types: z.array(z.string()).optional().describe("Filter by item types"),
60
+ tags: z.array(z.string()).optional().describe("Filter by tags"),
61
+ includeContent: z.boolean().default(false).describe("Include full content"),
62
+ projectRoot: projectRootInput,
63
+ },
64
+ }, async ({ query, limit, types, tags, includeContent, projectRoot }) => {
65
+ const queryTokens = tokenize(query);
66
+ const tagTokens = normalizeTags(tags);
67
+ const typeSet = types?.length
68
+ ? new Set(types.map((t) => validateType(t)))
69
+ : null;
70
+ const { store } = await withStore(async () => false, storeOptions(projectRoot));
71
+ const matches = store.items
72
+ .filter((it) => (typeSet ? typeSet.has(validateType(it.type)) : true))
73
+ .map((it) => ({
74
+ item: it,
75
+ score: scoreItem(it, queryTokens, tagTokens),
76
+ }))
77
+ .filter((x) => x.score > 0)
78
+ .sort((a, b) => b.score - a.score)
79
+ .slice(0, limit)
80
+ .map(({ item, score }) => ({
81
+ id: item.id,
82
+ type: item.type,
83
+ title: item.title,
84
+ tags: item.tags || [],
85
+ pinned: Boolean(item.pinned),
86
+ createdAt: item.createdAt,
87
+ updatedAt: item.updatedAt,
88
+ score,
89
+ snippet: safeSnippet(item.content),
90
+ ...(includeContent ? { content: String(item.content || "") } : {}),
91
+ }));
92
+ return {
93
+ content: [
94
+ {
95
+ type: "text",
96
+ text: JSON.stringify({ count: matches.length, results: matches }, null, 2),
97
+ },
98
+ ],
99
+ };
100
+ });
101
+ server.registerTool("memory_get_bundle", {
102
+ description: "Build a compact, ranked context bundle from project memory for the current task.",
103
+ inputSchema: {
104
+ prompt: z.string().min(1).describe("What are you working on right now?"),
105
+ maxItems: z.number().int().min(1).max(50).default(12),
106
+ maxChars: z.number().int().min(500).max(20000).default(6000),
107
+ types: z.array(z.string()).optional().describe("Filter by item types"),
108
+ includePinned: z.boolean().default(true),
109
+ projectRoot: projectRootInput,
110
+ },
111
+ }, async ({ prompt, maxItems, maxChars, types, includePinned, projectRoot }) => {
112
+ const queryTokens = tokenize(prompt);
113
+ const typeSet = types?.length
114
+ ? new Set(types.map((t) => validateType(t)))
115
+ : null;
116
+ const { store } = await withStore(async () => false, storeOptions(projectRoot));
117
+ const candidates = store.items.filter((it) => typeSet ? typeSet.has(validateType(it.type)) : true);
118
+ const pinned = includePinned ? candidates.filter((x) => x.pinned) : [];
119
+ const rest = candidates
120
+ .filter((x) => !x.pinned)
121
+ .map((it) => ({ item: it, score: scoreItem(it, queryTokens, []) }))
122
+ .filter((x) => x.score > 0)
123
+ .sort((a, b) => b.score - a.score)
124
+ .map((x) => x.item);
125
+ const chosen = [...pinned, ...rest].slice(0, maxItems);
126
+ let out = "# Project Memory Bundle\n\n";
127
+ out += `Generated: ${nowIso()}\n`;
128
+ out += `Items: ${chosen.length}\n\n`;
129
+ for (const it of chosen) {
130
+ const header = `- [${it.id}] (${it.type}${it.pinned ? ", pinned" : ""}) ${it.title || ""}`.trim();
131
+ const body = safeSnippet(it.content, 800);
132
+ const line = `${header}\n ${body}\n`;
133
+ if (out.length + line.length > maxChars)
134
+ break;
135
+ out += `${line}\n`;
136
+ }
137
+ if (!chosen.length) {
138
+ out += "_No matching memory yet. Use `memory_propose` to add project decisions/constraints._\n";
139
+ }
140
+ return { content: [{ type: "text", text: out }] };
141
+ });
142
+ server.registerTool("memory_propose", {
143
+ description: "Propose new project memory items (pending approval). Use this for new decisions/constraints/facts you want persisted for this project.",
144
+ inputSchema: {
145
+ items: z
146
+ .array(z.object({
147
+ type: z.string().optional().describe("note|decision|fact|constraint|todo|architecture|glossary"),
148
+ title: z.string().min(1),
149
+ content: z.string().min(1),
150
+ tags: z.array(z.string()).optional(),
151
+ pinned: z.boolean().optional(),
152
+ }))
153
+ .min(1)
154
+ .max(25),
155
+ reason: z.string().optional().describe("Why this should be saved"),
156
+ projectRoot: projectRootInput,
157
+ },
158
+ }, async ({ items, reason, projectRoot }) => {
159
+ const createdAt = nowIso();
160
+ const proposalIds = [];
161
+ await withStore(async (st) => {
162
+ for (const raw of items) {
163
+ const proposal = {
164
+ id: newId("prop"),
165
+ type: validateType(raw.type),
166
+ title: String(raw.title).trim(),
167
+ content: String(raw.content).trim(),
168
+ tags: normalizeTags(raw.tags),
169
+ pinned: Boolean(raw.pinned),
170
+ status: "pending",
171
+ createdAt,
172
+ updatedAt: createdAt,
173
+ reason: reason ? String(reason).trim() : "",
174
+ };
175
+ st.proposals.push(proposal);
176
+ proposalIds.push(proposal.id);
177
+ }
178
+ return true;
179
+ }, storeOptions(projectRoot));
180
+ const text = `Proposals created (${proposalIds.length}).\n` +
181
+ "Next: review + approve with memory_list_proposals / memory_approve_proposal.\n" +
182
+ `Proposal IDs: ${proposalIds.join(", ")}`;
183
+ return { content: [{ type: "text", text }] };
184
+ });
185
+ server.registerTool("memory_save", {
186
+ description: "Save a memory item directly (no approval step). Use this for finalized context after code changes.",
187
+ inputSchema: {
188
+ type: z
189
+ .string()
190
+ .optional()
191
+ .describe("note|decision|fact|constraint|todo|architecture|glossary"),
192
+ title: z.string().min(1),
193
+ content: z.string().min(1),
194
+ tags: z.array(z.string()).optional(),
195
+ pinned: z.boolean().optional(),
196
+ source: z.string().optional().describe("e.g. claude|codex|gemini"),
197
+ projectRoot: projectRootInput,
198
+ },
199
+ }, async ({ type, title, content, tags, pinned, source, projectRoot }) => {
200
+ const createdAt = nowIso();
201
+ let itemId = "";
202
+ await withStore(async (st, ctx) => {
203
+ const item = {
204
+ id: newId("mem"),
205
+ type: validateType(type),
206
+ title: String(title).trim(),
207
+ content: String(content).trim(),
208
+ tags: normalizeTags(tags),
209
+ pinned: Boolean(pinned),
210
+ createdAt,
211
+ updatedAt: createdAt,
212
+ lastUsedAt: createdAt,
213
+ source: source ? String(source).trim() : "direct",
214
+ };
215
+ st.items.push(item);
216
+ itemId = item.id;
217
+ await autoCompactStore(st, ctx);
218
+ return true;
219
+ }, storeOptions(projectRoot));
220
+ return { content: [{ type: "text", text: `Saved memory item ${itemId}` }] };
221
+ });
222
+ server.registerTool("memory_list_proposals", {
223
+ description: "List pending memory proposals for this project.",
224
+ inputSchema: {
225
+ limit: z.number().int().min(1).max(100).default(20),
226
+ status: z.enum(["pending", "approved", "rejected"]).default("pending"),
227
+ includeContent: z.boolean().default(false),
228
+ projectRoot: projectRootInput,
229
+ },
230
+ }, async ({ limit, status, includeContent, projectRoot }) => {
231
+ const { store } = await withStore(async () => false, storeOptions(projectRoot));
232
+ const proposals = store.proposals
233
+ .filter((p) => (status ? p.status === status : true))
234
+ .slice(-limit)
235
+ .map((p) => ({
236
+ id: p.id,
237
+ status: p.status,
238
+ type: p.type,
239
+ title: p.title,
240
+ tags: p.tags || [],
241
+ pinned: Boolean(p.pinned),
242
+ createdAt: p.createdAt,
243
+ updatedAt: p.updatedAt,
244
+ reason: p.reason || "",
245
+ snippet: safeSnippet(p.content),
246
+ ...(includeContent ? { content: String(p.content || "") } : {}),
247
+ }));
248
+ return {
249
+ content: [
250
+ {
251
+ type: "text",
252
+ text: JSON.stringify({ count: proposals.length, proposals }, null, 2),
253
+ },
254
+ ],
255
+ };
256
+ });
257
+ server.registerTool("memory_approve_proposal", {
258
+ description: "Approve or reject a memory proposal. Approving persists it as a project memory item.",
259
+ inputSchema: {
260
+ proposalId: z.string().min(1),
261
+ action: z.enum(["approve", "reject"]),
262
+ edits: z
263
+ .object({
264
+ type: z.string().optional(),
265
+ title: z.string().optional(),
266
+ content: z.string().optional(),
267
+ tags: z.array(z.string()).optional(),
268
+ pinned: z.boolean().optional(),
269
+ })
270
+ .optional()
271
+ .describe("Optional edits before approval/rejection"),
272
+ projectRoot: projectRootInput,
273
+ },
274
+ }, async ({ proposalId, action, edits, projectRoot }) => {
275
+ const decidedAt = nowIso();
276
+ let resultText = "";
277
+ await withStore(async (st, ctx) => {
278
+ const p = st.proposals.find((x) => x.id === proposalId);
279
+ if (!p) {
280
+ resultText = `Proposal not found: ${proposalId}`;
281
+ return false;
282
+ }
283
+ if (p.status !== "pending") {
284
+ resultText = `Proposal ${proposalId} is already ${p.status}`;
285
+ return false;
286
+ }
287
+ if (edits) {
288
+ if (edits.type)
289
+ p.type = validateType(edits.type);
290
+ if (typeof edits.title === "string")
291
+ p.title = edits.title.trim();
292
+ if (typeof edits.content === "string")
293
+ p.content = edits.content.trim();
294
+ if (edits.tags)
295
+ p.tags = normalizeTags(edits.tags);
296
+ if (typeof edits.pinned === "boolean")
297
+ p.pinned = edits.pinned;
298
+ }
299
+ p.status = action === "approve" ? "approved" : "rejected";
300
+ p.updatedAt = decidedAt;
301
+ if (action === "approve") {
302
+ const item = {
303
+ id: newId("mem"),
304
+ type: p.type,
305
+ title: p.title,
306
+ content: p.content,
307
+ tags: p.tags || [],
308
+ pinned: Boolean(p.pinned),
309
+ createdAt: decidedAt,
310
+ updatedAt: decidedAt,
311
+ lastUsedAt: decidedAt,
312
+ source: "proposal",
313
+ proposalId: p.id,
314
+ };
315
+ st.items.push(item);
316
+ await autoCompactStore(st, ctx);
317
+ resultText = `Approved ${proposalId} -> saved as item ${item.id}`;
318
+ }
319
+ else {
320
+ resultText = `Rejected ${proposalId}`;
321
+ }
322
+ return true;
323
+ }, storeOptions(projectRoot));
324
+ return { content: [{ type: "text", text: resultText }] };
325
+ });
326
+ server.registerTool("memory_pin", {
327
+ description: "Pin or unpin an existing memory item.",
328
+ inputSchema: {
329
+ itemId: z.string().min(1),
330
+ pinned: z.boolean(),
331
+ projectRoot: projectRootInput,
332
+ },
333
+ }, async ({ itemId, pinned, projectRoot }) => {
334
+ let msg = "";
335
+ await withStore(async (st) => {
336
+ const it = st.items.find((x) => x.id === itemId);
337
+ if (!it) {
338
+ msg = `Item not found: ${itemId}`;
339
+ return false;
340
+ }
341
+ it.pinned = Boolean(pinned);
342
+ it.updatedAt = nowIso();
343
+ msg = `${pinned ? "Pinned" : "Unpinned"} ${itemId}`;
344
+ return true;
345
+ }, storeOptions(projectRoot));
346
+ return { content: [{ type: "text", text: msg }] };
347
+ });
348
+ server.registerTool("memory_compact", {
349
+ description: "Archive older memory items into a separate file and add a summary entry to keep the main store small.",
350
+ inputSchema: {
351
+ maxItems: z
352
+ .number()
353
+ .int()
354
+ .min(10)
355
+ .max(2000)
356
+ .optional()
357
+ .describe("Maximum items to keep active after compaction."),
358
+ archivePath: z
359
+ .string()
360
+ .optional()
361
+ .describe("Optional override archive file path (default .ai/memory-archive.json)."),
362
+ summaryTitle: z.string().optional(),
363
+ summaryTags: z.array(z.string()).optional(),
364
+ summaryMaxEntries: z
365
+ .number()
366
+ .int()
367
+ .min(1)
368
+ .max(100)
369
+ .optional()
370
+ .describe("How many archived items to list in the summary body."),
371
+ projectRoot: projectRootInput,
372
+ },
373
+ }, async ({ maxItems, archivePath, summaryTitle, summaryTags, summaryMaxEntries, projectRoot, }) => {
374
+ let result = { archived: 0 };
375
+ await withStore(async (st, ctx) => {
376
+ result = await compactStoreInPlace(st, ctx, {
377
+ maxItems,
378
+ archivePath,
379
+ summaryTitle,
380
+ summaryTags,
381
+ summaryMaxEntries,
382
+ reason: "manual",
383
+ });
384
+ return result.archived > 0;
385
+ }, storeOptions(projectRoot));
386
+ const text = result.archived > 0
387
+ ? `Archived ${result.archived} item(s) into ${result.archivePath}`
388
+ : "No compaction needed (store below threshold).";
389
+ return { content: [{ type: "text", text }] };
390
+ });
391
+ }
392
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,KAAK,EACL,aAAa,EACb,WAAW,EACX,SAAS,EACT,QAAQ,EACR,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,MAAM,gBAAgB,GAAG,CAAC;KACvB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,QAAQ,EAAE;KACV,QAAQ,CAAC,oFAAoF,CAAC,CAAC;AAElG,SAAS,YAAY,CAAC,WAAoB;IACxC,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC;AAED,MAAM,SAAS,GAAG;;;;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@@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,223 @@
1
+ # Project Memory MCP Server – Local Setup
2
+
3
+ This guide walks through installing the server, wiring it into each CLI, and confirming `memory_get_bundle` / `memory_save` work end-to-end on your machine.
4
+
5
+ ## 1. Requirements
6
+
7
+ - Node.js 18+ on PATH (`node -v`)
8
+ - This repo cloned locally (example path: `/Users/itsupport4/Documents/project-memory-mcp-js`)
9
+ - Target project(s) checked out locally (each one gets its own `.ai/memory.json`)
10
+
11
+ ## 2. Choose your install path
12
+
13
+ Pick the path that fits your workflow:
14
+
15
+ ### Option A – Global CLI (one-time install)
16
+
17
+ ```bash
18
+ npm install -g project-memory-mcp
19
+ project-memory-mcp setup
20
+ ```
21
+
22
+ CLI clients will call the globally installed binary (`project-memory-mcp`). Recommended for most developers.
23
+
24
+ ### Option B – On-demand via npx (no install)
25
+
26
+ ```bash
27
+ npx project-memory-mcp setup
28
+ ```
29
+
30
+ Great for quickly wiring a single machine—you always get the published build without keeping a copy in your repo.
31
+
32
+ ### Option C – Project dependency (package.json)
33
+
34
+ ```bash
35
+ npm install --save-dev project-memory-mcp # inside your app repo
36
+ npx project-memory-mcp setup --project .
37
+ ```
38
+
39
+ Now teammates can run `npm run memory:setup` or `npx project-memory-mcp serve` without installing anything globally. Point CLI configs at `node ./node_modules/project-memory-mcp/dist/server.js` or `npx project-memory-mcp`.
40
+
41
+ ### Option D – Local clone (development / hacking)
42
+
43
+ ```bash
44
+ git clone https://github.com/nicobailon/project-memory-mcp-js.git
45
+ cd /Users/itsupport4/Documents/project-memory-mcp-js
46
+ npm install
47
+ npm run build
48
+ ```
49
+
50
+ This keeps the source on disk so you can iterate on hooks or contribute upstream. Instead of `project-memory-mcp`, point your CLIs at `node /Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js`. You normally do **not** run `npm start` manually; CLIs spawn the stdio server when needed.
51
+
52
+ ## 3. Optional environment overrides
53
+
54
+ The server auto-detects project root, but you can override behavior with env vars:
55
+
56
+ | Variable | Purpose |
57
+ |---|---|
58
+ | `MEMORY_PROJECT_ROOT` | Force the project root path (overrides `.git` detection + cwd) |
59
+ | `MEMORY_FILE_PATH` | Override memory JSON path (relative paths resolve under project root) |
60
+
61
+ Example manual start (for debugging):
62
+
63
+ ```bash
64
+ MEMORY_PROJECT_ROOT=/Users/.../repo \
65
+ MEMORY_FILE_PATH=.ai/custom-memory.json \
66
+ node dist/server.js
67
+ ```
68
+
69
+ ## 4. Guided setup command (recommended)
70
+
71
+ Skip the manual wiring by running the built-in wizard inside the project you want to enable (or pass `--project /path/to/project`):
72
+
73
+ ```bash
74
+ npx project-memory-mcp setup
75
+ # or, after a global install
76
+ project-memory-mcp setup
77
+ ```
78
+
79
+ What it does:
80
+
81
+ - Prompts for the project directory (defaults to your current working directory).
82
+ - Lets you pick how the server should be launched (`npx project-memory-mcp`, global binary, `node /absolute/path/dist/server.js`, or a fully custom command/args).
83
+ - Lets you choose which CLIs to configure (Claude Code, Gemini CLI, Codex CLI).
84
+ - Updates `~/.claude.json` (with a `.bak` backup), then runs `gemini mcp` / `codex mcp` commands so they point to the right repo. Each CLI must already be installed and available on your `PATH`.
85
+ - Supports automation via flags such as `--project`, `--cli claude,gemini`, `--runner global`, `--command`, `--args`, and `--yes` to skip prompts. Run `project-memory-mcp setup --help` for the full list.
86
+
87
+ You can re-run the wizard anytime; it safely overwrites the `project-memory` entries with your latest choices.
88
+
89
+ ## 5. Manual quick setup for a new project
90
+
91
+ Follow these minimal steps whenever you want to enable shared memory in another repo (e.g. `/path/to/my-app`):
92
+
93
+ 1. **Update the server repo once**
94
+ ```bash
95
+ cd /Users/itsupport4/Documents/project-memory-mcp-js
96
+ git pull && npm install && npm run build
97
+ ```
98
+
99
+ 2. **From the target project folder (`/path/to/my-app`) configure MCP per CLI**
100
+ - *Claude Code*: edit `~/.claude.json` → under that project’s block add
101
+ ```json
102
+ "mcpServers": {
103
+ "project-memory": {
104
+ "command": "node",
105
+ "args": ["/Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js"],
106
+ "cwd": "/path/to/my-app"
107
+ }
108
+ }
109
+ ```
110
+ Restart Claude from `/path/to/my-app`.
111
+ - *Gemini CLI*:
112
+ ```bash
113
+ cd /path/to/my-app
114
+ gemini mcp add project-memory node /Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js --trust
115
+ gemini mcp list
116
+ ```
117
+ - *Codex CLI*:
118
+ ```bash
119
+ cd /path/to/my-app
120
+ codex mcp add project-memory node /Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js
121
+ codex mcp list
122
+ ```
123
+
124
+ 3. **Verify routing**
125
+ Inside the target repo, start your CLI and say “Call `memory_status` and show the output.” You should see `projectRoot` set to `/path/to/my-app` and `memoryFilePath` pointing to `/path/to/my-app/.ai/memory.json`. Fix any `cwd`/env misconfigurations before continuing.
126
+ - Need a refresher on prompts? Run `memory_help` from the same session to see the quick command list.
127
+
128
+ Once these steps pass, all subsequent sessions in that repo automatically use the latest MCP server code.
129
+
130
+ ## 6. Configure each CLI (details)
131
+
132
+ Run these commands from the project whose memory you want to persist (e.g. `/Users/.../opulence_api`).
133
+
134
+ ### Claude Code
135
+
136
+ Edit `~/.claude.json` and add/merge this under the matching project block:
137
+
138
+ ```json
139
+ "mcpServers": {
140
+ "project-memory": {
141
+ "command": "node",
142
+ "args": ["/Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js"],
143
+ "cwd": "/Users/.../opulence_api"
144
+ }
145
+ }
146
+ ```
147
+
148
+ Restart Claude CLI from that project folder so it resolves the correct working directory. Optional auto-save hook: keep `.claude/settings.json` from this repo inside your project.
149
+
150
+ ### Gemini CLI
151
+
152
+ Follows the [Gemini MCP workflow](https://geminicli.com/docs/tools/mcp-server/):
153
+
154
+ ```bash
155
+ cd /Users/.../opulence_api
156
+ gemini mcp add project-memory node /Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js --trust
157
+ gemini mcp list # should show project-memory CONNECTED
158
+ /mcp # in-session command to inspect tools/resources
159
+ ```
160
+
161
+ - Default scope is `project`, so `.gemini/settings.json` gains the entry under `mcpServers`.
162
+ - Use `--trust` (or later `gemini mcp trust project-memory`) to skip confirmation prompts.
163
+ - If Gemini runs from a different directory, edit `.gemini/settings.json` and add `"cwd": "/Users/.../opulence_api"` or env overrides like `"MEMORY_PROJECT_ROOT": "$GEMINI_PROJECT_DIR"`.
164
+ - Disable/enable without deleting: `gemini mcp disable project-memory`; remove with `gemini mcp remove project-memory`.
165
+
166
+ ### Codex CLI
167
+
168
+ Codex MCP entries are global, so add the server once:
169
+
170
+ ```bash
171
+ codex mcp add project-memory node /Users/itsupport4/Documents/project-memory-mcp-js/dist/server.js
172
+ codex mcp list
173
+ codex mcp get project-memory
174
+ ```
175
+
176
+ Always start Codex from the target repo (`cd /Users/.../opulence_api && codex`) so the server sees that folder as the project root. Optional notify hook: add to `~/.codex/config.toml`.
177
+
178
+ ## 7. Verify routing & run a smoke test
179
+
180
+ 1. Start a fresh CLI session in the target repo.
181
+ 2. Run `memory_status`. Expected output:
182
+ - `projectRoot` → `/path/to/your-project`
183
+ - `memoryFilePath` → `/path/to/your-project/.ai/memory.json`
184
+ 3. Call `memory_save` with test content, then `memory_search` to confirm it appears.
185
+ 4. Check `.ai/memory.json` for the saved entry.
186
+ 5. Switch to another CLI (e.g., Gemini after Claude) and run `memory_get_bundle` to ensure cross-client sharing works.
187
+
188
+ ## 8. Troubleshooting checklist
189
+
190
+ | Symptom | Fix |
191
+ |---|---|
192
+ | Server shows `DISCONNECTED` in `/mcp` | Verify `node` path, server file path, and restart CLI |
193
+ | Tools missing in Gemini | Re-run `gemini mcp add … --trust`; confirm entry in `.gemini/settings.json`; ensure `cwd` points at project |
194
+ | `memory_status` shows wrong project | Adjust CLI config `cwd` or export `MEMORY_PROJECT_ROOT` |
195
+ | Writes not saving | Make sure you called `memory_save` or approved proposals; check `.ai` folder permissions |
196
+ | Lock errors | Check for stale `.ai/memory.json.lock` file and remove after ensuring no other process is running |
197
+
198
+ ## 9. Optional auto-save hooks
199
+
200
+ Leave the provided hook configs inside your project to capture info automatically when sessions end:
201
+
202
+ - `.claude/settings.json` – runs `dist/hooks/auto-save.js` after Claude sessions.
203
+ - `.gemini/settings.json` – registers a `SessionEnd` hook for Gemini.
204
+ - `dist/hooks/codex-notify.js` – wire via `~/.codex/config.toml` to capture Codex history events.
205
+
206
+ Run `npm run build && npm run test:hooks` inside this repo to simulate all hook flows end-to-end.
207
+
208
+ ### Auto-memory (bundle + save) hook
209
+
210
+ For a fully hands-off flow, use the new `dist/hooks/auto-memory.js` script:
211
+
212
+ | CLI Event | Command | What it does |
213
+ |---|---|---|
214
+ | `UserPromptSubmit` (first user message) | `node "$CLAUDE_PROJECT_DIR/dist/hooks/auto-memory.js" start` | Compacts if needed, then injects a fresh `memory_get_bundle` result into the conversation. |
215
+ | `Stop` (session end) | `node "$CLAUDE_PROJECT_DIR/dist/hooks/auto-memory.js" stop` | Mirrors `auto-save.js`: parses transcript, auto-saves important facts/decisions. |
216
+
217
+ Use the same command for Gemini (`"$GEMINI_PROJECT_DIR"` in the path) or Codex (`"$CODEX_PROJECT_DIR"`). The script auto-detects which CLI invoked it and prints `{}` for Gemini when no output is needed.
218
+
219
+ ## 10. Managing store size
220
+
221
+ - The server auto-compacts once more than 400 active items exist (see `src/config.ts > CONFIG.autoCompact`). Oldest entries move into `.ai/memory-archive.json`, and a summary item (tagged `archive`) stays in the main store.
222
+ - Trigger the same logic manually via the `memory_compact` tool, e.g. `Call memory_compact with {"maxItems":250}` to keep only the latest 250 active records.
223
+ - Archived entries remain available in the archive file for audits; `memory_get_bundle` continues to use the lean active list so responses stay fast.