@seanhogg/builderforce-memory-mcp 2026.6.18

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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -0
  3. package/dist/backend.d.ts +60 -0
  4. package/dist/backend.d.ts.map +1 -0
  5. package/dist/backend.js +11 -0
  6. package/dist/backend.js.map +1 -0
  7. package/dist/backends/memory-store.d.ts +73 -0
  8. package/dist/backends/memory-store.d.ts.map +1 -0
  9. package/dist/backends/memory-store.js +152 -0
  10. package/dist/backends/memory-store.js.map +1 -0
  11. package/dist/bin/http.d.ts +14 -0
  12. package/dist/bin/http.d.ts.map +1 -0
  13. package/dist/bin/http.js +33 -0
  14. package/dist/bin/http.js.map +1 -0
  15. package/dist/bin/stdio.d.ts +18 -0
  16. package/dist/bin/stdio.d.ts.map +1 -0
  17. package/dist/bin/stdio.js +24 -0
  18. package/dist/bin/stdio.js.map +1 -0
  19. package/dist/index.d.ts +21 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +18 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/tools.d.ts +47 -0
  24. package/dist/tools.d.ts.map +1 -0
  25. package/dist/tools.js +186 -0
  26. package/dist/tools.js.map +1 -0
  27. package/dist/transports/http.d.ts +30 -0
  28. package/dist/transports/http.d.ts.map +1 -0
  29. package/dist/transports/http.js +45 -0
  30. package/dist/transports/http.js.map +1 -0
  31. package/dist/transports/mcp-server.d.ts +17 -0
  32. package/dist/transports/mcp-server.d.ts.map +1 -0
  33. package/dist/transports/mcp-server.js +26 -0
  34. package/dist/transports/mcp-server.js.map +1 -0
  35. package/dist/transports/sdk.d.ts +45 -0
  36. package/dist/transports/sdk.d.ts.map +1 -0
  37. package/dist/transports/sdk.js +44 -0
  38. package/dist/transports/sdk.js.map +1 -0
  39. package/dist/transports/stdio.d.ts +14 -0
  40. package/dist/transports/stdio.d.ts.map +1 -0
  41. package/dist/transports/stdio.js +17 -0
  42. package/dist/transports/stdio.js.map +1 -0
  43. package/package.json +86 -0
  44. package/src/backend.ts +66 -0
  45. package/src/backends/memory-store.ts +217 -0
  46. package/src/bin/http.ts +36 -0
  47. package/src/bin/stdio.ts +26 -0
  48. package/src/index.ts +31 -0
  49. package/src/tools.ts +214 -0
  50. package/src/transports/http.ts +64 -0
  51. package/src/transports/mcp-server.ts +40 -0
  52. package/src/transports/sdk.ts +75 -0
  53. package/src/transports/stdio.ts +19 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sean Hogg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # @seanhogg/builderforce-memory-mcp
