mcpscraper-memory-sdk 0.2.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 ADDED
@@ -0,0 +1,51 @@
1
+ # mcpscraper-memory-sdk
2
+
3
+ Official TypeScript/JavaScript client for [memory.mcpscraper.dev](https://memory.mcpscraper.dev) — a hosted, per-user, multi-vault memory API (notes, search, tables, channels, scheduled actions, and more).
4
+
5
+ This is a thin client: every method sends a JSON-RPC 2.0 `tools/call` request to `/mcp` with your Bearer API key and parses the response. No memory/vault logic lives in this package — see [`contracts/memory.tools.json`](../../contracts/memory.tools.json) for the full contract this client is generated from.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install mcpscraper-memory-sdk
11
+ ```
12
+
13
+ ## Quickstart
14
+
15
+ ```ts
16
+ import { MemoryClient, MemoryApiError } from 'mcpscraper-memory-sdk'
17
+
18
+ const client = new MemoryClient({ apiKey: process.env.MCP_MEMORY_API_KEY! })
19
+
20
+ try {
21
+ const results = await client.memory.search({ query: 'q3 roadmap decisions' })
22
+ console.log(results.results)
23
+
24
+ const note = await client.memory.get({ path: 'projects/q3-plan' })
25
+ console.log(note)
26
+ } catch (err) {
27
+ if (err instanceof MemoryApiError) {
28
+ console.error('memory API error:', err.message, err.rpcCode, err.httpStatus)
29
+ } else {
30
+ throw err
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Namespaces
36
+
37
+ Methods are grouped by category, matching [`contracts/memory.tools.json`](../../contracts/memory.tools.json): `client.memory` (get/list/put/search/suggest/export/upload/deleteNote), `client.vaults`, `client.access` (keys, shares, invites), `client.channels`, `client.tables`, `client.schedule`, `client.webhooks`, `client.facts`, `client.recall`, `client.storage`, `client.video`, `client.library`, `client.capture`.
38
+
39
+ Every method's input/output types are generated from the live tool schemas (see `src/generated/`, produced by `npm run generate` at the repo root from `contracts/memory.tools.json`) — no hand-maintained duplicate types to drift out of sync.
40
+
41
+ ## Getting an API key
42
+
43
+ Issue one via the `access-issue-key` tool (or `client.access.issueKey(...)` once you have an initial key), or through the memory dashboard.
44
+
45
+ ## Errors
46
+
47
+ All failures — HTTP-level, JSON-RPC-level, and MCP tool-level (`isError: true`) — surface as a single `MemoryApiError` with `httpStatus`, `rpcCode`, and `data`/`toolError` fields depending on where the failure occurred.
48
+
49
+ ## See also
50
+
51
+ [Repo README](../../README.md) (multi-language examples with real sample output) · [`mcpscraper-sdk`](../scraper) (Node, also reaches these 85 tools via `client.memoryTools` using only a scraper key) · [`mcpscraper-memory-sdk` on PyPI](../memory-python) (Python) · [`mcpscraper-cli`](../cli)
package/dist/index.cjs ADDED
@@ -0,0 +1,510 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AccessNamespace: () => AccessNamespace,
24
+ CaptureNamespace: () => CaptureNamespace,
25
+ ChannelsNamespace: () => ChannelsNamespace,
26
+ FactsNamespace: () => FactsNamespace,
27
+ GraphNamespace: () => GraphNamespace,
28
+ LibraryNamespace: () => LibraryNamespace,
29
+ MemoryApiError: () => MemoryApiError,
30
+ MemoryClient: () => MemoryClient,
31
+ MemoryNamespace: () => MemoryNamespace,
32
+ RecallNamespace: () => RecallNamespace,
33
+ ScheduleNamespace: () => ScheduleNamespace,
34
+ StorageNamespace: () => StorageNamespace,
35
+ TablesNamespace: () => TablesNamespace,
36
+ TagsNamespace: () => TagsNamespace,
37
+ VaultsNamespace: () => VaultsNamespace,
38
+ VideoNamespace: () => VideoNamespace,
39
+ WebhooksNamespace: () => WebhooksNamespace
40
+ });
41
+ module.exports = __toCommonJS(index_exports);
42
+
43
+ // src/errors.ts
44
+ var MemoryApiError = class extends Error {
45
+ httpStatus;
46
+ rpcCode;
47
+ data;
48
+ toolError;
49
+ constructor(message, details = {}) {
50
+ super(message);
51
+ this.name = "MemoryApiError";
52
+ this.httpStatus = details.httpStatus;
53
+ this.rpcCode = details.rpcCode;
54
+ this.data = details.data;
55
+ this.toolError = details.toolError;
56
+ }
57
+ };
58
+
59
+ // src/generated/methods.ts
60
+ var AccessNamespace = class {
61
+ constructor(callTool) {
62
+ this.callTool = callTool;
63
+ }
64
+ callTool;
65
+ async issueKey(input) {
66
+ return this.callTool("issueKeyTool", input);
67
+ }
68
+ async listKeys(input) {
69
+ return this.callTool("listKeysTool", input);
70
+ }
71
+ async revokeKey(input) {
72
+ return this.callTool("revokeKeyTool", input);
73
+ }
74
+ async setScope(input) {
75
+ return this.callTool("setScopeTool", input);
76
+ }
77
+ async shareVault(input) {
78
+ return this.callTool("shareVaultTool", input);
79
+ }
80
+ async swapVault(input) {
81
+ return this.callTool("swapVaultTool", input);
82
+ }
83
+ async inviteAccount(input) {
84
+ return this.callTool("inviteAccountTool", input);
85
+ }
86
+ async switchAccount(input) {
87
+ return this.callTool("switchAccountTool", input);
88
+ }
89
+ async approveSender(input) {
90
+ return this.callTool("approveSenderTool", input);
91
+ }
92
+ async removeApprovedSender(input) {
93
+ return this.callTool("removeApprovedSenderTool", input);
94
+ }
95
+ async listApprovedSenders(input) {
96
+ return this.callTool("listApprovedSendersTool", input);
97
+ }
98
+ async inboxSettings(input) {
99
+ return this.callTool("inboxSettingsTool", input);
100
+ }
101
+ async shareNote(input) {
102
+ return this.callTool("shareNoteTool", input);
103
+ }
104
+ async noteInbox(input) {
105
+ return this.callTool("noteInboxTool", input);
106
+ }
107
+ async acceptShare(input) {
108
+ return this.callTool("acceptShareTool", input);
109
+ }
110
+ async declineShare(input) {
111
+ return this.callTool("declineShareTool", input);
112
+ }
113
+ async unlinkShare(input) {
114
+ return this.callTool("unlinkShareTool", input);
115
+ }
116
+ async revokeShare(input) {
117
+ return this.callTool("revokeShareTool", input);
118
+ }
119
+ async getChatLink(input) {
120
+ return this.callTool("getChatLinkTool", input);
121
+ }
122
+ async revokeChatLink(input) {
123
+ return this.callTool("revokeChatLinkTool", input);
124
+ }
125
+ async setAgentIdentity(input) {
126
+ return this.callTool("setAgentIdentityTool", input);
127
+ }
128
+ };
129
+ var VaultsNamespace = class {
130
+ constructor(callTool) {
131
+ this.callTool = callTool;
132
+ }
133
+ callTool;
134
+ async listSharedWithMe(input) {
135
+ return this.callTool("listSharedWithMeTool", input);
136
+ }
137
+ async listVaults(input) {
138
+ return this.callTool("listVaultsTool", input);
139
+ }
140
+ async addVault(input) {
141
+ return this.callTool("addVaultTool", input);
142
+ }
143
+ async createSecureVault(input) {
144
+ return this.callTool("createSecureVaultTool", input);
145
+ }
146
+ async deleteVault(input) {
147
+ return this.callTool("deleteVaultTool", input);
148
+ }
149
+ async provisionDefaults(input) {
150
+ return this.callTool("provisionDefaultsTool", input);
151
+ }
152
+ async getVaultContract(input) {
153
+ return this.callTool("getVaultContractTool", input);
154
+ }
155
+ async routeMemory(input) {
156
+ return this.callTool("routeMemoryTool", input);
157
+ }
158
+ };
159
+ var ChannelsNamespace = class {
160
+ constructor(callTool) {
161
+ this.callTool = callTool;
162
+ }
163
+ callTool;
164
+ async createChannel(input) {
165
+ return this.callTool("createChannelTool", input);
166
+ }
167
+ async postMessage(input) {
168
+ return this.callTool("postMessageTool", input);
169
+ }
170
+ async replyMessage(input) {
171
+ return this.callTool("replyMessageTool", input);
172
+ }
173
+ async listChannelMessages(input) {
174
+ return this.callTool("listChannelMessagesTool", input);
175
+ }
176
+ async reactMessage(input) {
177
+ return this.callTool("reactMessageTool", input);
178
+ }
179
+ async myMentions(input) {
180
+ return this.callTool("myMentionsTool", input);
181
+ }
182
+ async listChannelMembers(input) {
183
+ return this.callTool("listChannelMembersTool", input);
184
+ }
185
+ async removeChannelMember(input) {
186
+ return this.callTool("removeChannelMemberTool", input);
187
+ }
188
+ async pollChannel(input) {
189
+ return this.callTool("pollChannelTool", input);
190
+ }
191
+ async getMessageNote(input) {
192
+ return this.callTool("getMessageNoteTool", input);
193
+ }
194
+ };
195
+ var CaptureNamespace = class {
196
+ constructor(callTool) {
197
+ this.callTool = callTool;
198
+ }
199
+ callTool;
200
+ async memoryQuestions(input) {
201
+ return this.callTool("memoryQuestionsTool", input);
202
+ }
203
+ async prepareMemoryWrite(input) {
204
+ return this.callTool("prepareMemoryWriteTool", input);
205
+ }
206
+ async validateMemoryWrite(input) {
207
+ return this.callTool("validateMemoryWriteTool", input);
208
+ }
209
+ async memoryCapture(input) {
210
+ return this.callTool("memoryCaptureTool", input);
211
+ }
212
+ };
213
+ var LibraryNamespace = class {
214
+ constructor(callTool) {
215
+ this.callTool = callTool;
216
+ }
217
+ callTool;
218
+ async ingest(input) {
219
+ return this.callTool("libraryIngestTool", input);
220
+ }
221
+ };
222
+ var MemoryNamespace = class {
223
+ constructor(callTool) {
224
+ this.callTool = callTool;
225
+ }
226
+ callTool;
227
+ async export(input) {
228
+ return this.callTool("exportTool", input);
229
+ }
230
+ async get(input) {
231
+ return this.callTool("getTool", input);
232
+ }
233
+ async list(input) {
234
+ return this.callTool("listTool", input);
235
+ }
236
+ async put(input) {
237
+ return this.callTool("putTool", input);
238
+ }
239
+ async search(input) {
240
+ return this.callTool("searchTool", input);
241
+ }
242
+ async suggest(input) {
243
+ return this.callTool("suggestTool", input);
244
+ }
245
+ async upload(input) {
246
+ return this.callTool("uploadTool", input);
247
+ }
248
+ async deleteNote(input) {
249
+ return this.callTool("deleteNoteTool", input);
250
+ }
251
+ };
252
+ var TablesNamespace = class {
253
+ constructor(callTool) {
254
+ this.callTool = callTool;
255
+ }
256
+ callTool;
257
+ async create(input) {
258
+ return this.callTool("createTableTool", input);
259
+ }
260
+ async list(input) {
261
+ return this.callTool("listTablesTool", input);
262
+ }
263
+ async describe(input) {
264
+ return this.callTool("describeTableTool", input);
265
+ }
266
+ async insertRows(input) {
267
+ return this.callTool("insertTableRowsTool", input);
268
+ }
269
+ async query(input) {
270
+ return this.callTool("queryTableTool", input);
271
+ }
272
+ async deleteRows(input) {
273
+ return this.callTool("deleteTableRowsTool", input);
274
+ }
275
+ async drop(input) {
276
+ return this.callTool("dropTableTool", input);
277
+ }
278
+ };
279
+ var RecallNamespace = class {
280
+ constructor(callTool) {
281
+ this.callTool = callTool;
282
+ }
283
+ callTool;
284
+ async temporalRecall(input) {
285
+ return this.callTool("temporalRecallTool", input);
286
+ }
287
+ };
288
+ var TagsNamespace = class {
289
+ constructor(callTool) {
290
+ this.callTool = callTool;
291
+ }
292
+ callTool;
293
+ async listMemoryTags(input) {
294
+ return this.callTool("listTagsTool", input);
295
+ }
296
+ async resolveMemoryTags(input) {
297
+ return this.callTool("resolveTagsTool", input);
298
+ }
299
+ async upsertMemoryTag(input) {
300
+ return this.callTool("upsertTagTool", input);
301
+ }
302
+ };
303
+ var GraphNamespace = class {
304
+ constructor(callTool) {
305
+ this.callTool = callTool;
306
+ }
307
+ callTool;
308
+ async memoryBacklinks(input) {
309
+ return this.callTool("noteBacklinksTool", input);
310
+ }
311
+ async memoryGraphUniverse(input) {
312
+ return this.callTool("graphUniverseTool", input);
313
+ }
314
+ async memoryGraphPath(input) {
315
+ return this.callTool("graphPathTool", input);
316
+ }
317
+ };
318
+ var FactsNamespace = class {
319
+ constructor(callTool) {
320
+ this.callTool = callTool;
321
+ }
322
+ callTool;
323
+ async recordFact(input) {
324
+ return this.callTool("recordFactTool", input);
325
+ }
326
+ async history(input) {
327
+ return this.callTool("factHistoryTool", input);
328
+ }
329
+ };
330
+ var StorageNamespace = class {
331
+ constructor(callTool) {
332
+ this.callTool = callTool;
333
+ }
334
+ callTool;
335
+ async usage(input) {
336
+ return this.callTool("storageUsageTool", input);
337
+ }
338
+ async costUsage(input) {
339
+ return this.callTool("costUsageTool", input);
340
+ }
341
+ };
342
+ var ScheduleNamespace = class {
343
+ constructor(callTool) {
344
+ this.callTool = callTool;
345
+ }
346
+ callTool;
347
+ async createScheduledAction(input) {
348
+ return this.callTool("createScheduledActionTool", input);
349
+ }
350
+ async listScheduledActions(input) {
351
+ return this.callTool("listScheduledActionsTool", input);
352
+ }
353
+ async pauseScheduledAction(input) {
354
+ return this.callTool("pauseScheduledActionTool", input);
355
+ }
356
+ async resumeScheduledAction(input) {
357
+ return this.callTool("resumeScheduledActionTool", input);
358
+ }
359
+ async deleteScheduledAction(input) {
360
+ return this.callTool("deleteScheduledActionTool", input);
361
+ }
362
+ async setScheduleEntitlement(input) {
363
+ return this.callTool("setScheduleEntitlementTool", input);
364
+ }
365
+ async getScheduleStatus(input) {
366
+ return this.callTool("getScheduleStatusTool", input);
367
+ }
368
+ async proposeScheduledAction(input) {
369
+ return this.callTool("proposeScheduledActionTool", input);
370
+ }
371
+ async getScheduleLink(input) {
372
+ return this.callTool("getScheduleLinkTool", input);
373
+ }
374
+ async revokeScheduleLink(input) {
375
+ return this.callTool("revokeScheduleLinkTool", input);
376
+ }
377
+ };
378
+ var WebhooksNamespace = class {
379
+ constructor(callTool) {
380
+ this.callTool = callTool;
381
+ }
382
+ callTool;
383
+ async createWebhook(input) {
384
+ return this.callTool("createWebhookTool", input);
385
+ }
386
+ async listWebhooks(input) {
387
+ return this.callTool("listWebhooksTool", input);
388
+ }
389
+ async revokeWebhook(input) {
390
+ return this.callTool("revokeWebhookTool", input);
391
+ }
392
+ };
393
+ var VideoNamespace = class {
394
+ constructor(callTool) {
395
+ this.callTool = callTool;
396
+ }
397
+ callTool;
398
+ async analyzeStart(input) {
399
+ return this.callTool("videoAnalyzeStartTool", input);
400
+ }
401
+ async analyzeStatus(input) {
402
+ return this.callTool("videoAnalyzeStatusTool", input);
403
+ }
404
+ };
405
+
406
+ // src/client.ts
407
+ var MemoryClient = class {
408
+ access;
409
+ capture;
410
+ channels;
411
+ facts;
412
+ graph;
413
+ library;
414
+ memory;
415
+ recall;
416
+ schedule;
417
+ storage;
418
+ tables;
419
+ tags;
420
+ vaults;
421
+ video;
422
+ webhooks;
423
+ apiKey;
424
+ baseUrl;
425
+ fetchImpl;
426
+ rpcId = 0;
427
+ constructor(options) {
428
+ this.apiKey = options.apiKey;
429
+ this.baseUrl = options.baseUrl ?? "https://memory.mcpscraper.dev";
430
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
431
+ const callTool = this.callTool.bind(this);
432
+ this.access = new AccessNamespace(callTool);
433
+ this.capture = new CaptureNamespace(callTool);
434
+ this.channels = new ChannelsNamespace(callTool);
435
+ this.facts = new FactsNamespace(callTool);
436
+ this.graph = new GraphNamespace(callTool);
437
+ this.library = new LibraryNamespace(callTool);
438
+ this.memory = new MemoryNamespace(callTool);
439
+ this.recall = new RecallNamespace(callTool);
440
+ this.schedule = new ScheduleNamespace(callTool);
441
+ this.storage = new StorageNamespace(callTool);
442
+ this.tables = new TablesNamespace(callTool);
443
+ this.tags = new TagsNamespace(callTool);
444
+ this.vaults = new VaultsNamespace(callTool);
445
+ this.video = new VideoNamespace(callTool);
446
+ this.webhooks = new WebhooksNamespace(callTool);
447
+ }
448
+ async callTool(name, args) {
449
+ const res = await this.fetchImpl(`${this.baseUrl}/mcp`, {
450
+ method: "POST",
451
+ headers: {
452
+ "content-type": "application/json",
453
+ accept: "application/json, text/event-stream",
454
+ authorization: `Bearer ${this.apiKey}`
455
+ },
456
+ body: JSON.stringify({
457
+ jsonrpc: "2.0",
458
+ id: ++this.rpcId,
459
+ method: "tools/call",
460
+ params: { name, arguments: args }
461
+ })
462
+ });
463
+ if (!res.ok) {
464
+ const body = await res.text().catch(() => void 0);
465
+ throw new MemoryApiError(`HTTP ${res.status} calling tool "${name}"`, { httpStatus: res.status, data: body });
466
+ }
467
+ const payload = await res.json();
468
+ if (payload.error) {
469
+ throw new MemoryApiError(payload.error.message, { rpcCode: payload.error.code, data: payload.error.data });
470
+ }
471
+ const result = payload.result;
472
+ const textBlock = result?.content?.find((block) => block.type === "text")?.text;
473
+ let parsed = textBlock;
474
+ if (typeof textBlock === "string") {
475
+ try {
476
+ parsed = JSON.parse(textBlock);
477
+ } catch {
478
+ parsed = textBlock;
479
+ }
480
+ }
481
+ if (result?.structuredContent !== void 0) {
482
+ parsed = result.structuredContent;
483
+ }
484
+ if (result?.isError) {
485
+ const message = parsed && typeof parsed === "object" && "message" in parsed ? String(parsed.message) : typeof parsed === "string" ? parsed : `Tool "${name}" failed`;
486
+ throw new MemoryApiError(message, { toolError: parsed });
487
+ }
488
+ return parsed;
489
+ }
490
+ };
491
+ // Annotate the CommonJS export names for ESM import in node:
492
+ 0 && (module.exports = {
493
+ AccessNamespace,
494
+ CaptureNamespace,
495
+ ChannelsNamespace,
496
+ FactsNamespace,
497
+ GraphNamespace,
498
+ LibraryNamespace,
499
+ MemoryApiError,
500
+ MemoryClient,
501
+ MemoryNamespace,
502
+ RecallNamespace,
503
+ ScheduleNamespace,
504
+ StorageNamespace,
505
+ TablesNamespace,
506
+ TagsNamespace,
507
+ VaultsNamespace,
508
+ VideoNamespace,
509
+ WebhooksNamespace
510
+ });