@skedulo/memory-hub-mcp 0.2.8 → 0.2.10

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
@@ -100,7 +100,7 @@ once, and `setup --no-auto-update` pins the installed binary instead (update it
100
100
  `npm i -g @skedulo/memory-hub-mcp`, then re-run `setup`).
101
101
 
102
102
  The first start after a release fetches the new version, about 1 to 5 seconds with the dependencies
103
- already in npm's cache. `setup` warms that cache, so nobody's first start pays the ~430 MB cold
103
+ already in npm's cache. `setup` warms that cache, so nobody's first start pays the ~400 MB cold
104
104
  download (about 16 seconds).
105
105
 
106
106
  ### Releasing
@@ -116,7 +116,7 @@ release has three steps:
116
116
  `@latest` reaches everyone at their next start, so stage it first:
117
117
  ```sh
118
118
  npm publish --tag next # latest is untouched
119
- npx -y @skedulo/memory-hub-mcp@next --help # try it
119
+ npx -y @skedulo/memory-hub-mcp@next embed hello # try it: prints a vector
120
120
  npm dist-tag add @skedulo/memory-hub-mcp@<version> latest # release it
121
121
  ```
122
122
 
package/dist/cli.js CHANGED
@@ -15,7 +15,15 @@ if (command === 'setup') {
15
15
  else if (command === 'embed') {
16
16
  // eslint-disable-next-line @typescript-eslint/no-var-requires
17
17
  const { runEmbed, readProcessStdin } = require('./embed-cli');
18
- runEmbed(process.argv.slice(3), { readStdin: readProcessStdin, write: (line) => console.log(line) }).then((code) => process.exit(code));
18
+ runEmbed(process.argv.slice(3), { readStdin: readProcessStdin, write: (line) => console.log(line) }).then((code) => {
19
+ // onnxruntime aborts the process if process.exit() runs while its model session is open, so a success ends on its own.
20
+ if (code === 0) {
21
+ process.exitCode = 0;
22
+ }
23
+ else {
24
+ process.exit(code);
25
+ }
26
+ });
19
27
  }
20
28
  else if (command === '--help' || command === '-h') {
21
29
  console.log(`memory-hub-mcp — MCP server for the SE AI Memory Hub
@@ -1,12 +1,33 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.embed = exports.MODEL_CACHE_DIR = void 0;
26
+ exports.embed = exports.embeddingNotice = exports.MODEL_CACHE_DIR = void 0;
4
27
  const os_1 = require("os");
5
28
  const path_1 = require("path");
6
- const transformers_1 = require("@xenova/transformers");
7
29
  // Not under node_modules: a global `npm i -g` update wipes that, and a slow network can then miss the load timeout.
8
30
  exports.MODEL_CACHE_DIR = process.env.MEMORY_HUB_MODEL_CACHE || (0, path_1.join)((0, os_1.homedir)(), '.cache', 'memory-hub', 'models');
9
- transformers_1.env.cacheDir = exports.MODEL_CACHE_DIR;
10
31
  // Loaded lazily, once per process, on the first embed() call — a session that
11
32
  // never saves or recalls anything pays zero cost, and every call after the
12
33
  // first reuses the same loaded model instead of reloading it. The model's
@@ -14,28 +35,51 @@ transformers_1.env.cacheDir = exports.MODEL_CACHE_DIR;
14
35
  // download, so only the very first call on a fresh machine pays that cost.
15
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
37
  let extractorPromise;
38
+ let loadFailure;
17
39
  const EXTRACTOR_LOAD_TIMEOUT_MS = 15_000;
40
+ // Imported here, not at module top: the library loads native modules, and one that fails must not stop the whole server from starting.
41
+ async function loadPipeline() {
42
+ const { env, pipeline } = await Promise.resolve().then(() => __importStar(require('@huggingface/transformers')));
43
+ env.cacheDir = exports.MODEL_CACHE_DIR;
44
+ // q8 is the quantized model every stored vector was made with; the library's default would change them all.
45
+ return pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2', { dtype: 'q8' });
46
+ }
18
47
  function loadExtractor() {
19
48
  let timer;
20
49
  const timeout = new Promise((_, reject) => {
21
50
  timer = setTimeout(() => reject(new Error('Embedding model load timed out')), EXTRACTOR_LOAD_TIMEOUT_MS);
22
51
  });
23
- return Promise.race([(0, transformers_1.pipeline)('feature-extraction', 'Xenova/all-MiniLM-L6-v2'), timeout]).finally(() => clearTimeout(timer));
52
+ return Promise.race([loadPipeline(), timeout]).finally(() => clearTimeout(timer));
53
+ }
54
+ function firstLine(err) {
55
+ const message = err instanceof Error ? err.message : String(err);
56
+ return message.split('\n').map((line) => line.trim()).find(Boolean) ?? 'unknown error';
24
57
  }
25
58
  function getExtractor() {
26
59
  if (!extractorPromise) {
27
- extractorPromise = loadExtractor().catch((err) => {
60
+ extractorPromise = loadExtractor().then((extractor) => {
61
+ loadFailure = undefined;
62
+ return extractor;
63
+ }, (err) => {
28
64
  // Don't cache the failure — a transient issue (network blip, disk
29
65
  // permission race) shouldn't permanently disable embeddings for the
30
- // rest of the process's life. Log to stderr since every caller of
31
- // embed() swallows this into "no embedding" silently.
66
+ // rest of the process's life. Every caller of embed() degrades to
67
+ // "no embedding", so the reason is kept for embeddingNotice().
32
68
  extractorPromise = undefined;
69
+ loadFailure = firstLine(err);
33
70
  console.error('Failed to load embedding model:', err);
34
71
  throw err;
35
72
  });
36
73
  }
37
74
  return extractorPromise;
38
75
  }
76
+ function embeddingNotice() {
77
+ if (!loadFailure) {
78
+ return undefined;
79
+ }
80
+ return `Note: semantic matching is off because the embedding model could not load (${loadFailure}). Saves and recalls still work but match on text only, and new saves are stored without an embedding.`;
81
+ }
82
+ exports.embeddingNotice = embeddingNotice;
39
83
  // 384-dimension vector (all-MiniLM-L6-v2's fixed output size), mean-pooled and
40
84
  // L2-normalized so cosine similarity on the connected function side reduces to
41
85
  // a plain dot product in effect. Throws on model load or inference failure —
package/dist/index.js CHANGED
@@ -93,6 +93,10 @@ function similarNoticeBlocks(type, result) {
93
93
  const text = (0, similar_notice_1.similarNotice)(type, result);
94
94
  return text ? [{ type: 'text', text }] : [];
95
95
  }
96
+ function embeddingNoticeBlocks() {
97
+ const text = (0, embeddings_1.embeddingNotice)();
98
+ return text ? [{ type: 'text', text }] : [];
99
+ }
96
100
  server.tool('memory_getSkillGuide', 'Get the current SE AI Memory Hub usage guide — when to recall, what to save where, sharing rules, repo linking. Call this first when the se-ai-memory-hub skill triggers.', {}, async () => {
97
101
  // Read from disk on every call, not cached at module load — this is the whole point:
98
102
  // a developer's local skills/ copy is a thin stub now (see skills/se-ai-memory-hub/SKILL.md),
@@ -114,7 +118,7 @@ server.tool('memory_recall', "Recall this developer's (or their team's) Facts, S
114
118
  maxTotalChars: zod_1.z.number().int().positive().optional().describe('Cap across all items, default 6000.'),
115
119
  }, async (input) => {
116
120
  const result = await (0, recall_1.performRecall)({ client, embed: embeddings_1.embed }, input);
117
- return { content: [{ type: 'text', text: JSON.stringify(result) }] };
121
+ return { content: [...embeddingNoticeBlocks(), { type: 'text', text: JSON.stringify(result) }] };
118
122
  });
119
123
  server.tool('memory_get', "Fetch one Fact/Skill/Scenario/Wiki page in full by its uid. memory_recall truncates every item it lists (500 chars by default), so use this to read anything longer than a paragraph — take the uid from a memory_recall result.", {
120
124
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
@@ -155,6 +159,7 @@ server.tool('memory_save', 'Save a Fact, Skill, Scenario, or Wiki page to the SE
155
159
  content: [
156
160
  ...(await joinNoticeBlocks()),
157
161
  ...similarNoticeBlocks(input.type, result),
162
+ ...embeddingNoticeBlocks(),
158
163
  { type: 'text', text: JSON.stringify(result) },
159
164
  ],
160
165
  };
@@ -214,7 +219,7 @@ server.tool('memory_update', "Revise a memory you saved, in place, instead of sa
214
219
  }, async (input) => {
215
220
  const result = await (0, revise_1.performUpdate)({ client, embed: embeddings_1.embed }, input);
216
221
  (0, capture_1.logCapture)({ action: 'updated', type: input.type, uid: result.uid });
217
- return { content: [{ type: 'text', text: JSON.stringify(result) }] };
222
+ return { content: [...embeddingNoticeBlocks(), { type: 'text', text: JSON.stringify(result) }] };
218
223
  });
219
224
  server.tool('memory_delete', "Permanently delete one memory you saved. Use it to remove a copy you have just merged into another, or a memory that is wrong or obsolete. It cannot be undone and only the author can delete. Prefer memory_update when the memory is still partly right.", {
220
225
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
@@ -262,7 +267,7 @@ server.tool('memory_linkRepoTeam', "Link a repo to a team by name (existing or n
262
267
  });
263
268
  server.tool('memory_sessionContext', "Load this developer's saved memory-hub context: their persona profile, facts, skills, and — when the session has a repo — its wiki pages. Call once at the start of a conversation. If the result has persona.configured false, offer once to set up their persona with memory_upsertPersona, then drop it for the rest of the conversation. On Claude Code the SessionStart hook already covers facts and skills; call this there for the persona, or if that context is missing.", {}, async () => {
264
269
  const context = await (0, session_context_1.buildSessionContext)({ client, currentRepoUid: repoContext.currentRepoUid });
265
- return { content: [{ type: 'text', text: JSON.stringify(context) }] };
270
+ return { content: [...embeddingNoticeBlocks(), { type: 'text', text: JSON.stringify(context) }] };
266
271
  });
267
272
  (0, asset_sync_1.refreshInstalledAssets)();
268
273
  const transport = new stdio_js_1.StdioServerTransport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/memory-hub-mcp",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "MCP server for the SE AI Memory Hub: recall and save developer memory from Claude Code and Claude Desktop.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -31,8 +31,8 @@
31
31
  "prepack": "./scripts/copy-assets.sh"
32
32
  },
33
33
  "dependencies": {
34
+ "@huggingface/transformers": "3.8.1",
34
35
  "@modelcontextprotocol/sdk": "^1.30.0",
35
- "@xenova/transformers": "^2.17.2",
36
36
  "axios": "^1.7.0",
37
37
  "zod": "^3.25.0"
38
38
  },