2
+
3
+ Expose [`@seanhogg/builderforce-memory`](../memory) to any MCP client. One token-saving
4
+ tool core over a pluggable `MemoryBackend`, three transports:
5
+
6
+ | Transport | Factory | Consumed as | Use when |
7
+ |---|---|---|---|
8
+ | **In-process (Claude Agent SDK)** | `createMemoryMcpServer(backend)` | the returned `type:"sdk"` object | the consuming product is TS and runs `@anthropic-ai/claude-agent-sdk` in-process — lowest latency |
9
+ | **stdio** | `runStdio(backend)` / `npx @seanhogg/builderforce-memory-mcp` | `{ type:"stdio", command, args }` | any language / separate process; decouples the SSM+IndexedDB deps from the consumer |
10
+ | **HTTP (Streamable)** | `createMemoryHttpHandler(backend, { authToken })` | `{ type:"http", url, headers }` | multi-tenant / networked (builderforce.ai hosting, remote claws) |
11
+
12
+ ## Why this saves tokens
13
+
14
+ The point of an external memory store is **fetch-on-demand** instead of pinning
15
+ your whole memory file into every prompt. That only pays off if recall is
16
+ *selective*, so the caps are enforced server-side in [`tools.ts`](src/tools.ts):
17
+
18
+ - `memory_recall` returns a **ranked top-K** (default 5, hard-capped), never the store.
19
+ - Each entry's content is **truncated** (default 500 chars) before it hits context.
20
+ - There is **no "return everything" tool** — a dump-all is more expensive than inlining.
21
+
22
+ Tool descriptions are prescriptive ("call this *before* answering when…") because
23
+ recent Claude models reach for tools more conservatively; the trigger condition in
24
+ the description is what drives should-call rate. Pair this with prompt caching (keep
25
+ the tool set identical across tenants so the cached prefix survives) and context
26
+ editing (prune stale recalled facts) for the full win.
27
+
28
+ ## The seam
29
+
30
+ Everything is written against [`MemoryBackend`](src/backend.ts):
31
+
32
+ ```ts
33
+ interface MemoryBackend {
34
+ recall(query: string, topK: number): Promise<RecallHit[]>; // semantic
35
+ get(key: string): Promise<RecallHit | undefined>; // exact
36
+ recallByTag(tag: string, limit: number): Promise<RecallHit[]>;
37
+ remember?(input: RememberInput): Promise<void>; // optional → read-only backends omit
38
+ forget?(key: string): Promise<void>;
39
+ }
40
+ ```
41
+
42
+ Ship the local `MemoryStoreBackend` (IndexedDB via `@seanhogg/builderforce-memory`) today;
43
+ drop in a networked builderforce.ai adapter later with **zero** changes to tools
44
+ or transports.
45
+
46
+ ## Quick start — in-process with the Claude Agent SDK
47
+
48
+ ```ts
49
+ import { query } from "@anthropic-ai/claude-agent-sdk";
50
+ import { createMemoryMcpServer, createLocalMemoryStoreBackend } from "@seanhogg/builderforce-memory-mcp";
51
+
52
+ const backend = await createLocalMemoryStoreBackend(); // IndexedDB (fake-indexeddb in Node)
53
+ const memory = await createMemoryMcpServer(backend); // type:"sdk" config
54
+
55
+ for await (const msg of query({
56
+ prompt: "What language does this user prefer? Check memory first.",
57
+ options: {
58
+ mcpServers: { builderforce_memory: memory },
59
+ allowedTools: ["mcp__builderforce_memory__*"], // auto-approve, no prompts
60
+ },
61
+ })) {
62
+ if (msg.type === "result" && msg.subtype === "success") console.log(msg.result);
63
+ }
64
+ ```
65
+
66
+ ### SSM-embedding recall (the premium path)
67
+
68
+ The local backend defaults to **lexical (Jaccard)** recall. For SSM-embedding
69
+ cosine recall, pass an SSM runtime — e.g. reuse the agent-runtime's already-loaded
70
+ hippocampus instead of standing up a second model:
71
+
72
+ ```ts
73
+ const backend = await createLocalMemoryStoreBackend({ runtime: ssmMemoryService.runtime });
74
+ ```
75
+
76
+ Recall quality then improves automatically as that model is adapted/distilled.
77
+
78
+ ## Quick start — stdio (any process / language)
79
+
80
+ ```bash
81
+ npx -y @seanhogg/builderforce-memory-mcp # serves the local MemoryStore over stdio
82
+ ```
83
+
84
+ ```ts
85
+ mcpServers: {
86
+ builderforce_memory: { type: "stdio", command: "npx", args: ["-y", "@seanhogg/builderforce-memory-mcp"] },
87
+ }
88
+ ```
89
+
90
+ Env: `BUILDERFORCE_MEMORY_DB` (db name), `BUILDERFORCE_MEMORY_READONLY=1` (drop write tools).
91
+
92
+ ## Quick start — HTTP (multi-tenant)
93
+
94
+ ```bash
95
+ BUILDERFORCE_MEMORY_TOKEN=secret PORT=8787 npx @seanhogg/builderforce-memory-mcp-http
96
+ ```
97
+
98
+ ```ts
99
+ mcpServers: {
100
+ builderforce_memory: {
101
+ type: "http",
102
+ url: "http://localhost:8787",
103
+ headers: { Authorization: "Bearer secret" },
104
+ },
105
+ }
106
+ ```
107
+
108
+ Or mount `createMemoryHttpHandler(backend, { authToken })` on your own Node/Express
109
+ server against any backend (including a future remote one).
110
+
111
+ ## Custom / remote backend
112
+
113
+ Implement `MemoryBackend` and hand it to any transport:
114
+
115
+ ```ts
116
+ import { createMemoryMcpServer, type MemoryBackend } from "@seanhogg/builderforce-memory-mcp";
117
+
118
+ const remote: MemoryBackend = {
119
+ recall: (q, k) => bfClient.search(q, k),
120
+ get: (key) => bfClient.get(key),
121
+ recallByTag: (t, lim) => bfClient.byTag(t, lim),
122
+ remember: (input) => bfClient.put(input),
123
+ forget: (key) => bfClient.delete(key),
124
+ };
125
+ const server = await createMemoryMcpServer(remote);
126
+ ```
127
+
128
+ ## Dependencies
129
+
130
+ `@modelcontextprotocol/sdk` + `zod` are hard deps. `@anthropic-ai/claude-agent-sdk`
131
+ (SDK transport), `@seanhogg/builderforce-memory` + `fake-indexeddb` (local backend) are
132
+ **optional peers**, imported indirectly — install only what your transport/backend
133
+ needs.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MemoryBackend — the storage seam every transport is written against.
3
+ *
4
+ * The MCP tools (src/tools.ts) and all three transports (SDK / stdio / HTTP)
5
+ * depend ONLY on this interface, never on a concrete store. Ship the local
6
+ * `MemoryStoreBackend` (IndexedDB via @seanhogg/builderforce-memory) today; drop in a
7
+ * networked builderforce.ai adapter later with zero changes to the tools or
8
+ * transports.
9
+ */
10
+ /** A single recalled memory, normalised across backends. */
11
+ export interface RecallHit {
12
+ /** Stable identifier for the memory. */
13
+ key: string;
14
+ /** The stored value. */
15
+ content: string;
16
+ /**
17
+ * Optional relevance score (higher = closer). Semantic backends that expose
18
+ * ranking can populate this; the local MemoryStore ranks but does not surface
19
+ * a score, so it is left undefined and recall order carries the signal.
20
+ */
21
+ score?: number;
22
+ /** Tags for grouping/filtering. */
23
+ tags?: string[];
24
+ /** Importance weight 0–1. */
25
+ importance?: number;
26
+ /** Unix-ms write time. */
27
+ timestamp?: number;
28
+ }
29
+ /** Arguments for writing a memory. */
30
+ export interface RememberInput {
31
+ key: string;
32
+ content: string;
33
+ tags?: string[];
34
+ /** Importance weight 0–1. */
35
+ importance?: number;
36
+ /** Time-to-live in milliseconds. */
37
+ ttlMs?: number;
38
+ }
39
+ /**
40
+ * The minimal capability surface the MCP layer needs. Deliberately small —
41
+ * the token-saving design exposes recall-on-demand, not a "dump everything"
42
+ * call, so this interface has no `recallAll`.
43
+ */
44
+ export interface MemoryBackend {
45
+ /**
46
+ * Semantic top-K recall. Backends with an embedding model (the SSM
47
+ * runtime) should use it; lexical fallback is acceptable. `topK` is already
48
+ * clamped by the caller — the backend may return fewer, never more.
49
+ */
50
+ recall(query: string, topK: number): Promise<RecallHit[]>;
51
+ /** Exact lookup by key. Returns undefined when absent or expired. */
52
+ get(key: string): Promise<RecallHit | undefined>;
53
+ /** All non-expired entries carrying `tag`, capped to `limit`. */
54
+ recallByTag(tag: string, limit: number): Promise<RecallHit[]>;
55
+ /** Store or overwrite a memory. Optional — read-only backends omit it. */
56
+ remember?(input: RememberInput): Promise<void>;
57
+ /** Delete a memory by key. Optional — read-only backends omit it. */
58
+ forget?(key: string): Promise<void>;
59
+ }
60
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,4DAA4D;AAC5D,MAAM,WAAW,SAAS;IACtB,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAE1D,qEAAqE;IACrE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAEjD,iEAAiE;IACjE,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAE9D,0EAA0E;IAC1E,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C,qEAAqE;IACrE,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MemoryBackend — the storage seam every transport is written against.
3
+ *
4
+ * The MCP tools (src/tools.ts) and all three transports (SDK / stdio / HTTP)
5
+ * depend ONLY on this interface, never on a concrete store. Ship the local
6
+ * `MemoryStoreBackend` (IndexedDB via @seanhogg/builderforce-memory) today; drop in a
7
+ * networked builderforce.ai adapter later with zero changes to the tools or
8
+ * transports.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * MemoryStoreBackend — local adapter mapping @seanhogg/builderforce-memory's MemoryStore
3
+ * onto the MemoryBackend seam.
4
+ *
5
+ * Recall quality: when an SSM runtime is supplied it is forwarded to
6
+ * `recallSimilar`, so recall uses SSM-embedding cosine similarity and improves
7
+ * as the model is adapted/distilled. With no runtime it transparently falls
8
+ * back to Jaccard word-overlap (still useful, just lexical).
9
+ */
10
+ import type { MemoryBackend, RecallHit, RememberInput } from "../backend.js";
11
+ interface MemoryEntryLike {
12
+ key: string;
13
+ content: string;
14
+ timestamp?: number;
15
+ tags?: string[];
16
+ importance?: number;
17
+ }
18
+ interface MemoryStoreLike {
19
+ remember(key: string, content: string, opts?: {
20
+ ttlMs?: number;
21
+ tags?: string[];
22
+ importance?: number;
23
+ }): Promise<void>;
24
+ recall(key: string): Promise<MemoryEntryLike | undefined>;
25
+ recallAll(): Promise<MemoryEntryLike[]>;
26
+ recallByTag(tag: string): Promise<MemoryEntryLike[]>;
27
+ recallSimilar(query: string, topK: number, runtime?: unknown): Promise<MemoryEntryLike[]>;
28
+ forget(key: string): Promise<void>;
29
+ }
30
+ export declare class MemoryStoreBackend implements MemoryBackend {
31
+ private readonly store;
32
+ /** Optional SSMRuntime; enables embedding-based recall when present. */
33
+ private readonly runtime?;
34
+ constructor(store: MemoryStoreLike,
35
+ /** Optional SSMRuntime; enables embedding-based recall when present. */
36
+ runtime?: unknown | undefined);
37
+ recall(query: string, topK: number): Promise<RecallHit[]>;
38
+ get(key: string): Promise<RecallHit | undefined>;
39
+ recallByTag(tag: string, limit: number): Promise<RecallHit[]>;
40
+ remember(input: RememberInput): Promise<void>;
41
+ forget(key: string): Promise<void>;
42
+ }
43
+ /** Options for {@link createLocalMemoryStoreBackend}. */
44
+ export interface LocalBackendOptions {
45
+ /** IndexedDB database name. Defaults to MemoryStore's own default ('ssmjs'). */
46
+ dbName?: string;
47
+ /**
48
+ * Optional SSMRuntime for embedding-based recall. Omit for lexical (Jaccard)
49
+ * recall. In the agent-runtime, pass `ssmMemoryService.runtime` here to reuse
50
+ * the already-loaded hippocampus instead of standing up a second model.
51
+ */
52
+ runtime?: unknown;
53
+ /**
54
+ * Absolute path to a JSON file that mirrors the store to disk. Without it the
55
+ * store is purely in-memory (fake-indexeddb) and evaporates when the process
56
+ * exits — fine for a long-lived server, fatal for a per-session subprocess
57
+ * (e.g. an MCP stdio client that respawns the server each launch).
58
+ *
59
+ * When set, the store is hydrated from the file on creation and re-snapshotted
60
+ * after every remember/forget, giving durable cross-process memory. TTLs are
61
+ * dropped on persist: the snapshot is the durable long-term tier.
62
+ */
63
+ persistFile?: string;
64
+ }
65
+ /**
66
+ * Builds a MemoryStoreBackend over a fresh MemoryStore, wiring fake-indexeddb in
67
+ * Node exactly as SsmMemoryService does. @seanhogg/builderforce-memory and fake-indexeddb
68
+ * are imported indirectly so they remain optional peers — a consumer that only
69
+ * wants a custom backend (or the HTTP thin-client) never has to install them.
70
+ */
71
+ export declare function createLocalMemoryStoreBackend(opts?: LocalBackendOptions): Promise<MemoryBackend>;
72
+ export {};
73
+ //# sourceMappingURL=memory-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../src/backends/memory-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI7E,UAAU,eAAe;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,eAAe;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MA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CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAiFD;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgC1G"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * MemoryStoreBackend — local adapter mapping @seanhogg/builderforce-memory's MemoryStore
3
+ * onto the MemoryBackend seam.
4
+ *
5
+ * Recall quality: when an SSM runtime is supplied it is forwarded to
6
+ * `recallSimilar`, so recall uses SSM-embedding cosine similarity and improves
7
+ * as the model is adapted/distilled. With no runtime it transparently falls
8
+ * back to Jaccard word-overlap (still useful, just lexical).
9
+ */
10
+ function toHit(e) {
11
+ return {
12
+ key: e.key,
13
+ content: e.content,
14
+ tags: e.tags,
15
+ importance: e.importance,
16
+ timestamp: e.timestamp,
17
+ };
18
+ }
19
+ export class MemoryStoreBackend {
20
+ store;
21
+ runtime;
22
+ constructor(store,
23
+ /** Optional SSMRuntime; enables embedding-based recall when present. */
24
+ runtime) {
25
+ this.store = store;
26
+ this.runtime = runtime;
27
+ }
28
+ async recall(query, topK) {
29
+ const entries = await this.store.recallSimilar(query, topK, this.runtime);
30
+ return entries.map(toHit);
31
+ }
32
+ async get(key) {
33
+ const e = await this.store.recall(key);
34
+ return e ? toHit(e) : undefined;
35
+ }
36
+ async recallByTag(tag, limit) {
37
+ const entries = await this.store.recallByTag(tag);
38
+ return entries.slice(0, limit).map(toHit);
39
+ }
40
+ async remember(input) {
41
+ await this.store.remember(input.key, input.content, {
42
+ ttlMs: input.ttlMs,
43
+ tags: input.tags,
44
+ importance: input.importance,
45
+ });
46
+ }
47
+ async forget(key) {
48
+ await this.store.forget(key);
49
+ }
50
+ }
51
+ /**
52
+ * Wraps a MemoryStoreBackend so every write is mirrored to a JSON file, and
53
+ * hydrates that file back into the store on boot. This is what turns a respawned
54
+ * stdio subprocess into a persistent memory: the store itself is in-memory, the
55
+ * file is the source of truth across process lifetimes.
56
+ */
57
+ class DiskPersistedBackend {
58
+ inner;
59
+ store;
60
+ file;
61
+ fs;
62
+ constructor(inner, store, file, fs) {
63
+ this.inner = inner;
64
+ this.store = store;
65
+ this.file = file;
66
+ this.fs = fs;
67
+ }
68
+ recall(query, topK) {
69
+ return this.inner.recall(query, topK);
70
+ }
71
+ get(key) {
72
+ return this.inner.get(key);
73
+ }
74
+ recallByTag(tag, limit) {
75
+ return this.inner.recallByTag(tag, limit);
76
+ }
77
+ async remember(input) {
78
+ await this.inner.remember(input);
79
+ await this.snapshot();
80
+ }
81
+ async forget(key) {
82
+ await this.inner.forget(key);
83
+ await this.snapshot();
84
+ }
85
+ async snapshot() {
86
+ const entries = await this.store.recallAll();
87
+ const out = entries.map((e) => ({
88
+ key: e.key,
89
+ content: e.content,
90
+ tags: e.tags,
91
+ importance: e.importance,
92
+ }));
93
+ this.fs.writeFileSync(this.file, JSON.stringify(out, null, 2));
94
+ }
95
+ }
96
+ /** Reads a snapshot file and replays it into the store as durable (no-TTL) entries. */
97
+ async function hydrateFromDisk(store, file, fs) {
98
+ if (!fs.existsSync(file))
99
+ return;
100
+ let parsed;
101
+ try {
102
+ parsed = JSON.parse(fs.readFileSync(file, "utf8"));
103
+ }
104
+ catch {
105
+ // Corrupt/partial snapshot — start clean rather than crash the server.
106
+ return;
107
+ }
108
+ if (!Array.isArray(parsed))
109
+ return;
110
+ for (const raw of parsed) {
111
+ if (!raw || typeof raw.key !== "string" || typeof raw.content !== "string")
112
+ continue;
113
+ await store.remember(raw.key, raw.content, { tags: raw.tags, importance: raw.importance });
114
+ }
115
+ }
116
+ /**
117
+ * Builds a MemoryStoreBackend over a fresh MemoryStore, wiring fake-indexeddb in
118
+ * Node exactly as SsmMemoryService does. @seanhogg/builderforce-memory and fake-indexeddb
119
+ * are imported indirectly so they remain optional peers — a consumer that only
120
+ * wants a custom backend (or the HTTP thin-client) never has to install them.
121
+ */
122
+ export async function createLocalMemoryStoreBackend(opts = {}) {
123
+ // Indirect import prevents the bundler/tsc from resolving optional peers.
124
+ const _import = (m) =>
125
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
126
+ new Function("m", "return import(m)")(m);
127
+ const memoryMod = (await _import("@seanhogg/builderforce-memory"));
128
+ const { MemoryStore } = memoryMod;
129
+ // IndexedDB shim for Node. In the browser the global is used automatically.
130
+ let idbFactory;
131
+ try {
132
+ const fake = (await _import("fake-indexeddb"));
133
+ idbFactory = new fake.IDBFactory();
134
+ }
135
+ catch {
136
+ // Browser or a host that provides global indexedDB — MemoryStore handles it.
137
+ }
138
+ const store = new MemoryStore({ idbFactory, dbName: opts.dbName });
139
+ const backend = new MemoryStoreBackend(store, opts.runtime);
140
+ if (!opts.persistFile)
141
+ return backend;
142
+ // Disk-mirror requested. node:fs/path are loaded indirectly so a browser
143
+ // bundle of this module never statically pulls in Node builtins.
144
+ const fs = (await _import("node:fs"));
145
+ const path = (await _import("node:path"));
146
+ const dir = path.dirname(opts.persistFile);
147
+ if (dir && !fs.existsSync(dir))
148
+ fs.mkdirSync(dir, { recursive: true });
149
+ await hydrateFromDisk(store, opts.persistFile, fs);
150
+ return new DiskPersistedBackend(backend, store, opts.persistFile, fs);
151
+ }
152
+ //# sourceMappingURL=memory-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-store.js","sourceRoot":"","sources":["../../src/backends/memory-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH,SAAS,KAAK,CAAC,CAAkB;IAC7B,OAAO;QACH,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,SAAS,EAAE,CAAC,CAAC,SAAS;KACzB,CAAC;AACN,CAAC;AAED,MAAM,OAAO,kBAAkB;IAEN;IAEA;IA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/usr/bin/env node
2
+ /**
3
+ * `builderforce-memory-mcp-http` — Streamable HTTP MCP server over the LOCAL
4
+ * MemoryStore. A reference host; in production builderforce.ai would mount
5
+ * createMemoryHttpHandler() against a shared/remote backend instead.
6
+ *
7
+ * Env:
8
+ * PORT Listen port (default 8787).
9
+ * BUILDERFORCE_MEMORY_TOKEN Bearer token required on every request (recommended).
10
+ * BUILDERFORCE_MEMORY_DB IndexedDB database name.
11
+ * BUILDERFORCE_MEMORY_READONLY '1' to disable remember/forget tools.
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/bin/http.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `builderforce-memory-mcp-http` — Streamable HTTP MCP server over the LOCAL
4
+ * MemoryStore. A reference host; in production builderforce.ai would mount
5
+ * createMemoryHttpHandler() against a shared/remote backend instead.
6
+ *
7
+ * Env:
8
+ * PORT Listen port (default 8787).
9
+ * BUILDERFORCE_MEMORY_TOKEN Bearer token required on every request (recommended).
10
+ * BUILDERFORCE_MEMORY_DB IndexedDB database name.
11
+ * BUILDERFORCE_MEMORY_READONLY '1' to disable remember/forget tools.
12
+ */
13
+ import http from "node:http";
14
+ import { createLocalMemoryStoreBackend } from "../backends/memory-store.js";
15
+ import { createMemoryHttpHandler } from "../transports/http.js";
16
+ const backend = await createLocalMemoryStoreBackend({
17
+ dbName: process.env["BUILDERFORCE_MEMORY_DB"],
18
+ });
19
+ const handler = createMemoryHttpHandler(backend, {
20
+ authToken: process.env["BUILDERFORCE_MEMORY_TOKEN"],
21
+ writable: process.env["BUILDERFORCE_MEMORY_READONLY"] !== "1",
22
+ });
23
+ const port = Number(process.env["PORT"] ?? 8787);
24
+ http.createServer((req, res) => {
25
+ void handler(req, res).catch((err) => {
26
+ if (!res.headersSent)
27
+ res.writeHead(500, { "content-type": "application/json" });
28
+ res.end(JSON.stringify({ error: String(err) }));
29
+ });
30
+ }).listen(port, () => {
31
+ process.stderr.write(`[builderforce-memory-mcp-http] listening on :${port}\n`);
32
+ });
33
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/bin/http.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,OAAO,GAAG,MAAM,6BAA6B,CAAC;IAChD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,uBAAuB,CAAC,OAAO,EAAE;IAC7C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC;IACnD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,KAAK,GAAG;CAChE,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;AAEjD,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAC3B,KAAK,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACjC,IAAI,CAAC,GAAG,CAAC,WAAW;YAAE,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;QACjF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gDAAgD,IAAI,IAAI,CAAC,CAAC;AACnF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `builderforce-memory-mcp` — stdio MCP server over the LOCAL MemoryStore.
4
+ *
5
+ * Env:
6
+ * BUILDERFORCE_MEMORY_DB IndexedDB database name (default: MemoryStore default).
7
+ * BUILDERFORCE_MEMORY_READONLY '1' to disable remember/forget tools.
8
+ * BUILDERFORCE_MEMORY_FILE Absolute path to a JSON snapshot. When set, memory
9
+ * persists across process restarts — REQUIRED for an
10
+ * MCP client that respawns this server each session
11
+ * (otherwise fake-indexeddb loses everything on exit).
12
+ *
13
+ * Recall is lexical (Jaccard) here — this headless binary does not stand up the
14
+ * SSM runtime/GPU. For SSM-embedding recall, embed the package in-process and
15
+ * pass `runtime` to createLocalMemoryStoreBackend (see README).
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=stdio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/bin/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `builderforce-memory-mcp` — stdio MCP server over the LOCAL MemoryStore.
4
+ *
5
+ * Env:
6
+ * BUILDERFORCE_MEMORY_DB IndexedDB database name (default: MemoryStore default).
7
+ * BUILDERFORCE_MEMORY_READONLY '1' to disable remember/forget tools.
8
+ * BUILDERFORCE_MEMORY_FILE Absolute path to a JSON snapshot. When set, memory
9
+ * persists across process restarts — REQUIRED for an
10
+ * MCP client that respawns this server each session
11
+ * (otherwise fake-indexeddb loses everything on exit).
12
+ *
13
+ * Recall is lexical (Jaccard) here — this headless binary does not stand up the
14
+ * SSM runtime/GPU. For SSM-embedding recall, embed the package in-process and
15
+ * pass `runtime` to createLocalMemoryStoreBackend (see README).
16
+ */
17
+ import { createLocalMemoryStoreBackend } from "../backends/memory-store.js";
18
+ import { runStdio } from "../transports/stdio.js";
19
+ const backend = await createLocalMemoryStoreBackend({
20
+ dbName: process.env["BUILDERFORCE_MEMORY_DB"],
21
+ persistFile: process.env["BUILDERFORCE_MEMORY_FILE"],
22
+ });
23
+ await runStdio(backend, { writable: process.env["BUILDERFORCE_MEMORY_READONLY"] !== "1" });
24
+ //# sourceMappingURL=stdio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/bin/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,MAAM,OAAO,GAAG,MAAM,6BAA6B,CAAC;IAChD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;CACvD,CAAC,CAAC;AAEH,MAAM,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @seanhogg/builderforce-memory-mcp — expose @seanhogg/builderforce-memory to MCP clients.
3
+ *
4
+ * One token-saving tool core over a pluggable MemoryBackend, three transports:
5
+ * - createMemoryMcpServer → in-process Claude Agent SDK (type:"sdk")
6
+ * - runStdio → stdio subprocess (any language)
7
+ * - createMemoryHttpHandler→ Streamable HTTP (multi-tenant / networked)
8
+ */
9
+ export type { MemoryBackend, RecallHit, RememberInput } from "./backend.js";
10
+ export { MemoryStoreBackend, createLocalMemoryStoreBackend } from "./backends/memory-store.js";
11
+ export type { LocalBackendOptions } from "./backends/memory-store.js";
12
+ export { buildMemoryTools } from "./tools.js";
13
+ export type { MemoryTool, MemoryToolsOptions, ToolResult } from "./tools.js";
14
+ export { createMemoryMcpServer } from "./transports/sdk.js";
15
+ export type { SdkServerOptions, SdkMcpServerConfig } from "./transports/sdk.js";
16
+ export { buildMcpServer } from "./transports/mcp-server.js";
17
+ export type { McpServerOptions } from "./transports/mcp-server.js";
18
+ export { runStdio } from "./transports/stdio.js";
19
+ export { createMemoryHttpHandler } from "./transports/http.js";
20
+ export type { HttpHandlerOptions } from "./transports/http.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG5E,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC/F,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @seanhogg/builderforce-memory-mcp — expose @seanhogg/builderforce-memory to MCP clients.
3
+ *
4
+ * One token-saving tool core over a pluggable MemoryBackend, three transports:
5
+ * - createMemoryMcpServer → in-process Claude Agent SDK (type:"sdk")
6
+ * - runStdio → stdio subprocess (any language)
7
+ * - createMemoryHttpHandler→ Streamable HTTP (multi-tenant / networked)
8
+ */
9
+ // ── Local backend (IndexedDB via @seanhogg/builderforce-memory) ────────────────────────
10
+ export { MemoryStoreBackend, createLocalMemoryStoreBackend } from "./backends/memory-store.js";
11
+ // ── Tool core ─────────────────────────────────────────────────────────────────
12
+ export { buildMemoryTools } from "./tools.js";
13
+ // ── Transports ──────────────────────────────────────────────────────────────
14
+ export { createMemoryMcpServer } from "./transports/sdk.js";
15
+ export { buildMcpServer } from "./transports/mcp-server.js";
16
+ export { runStdio } from "./transports/stdio.js";
17
+ export { createMemoryHttpHandler } from "./transports/http.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,0FAA0F;AAC1F,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAG/F,iFAAiF;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,+EAA+E;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC"}