@skedulo/memory-hub-mcp 0.2.8 → 0.2.9

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
@@ -85,6 +85,12 @@ Developer tools → API tokens. It never mints a token you didn't ask for.
85
85
 
86
86
  Then restart Claude Code, or quit Claude Desktop completely and reopen it.
87
87
 
88
+ If your npm skips install scripts it hasn't been told to allow (npm 12 does by default), the
89
+ embedding model's `sharp` dependency isn't built. The server still runs, but saves and recalls match
90
+ on text only, and tool results say why. To fix it, add `allow-scripts=sharp` to `~/.npmrc`, rerun
91
+ `npm install -g @skedulo/memory-hub-mcp`, delete `~/.npm/_npx` (npx keeps its own copy there), and
92
+ restart.
93
+
88
94
  Installing the package is not the same as having access: every call is authorised by your personal
89
95
  Skedulo API token, and the package is useless without one.
90
96
 
@@ -116,7 +122,7 @@ release has three steps:
116
122
  `@latest` reaches everyone at their next start, so stage it first:
117
123
  ```sh
118
124
  npm publish --tag next # latest is untouched
119
- npx -y @skedulo/memory-hub-mcp@next --help # try it
125
+ npx -y @skedulo/memory-hub-mcp@next embed hello # try it: prints a vector
120
126
  npm dist-tag add @skedulo/memory-hub-mcp@<version> latest # release it
121
127
  ```
122
128
 
@@ -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,54 @@ 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 needs sharp's native build, which npm 12 skips by default, and a top-level import would stop the whole server from starting.
41
+ async function loadPipeline() {
42
+ const { env, pipeline } = await Promise.resolve().then(() => __importStar(require('@xenova/transformers')));
43
+ env.cacheDir = exports.MODEL_CACHE_DIR;
44
+ return pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
45
+ }
18
46
  function loadExtractor() {
19
47
  let timer;
20
48
  const timeout = new Promise((_, reject) => {
21
49
  timer = setTimeout(() => reject(new Error('Embedding model load timed out')), EXTRACTOR_LOAD_TIMEOUT_MS);
22
50
  });
23
- return Promise.race([(0, transformers_1.pipeline)('feature-extraction', 'Xenova/all-MiniLM-L6-v2'), timeout]).finally(() => clearTimeout(timer));
51
+ return Promise.race([loadPipeline(), timeout]).finally(() => clearTimeout(timer));
52
+ }
53
+ function firstLine(err) {
54
+ const message = err instanceof Error ? err.message : String(err);
55
+ return message.split('\n').map((line) => line.trim()).find(Boolean) ?? 'unknown error';
24
56
  }
25
57
  function getExtractor() {
26
58
  if (!extractorPromise) {
27
- extractorPromise = loadExtractor().catch((err) => {
59
+ extractorPromise = loadExtractor().then((extractor) => {
60
+ loadFailure = undefined;
61
+ return extractor;
62
+ }, (err) => {
28
63
  // Don't cache the failure — a transient issue (network blip, disk
29
64
  // 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.
65
+ // rest of the process's life. Every caller of embed() degrades to
66
+ // "no embedding", so the reason is kept for embeddingNotice().
32
67
  extractorPromise = undefined;
68
+ loadFailure = firstLine(err);
33
69
  console.error('Failed to load embedding model:', err);
34
70
  throw err;
35
71
  });
36
72
  }
37
73
  return extractorPromise;
38
74
  }
75
+ // Shown on tool results so the agent can tell the user why semantic matching is off.
76
+ function embeddingNotice() {
77
+ if (!loadFailure) {
78
+ return undefined;
79
+ }
80
+ const fix = loadFailure.includes('sharp')
81
+ ? ' npm blocked the install script of sharp, which the model needs: add allow-scripts=sharp to ~/.npmrc, then reinstall (rerun npm install -g @skedulo/memory-hub-mcp, or delete ~/.npm/_npx when the server runs through npx) and restart.'
82
+ : '';
83
+ 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.${fix}`;
84
+ }
85
+ exports.embeddingNotice = embeddingNotice;
39
86
  // 384-dimension vector (all-MiniLM-L6-v2's fixed output size), mean-pooled and
40
87
  // L2-normalized so cosine similarity on the connected function side reduces to
41
88
  // 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.9",
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": {