mnemosyne-core 2.0.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.
Files changed (47) hide show
  1. package/README.md +176 -0
  2. package/dist/Store-N3j0Vaj6.d.mts +320 -0
  3. package/dist/Store-N3j0Vaj6.d.ts +320 -0
  4. package/dist/cli/index.d.mts +8 -0
  5. package/dist/cli/index.d.ts +8 -0
  6. package/dist/cli/index.js +16352 -0
  7. package/dist/cli/index.js.map +1 -0
  8. package/dist/cli/index.mjs +16348 -0
  9. package/dist/cli/index.mjs.map +1 -0
  10. package/dist/mcp/index.d.mts +94 -0
  11. package/dist/mcp/index.d.ts +94 -0
  12. package/dist/mcp/index.js +401 -0
  13. package/dist/mcp/index.js.map +1 -0
  14. package/dist/mcp/index.mjs +371 -0
  15. package/dist/mcp/index.mjs.map +1 -0
  16. package/dist/sdk/index.d.mts +102 -0
  17. package/dist/sdk/index.d.ts +102 -0
  18. package/dist/sdk/index.js +143 -0
  19. package/dist/sdk/index.js.map +1 -0
  20. package/dist/sdk/index.mjs +116 -0
  21. package/dist/sdk/index.mjs.map +1 -0
  22. package/dist/server/api.d.mts +14 -0
  23. package/dist/server/api.d.ts +14 -0
  24. package/dist/server/api.js +1699 -0
  25. package/dist/server/api.js.map +1 -0
  26. package/dist/server/api.mjs +1669 -0
  27. package/dist/server/api.mjs.map +1 -0
  28. package/dist/server/index.d.mts +111 -0
  29. package/dist/server/index.d.ts +111 -0
  30. package/dist/server/index.js +12446 -0
  31. package/dist/server/index.js.map +1 -0
  32. package/dist/server/index.mjs +12442 -0
  33. package/dist/server/index.mjs.map +1 -0
  34. package/dist/server/websocket.d.mts +23 -0
  35. package/dist/server/websocket.d.ts +23 -0
  36. package/dist/server/websocket.js +3807 -0
  37. package/dist/server/websocket.js.map +1 -0
  38. package/dist/server/websocket.mjs +3798 -0
  39. package/dist/server/websocket.mjs.map +1 -0
  40. package/dist/sharp-win32-x64-CXV3GA3G.node +0 -0
  41. package/dist/ws/index.d.mts +22 -0
  42. package/dist/ws/index.d.ts +22 -0
  43. package/dist/ws/index.js +3827 -0
  44. package/dist/ws/index.js.map +1 -0
  45. package/dist/ws/index.mjs +3817 -0
  46. package/dist/ws/index.mjs.map +1 -0
  47. package/package.json +69 -0
@@ -0,0 +1,94 @@
1
+ import { S as Store } from '../Store-N3j0Vaj6.mjs';
2
+ import * as http from 'http';
3
+ import 'better-sqlite3';
4
+
5
+ /**
6
+ * MCP Protocol Types
7
+ */
8
+ interface JsonRpcRequest {
9
+ jsonrpc: "2.0";
10
+ id: string | number | null;
11
+ method: string;
12
+ params?: any;
13
+ }
14
+ interface JsonRpcResponse {
15
+ jsonrpc: "2.0";
16
+ id: string | number | null;
17
+ result?: any;
18
+ error?: {
19
+ code: number;
20
+ message: string;
21
+ data?: any;
22
+ };
23
+ }
24
+ interface McpTool {
25
+ name: string;
26
+ description: string;
27
+ inputSchema: any;
28
+ handler: (args: any, store: Store) => any;
29
+ }
30
+
31
+ /**
32
+ * MCP Server
33
+ * JSON-RPC handler for Model Context Protocol.
34
+ */
35
+
36
+ declare class McpServer {
37
+ private store;
38
+ private toolMap;
39
+ constructor(store: Store);
40
+ /**
41
+ * Returns `null` for notifications (no response needed).
42
+ */
43
+ handleRequest(req: JsonRpcRequest): JsonRpcResponse | null;
44
+ getManifest(): {
45
+ name: string;
46
+ version: string;
47
+ description: string;
48
+ protocol: string;
49
+ transport: string[];
50
+ endpoints: {
51
+ sse: string;
52
+ messages: string;
53
+ };
54
+ tools: {
55
+ name: string;
56
+ description: string;
57
+ }[];
58
+ };
59
+ private ok;
60
+ private err;
61
+ }
62
+
63
+ /**
64
+ * MCP Tool Definitions
65
+ * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)
66
+ */
67
+
68
+ declare const TOOLS: McpTool[];
69
+
70
+ declare class McpSseTransport {
71
+ private server;
72
+ private sessions;
73
+ private sessionCounter;
74
+ constructor(server: McpServer);
75
+ handleSse(req: http.IncomingMessage, res: http.ServerResponse): void;
76
+ handleMessage(req: http.IncomingMessage, res: http.ServerResponse, body: any): void;
77
+ private sendSse;
78
+ }
79
+
80
+ /**
81
+ * MCP Stdio Transport
82
+ * Line-delimited JSON-RPC over stdin/stdout.
83
+ * This is what Claude Desktop uses to communicate with MCP servers.
84
+ */
85
+
86
+ declare class McpStdioTransport {
87
+ private server;
88
+ private buffer;
89
+ constructor(server: McpServer);
90
+ start(): void;
91
+ send(message: JsonRpcResponse): void;
92
+ }
93
+
94
+ export { type JsonRpcRequest, type JsonRpcResponse, McpServer, McpSseTransport, McpStdioTransport, type McpTool, TOOLS };
@@ -0,0 +1,94 @@
1
+ import { S as Store } from '../Store-N3j0Vaj6.js';
2
+ import * as http from 'http';
3
+ import 'better-sqlite3';
4
+
5
+ /**
6
+ * MCP Protocol Types
7
+ */
8
+ interface JsonRpcRequest {
9
+ jsonrpc: "2.0";
10
+ id: string | number | null;
11
+ method: string;
12
+ params?: any;
13
+ }
14
+ interface JsonRpcResponse {
15
+ jsonrpc: "2.0";
16
+ id: string | number | null;
17
+ result?: any;
18
+ error?: {
19
+ code: number;
20
+ message: string;
21
+ data?: any;
22
+ };
23
+ }
24
+ interface McpTool {
25
+ name: string;
26
+ description: string;
27
+ inputSchema: any;
28
+ handler: (args: any, store: Store) => any;
29
+ }
30
+
31
+ /**
32
+ * MCP Server
33
+ * JSON-RPC handler for Model Context Protocol.
34
+ */
35
+
36
+ declare class McpServer {
37
+ private store;
38
+ private toolMap;
39
+ constructor(store: Store);
40
+ /**
41
+ * Returns `null` for notifications (no response needed).
42
+ */
43
+ handleRequest(req: JsonRpcRequest): JsonRpcResponse | null;
44
+ getManifest(): {
45
+ name: string;
46
+ version: string;
47
+ description: string;
48
+ protocol: string;
49
+ transport: string[];
50
+ endpoints: {
51
+ sse: string;
52
+ messages: string;
53
+ };
54
+ tools: {
55
+ name: string;
56
+ description: string;
57
+ }[];
58
+ };
59
+ private ok;
60
+ private err;
61
+ }
62
+
63
+ /**
64
+ * MCP Tool Definitions
65
+ * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)
66
+ */
67
+
68
+ declare const TOOLS: McpTool[];
69
+
70
+ declare class McpSseTransport {
71
+ private server;
72
+ private sessions;
73
+ private sessionCounter;
74
+ constructor(server: McpServer);
75
+ handleSse(req: http.IncomingMessage, res: http.ServerResponse): void;
76
+ handleMessage(req: http.IncomingMessage, res: http.ServerResponse, body: any): void;
77
+ private sendSse;
78
+ }
79
+
80
+ /**
81
+ * MCP Stdio Transport
82
+ * Line-delimited JSON-RPC over stdin/stdout.
83
+ * This is what Claude Desktop uses to communicate with MCP servers.
84
+ */
85
+
86
+ declare class McpStdioTransport {
87
+ private server;
88
+ private buffer;
89
+ constructor(server: McpServer);
90
+ start(): void;
91
+ send(message: JsonRpcResponse): void;
92
+ }
93
+
94
+ export { type JsonRpcRequest, type JsonRpcResponse, McpServer, McpSseTransport, McpStdioTransport, type McpTool, TOOLS };
@@ -0,0 +1,401 @@
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/mcp/index.ts
21
+ var mcp_exports = {};
22
+ __export(mcp_exports, {
23
+ McpServer: () => McpServer,
24
+ McpSseTransport: () => McpSseTransport,
25
+ McpStdioTransport: () => McpStdioTransport,
26
+ TOOLS: () => TOOLS
27
+ });
28
+ module.exports = __toCommonJS(mcp_exports);
29
+
30
+ // src/mcp/tools.ts
31
+ var TOOLS = [
32
+ {
33
+ name: "nexus_list_projects",
34
+ description: "List all projects in the Mnemosyne knowledge base.",
35
+ inputSchema: { type: "object", properties: {} },
36
+ handler: (_args, store) => {
37
+ return { projects: store.getProjects().map((p) => ({ id: p.id, name: p.name, description: p.description, atomCount: store.getAtomsByProject(p.id).length })) };
38
+ }
39
+ },
40
+ {
41
+ name: "nexus_search",
42
+ description: "Search atoms and blocks by keyword. Returns ranked results.",
43
+ inputSchema: {
44
+ type: "object",
45
+ properties: {
46
+ query: { type: "string", description: "Search query" },
47
+ project: { type: "string", description: "Project name or ID (optional)" },
48
+ limit: { type: "number", description: "Max results (default 10)" }
49
+ },
50
+ required: ["query"]
51
+ },
52
+ handler: (args, store) => {
53
+ const projectId = args.project ? store.getProjectByName(args.project)?.id || args.project : "";
54
+ const results = store.search(projectId, args.query, args.limit || 10);
55
+ return { query: args.query, count: results.length, results };
56
+ }
57
+ },
58
+ {
59
+ name: "nexus_read_atom",
60
+ description: "Read an atom by ID or title. Returns atom details, blocks, children, and bonds.",
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: {
64
+ id: { type: "string", description: "Atom UUID" },
65
+ title: { type: "string", description: "Atom title (alternative to id)" },
66
+ project: { type: "string", description: "Project name (required if searching by title)" }
67
+ },
68
+ required: []
69
+ },
70
+ handler: (args, store) => {
71
+ let atom = args.id ? store.getAtom(args.id) : void 0;
72
+ if (!atom && args.title && args.project) {
73
+ const projectId = store.getProjectByName(args.project)?.id || args.project;
74
+ atom = store.getAtomsByProject(projectId).find((a) => a.title === args.title);
75
+ }
76
+ if (!atom) throw new Error("Atom not found");
77
+ const children = store.getAtomChildren(atom.id).map((a) => ({ id: a.id, title: a.title, type: a.metadata?.type || "text" }));
78
+ const blocks = store.getBlocksByAtom(atom.id);
79
+ const bonds = store.getBondsByAtom(atom.id);
80
+ return { atom, children, blocks, bonds };
81
+ }
82
+ },
83
+ {
84
+ name: "nexus_create_atom",
85
+ description: "Create a new atom in a project.",
86
+ inputSchema: {
87
+ type: "object",
88
+ properties: {
89
+ project: { type: "string", description: "Project name or ID" },
90
+ title: { type: "string", description: "Atom title/path" },
91
+ type: { type: "string", description: "Atom type (text, memory, stream, thought, task)" },
92
+ parent_id: { type: "string", description: "Parent atom ID (optional)" },
93
+ tags: { type: "array", items: { type: "string" }, description: "Tags (optional)" },
94
+ assistant_id: { type: "string", description: "Creator assistant ID" }
95
+ },
96
+ required: ["project", "title"]
97
+ },
98
+ handler: (args, store) => {
99
+ const project = store.getProjectByName(args.project) || store.getProject(args.project);
100
+ if (!project) throw new Error("Project not found");
101
+ const assistantId = args.assistant_id || "mcp-assistant";
102
+ const atom = store.createAtom(project.id, args.title, args.type || "text", assistantId, {
103
+ parentId: args.parent_id,
104
+ tags: args.tags
105
+ });
106
+ return { success: true, atom };
107
+ }
108
+ },
109
+ {
110
+ name: "nexus_update_atom",
111
+ description: "Update an atom's title or parent.",
112
+ inputSchema: {
113
+ type: "object",
114
+ properties: {
115
+ id: { type: "string", description: "Atom UUID" },
116
+ title: { type: "string", description: "New title" },
117
+ parent_id: { type: ["string", "null"], description: "New parent ID or null for root" },
118
+ assistant_id: { type: "string", description: "Updater assistant ID" }
119
+ },
120
+ required: ["id"]
121
+ },
122
+ handler: (args, store) => {
123
+ const assistantId = args.assistant_id || "mcp-assistant";
124
+ if (args.parent_id !== void 0) {
125
+ const updated2 = store.updateAtomParent(args.id, args.parent_id, assistantId);
126
+ if (!updated2) throw new Error("Invalid parent or atom not found");
127
+ }
128
+ const updated = store.updateAtom(args.id, { title: args.title }, assistantId);
129
+ return { success: true, atom: updated || store.getAtom(args.id) };
130
+ }
131
+ },
132
+ {
133
+ name: "nexus_create_bond",
134
+ description: "Create a bond (graph connection) between two atoms.",
135
+ inputSchema: {
136
+ type: "object",
137
+ properties: {
138
+ source_id: { type: "string", description: "Source atom ID" },
139
+ target_id: { type: "string", description: "Target atom ID" },
140
+ label: { type: "string", description: "Bond label (default: connects)" },
141
+ color: { type: "string", description: "Hex color (optional)" }
142
+ },
143
+ required: ["source_id", "target_id"]
144
+ },
145
+ handler: (args, store) => {
146
+ const bond = store.createBond(args.source_id, args.target_id, args.label || "connects", args.color);
147
+ return { success: true, bond };
148
+ }
149
+ },
150
+ {
151
+ name: "nexus_request_checkout",
152
+ description: "Request an exclusive checkout (lock) on an atom.",
153
+ inputSchema: {
154
+ type: "object",
155
+ properties: {
156
+ atom_id: { type: "string", description: "Atom UUID" },
157
+ assistant_id: { type: "string", description: "Assistant requesting checkout" },
158
+ reason: { type: "string", description: "Reason for checkout" }
159
+ },
160
+ required: ["atom_id", "assistant_id"]
161
+ },
162
+ handler: (args, store) => {
163
+ const result = store.checkout(args.atom_id, args.assistant_id, "exclusive", args.reason || "");
164
+ return result;
165
+ }
166
+ },
167
+ {
168
+ name: "nexus_release_checkout",
169
+ description: "Release a checkout (unlock) on an atom.",
170
+ inputSchema: {
171
+ type: "object",
172
+ properties: {
173
+ atom_id: { type: "string", description: "Atom UUID" },
174
+ assistant_id: { type: "string", description: "Assistant releasing checkout" }
175
+ },
176
+ required: ["atom_id", "assistant_id"]
177
+ },
178
+ handler: (args, store) => {
179
+ const success = store.releaseCheckout(args.atom_id, args.assistant_id);
180
+ return { success };
181
+ }
182
+ },
183
+ {
184
+ name: "nexus_subscribe_to_atom",
185
+ description: "Subscribe to real-time updates for an atom via WebSocket.",
186
+ inputSchema: {
187
+ type: "object",
188
+ properties: {
189
+ atom_id: { type: "string", description: "Atom UUID to subscribe to" }
190
+ },
191
+ required: ["atom_id"]
192
+ },
193
+ handler: (args, _store) => {
194
+ return { success: true, wsEndpoint: "ws://localhost:7321/ws", atom_id: args.atom_id, message: "Connect via WebSocket and send { type: 'subscribe', atomId: '<id>' }" };
195
+ }
196
+ },
197
+ {
198
+ name: "nexus_batch",
199
+ description: "Execute multiple MCP tools in a single request. Reduces round-trip token waste.",
200
+ inputSchema: {
201
+ type: "object",
202
+ properties: {
203
+ operations: {
204
+ type: "array",
205
+ items: {
206
+ type: "object",
207
+ properties: {
208
+ tool: { type: "string", description: "Tool name to call" },
209
+ params: { type: "object", description: "Parameters for the tool" }
210
+ },
211
+ required: ["tool"]
212
+ },
213
+ description: "Ordered list of tool calls"
214
+ },
215
+ stop_on_error: { type: "boolean", description: "If true, stop at first error. Default: false", default: false }
216
+ },
217
+ required: ["operations"]
218
+ },
219
+ handler: (args, store) => {
220
+ const operations = args.operations || [];
221
+ const stopOnError = args.stop_on_error ?? false;
222
+ const results = [];
223
+ const toolMap = /* @__PURE__ */ new Map();
224
+ for (const t of TOOLS) toolMap.set(t.name, t);
225
+ for (let i = 0; i < operations.length; i++) {
226
+ const op = operations[i];
227
+ const tool = toolMap.get(op.tool);
228
+ if (!tool) {
229
+ results.push({ index: i, tool: op.tool, error: `Tool not found: ${op.tool}` });
230
+ if (stopOnError) break;
231
+ continue;
232
+ }
233
+ try {
234
+ const result = tool.handler(op.params || {}, store);
235
+ results.push({ index: i, tool: op.tool, success: true, result });
236
+ } catch (err) {
237
+ results.push({ index: i, tool: op.tool, error: err.message });
238
+ if (stopOnError) break;
239
+ }
240
+ }
241
+ return { count: operations.length, completed: results.length, results };
242
+ }
243
+ }
244
+ ];
245
+
246
+ // src/mcp/server.ts
247
+ var McpServer = class {
248
+ store;
249
+ toolMap = /* @__PURE__ */ new Map();
250
+ constructor(store) {
251
+ this.store = store;
252
+ for (const t of TOOLS) this.toolMap.set(t.name, t);
253
+ }
254
+ /**
255
+ * Returns `null` for notifications (no response needed).
256
+ */
257
+ handleRequest(req) {
258
+ if (req.id === null || req.id === void 0) {
259
+ return null;
260
+ }
261
+ try {
262
+ switch (req.method) {
263
+ case "initialize":
264
+ return this.ok(req.id, {
265
+ protocolVersion: "2024-11-05",
266
+ capabilities: { tools: {}, resources: {}, prompts: {} },
267
+ serverInfo: { name: "mnemosyne-mcp", version: "2.0.0" }
268
+ });
269
+ case "tools/list":
270
+ return this.ok(req.id, {
271
+ tools: TOOLS.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }))
272
+ });
273
+ case "tools/call": {
274
+ const { name, arguments: args } = req.params || {};
275
+ const tool = this.toolMap.get(name);
276
+ if (!tool) return this.err(req.id, -32601, `Tool not found: ${name}`);
277
+ const result = tool.handler(args || {}, this.store);
278
+ return this.ok(req.id, { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] });
279
+ }
280
+ case "resources/list":
281
+ return this.ok(req.id, { resources: [] });
282
+ case "prompts/list":
283
+ return this.ok(req.id, { prompts: [] });
284
+ default:
285
+ return this.err(req.id, -32601, `Method not found: ${req.method}`);
286
+ }
287
+ } catch (e) {
288
+ return this.err(req.id, -32603, e.message);
289
+ }
290
+ }
291
+ getManifest() {
292
+ return {
293
+ name: "Mnemosyne",
294
+ version: "2.0.0",
295
+ description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
296
+ protocol: "mcp",
297
+ transport: ["stdio", "sse"],
298
+ endpoints: {
299
+ sse: "/mcp/sse",
300
+ messages: "/mcp/messages"
301
+ },
302
+ tools: TOOLS.map((t) => ({ name: t.name, description: t.description }))
303
+ };
304
+ }
305
+ ok(id, result) {
306
+ return { jsonrpc: "2.0", id, result };
307
+ }
308
+ err(id, code, message) {
309
+ return { jsonrpc: "2.0", id, error: { code, message } };
310
+ }
311
+ };
312
+
313
+ // src/mcp/sse.ts
314
+ var McpSseTransport = class {
315
+ server;
316
+ sessions = /* @__PURE__ */ new Map();
317
+ sessionCounter = 0;
318
+ constructor(server) {
319
+ this.server = server;
320
+ }
321
+ handleSse(req, res) {
322
+ const id = `sess_${++this.sessionCounter}_${Date.now()}`;
323
+ res.writeHead(200, {
324
+ "Content-Type": "text/event-stream",
325
+ "Cache-Control": "no-cache",
326
+ "Connection": "keep-alive"
327
+ });
328
+ this.sessions.set(id, { id, res });
329
+ this.sendSse(id, "endpoint", "/mcp/messages?session_id=" + id);
330
+ req.on("close", () => this.sessions.delete(id));
331
+ }
332
+ handleMessage(req, res, body) {
333
+ const url = new URL(req.url || "/", `http://${req.headers.host}`);
334
+ const sessionId = url.searchParams.get("session_id") || "";
335
+ const request = body;
336
+ if (!request || request.jsonrpc !== "2.0") {
337
+ res.writeHead(400, { "Content-Type": "application/json" });
338
+ res.end(JSON.stringify({ error: "invalid_jsonrpc" }));
339
+ return;
340
+ }
341
+ const response = this.server.handleRequest(request);
342
+ if (!response) {
343
+ res.writeHead(200, { "Content-Type": "application/json" });
344
+ res.end("{}");
345
+ return;
346
+ }
347
+ res.writeHead(200, { "Content-Type": "application/json" });
348
+ res.end(JSON.stringify(response));
349
+ if (sessionId) this.sendSse(sessionId, "message", JSON.stringify(response));
350
+ }
351
+ sendSse(sessionId, event, data) {
352
+ const session = this.sessions.get(sessionId);
353
+ if (!session) return;
354
+ session.res.write(`event: ${event}
355
+ data: ${data}
356
+
357
+ `);
358
+ }
359
+ };
360
+
361
+ // src/mcp/stdio.ts
362
+ var McpStdioTransport = class {
363
+ server;
364
+ buffer = "";
365
+ constructor(server) {
366
+ this.server = server;
367
+ }
368
+ start() {
369
+ process.stdin.setEncoding("utf8");
370
+ process.stdin.resume();
371
+ process.stdin.on("data", (chunk) => {
372
+ this.buffer += chunk;
373
+ const lines = this.buffer.split("\n");
374
+ this.buffer = lines.pop() || "";
375
+ for (const line of lines) {
376
+ if (!line.trim()) continue;
377
+ try {
378
+ const request = JSON.parse(line);
379
+ const response = this.server.handleRequest(request);
380
+ if (response) this.send(response);
381
+ } catch (err) {
382
+ this.send({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error: " + err.message } });
383
+ }
384
+ }
385
+ });
386
+ process.stdin.on("end", () => {
387
+ process.exit(0);
388
+ });
389
+ }
390
+ send(message) {
391
+ process.stdout.write(JSON.stringify(message) + "\n");
392
+ }
393
+ };
394
+ // Annotate the CommonJS export names for ESM import in node:
395
+ 0 && (module.exports = {
396
+ McpServer,
397
+ McpSseTransport,
398
+ McpStdioTransport,
399
+ TOOLS
400
+ });
401
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/mcp/index.ts","../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["export { McpServer } from \"./server.js\";\nexport { TOOLS } from \"./tools.js\";\nexport { McpSseTransport } from \"./sse.js\";\nexport { McpStdioTransport } from \"./stdio.js\";\nexport type { McpTool, JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n","/**\n * MCP Tool Definitions\n * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport type { McpTool } from \"./types.js\";\n\nexport const TOOLS: McpTool[] = [\n {\n name: \"nexus_list_projects\",\n description: \"List all projects in the Mnemosyne knowledge base.\",\n inputSchema: { type: \"object\", properties: {} },\n handler: (_args, store) => {\n return { projects: store.getProjects().map(p => ({ id: p.id, name: p.name, description: p.description, atomCount: store.getAtomsByProject(p.id).length })) };\n },\n },\n {\n name: \"nexus_search\",\n description: \"Search atoms and blocks by keyword. Returns ranked results.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n project: { type: \"string\", description: \"Project name or ID (optional)\" },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n handler: (args, store) => {\n const projectId = args.project ? store.getProjectByName(args.project)?.id || args.project : \"\";\n const results = store.search(projectId, args.query, args.limit || 10);\n return { query: args.query, count: results.length, results };\n },\n },\n {\n name: \"nexus_read_atom\",\n description: \"Read an atom by ID or title. Returns atom details, blocks, children, and bonds.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"Atom title (alternative to id)\" },\n project: { type: \"string\", description: \"Project name (required if searching by title)\" },\n },\n required: [],\n },\n handler: (args, store) => {\n let atom = args.id ? store.getAtom(args.id) : undefined;\n if (!atom && args.title && args.project) {\n const projectId = store.getProjectByName(args.project)?.id || args.project;\n atom = store.getAtomsByProject(projectId).find(a => a.title === args.title);\n }\n if (!atom) throw new Error(\"Atom not found\");\n const children = store.getAtomChildren(atom.id).map(a => ({ id: a.id, title: a.title, type: a.metadata?.type || \"text\" }));\n const blocks = store.getBlocksByAtom(atom.id);\n const bonds = store.getBondsByAtom(atom.id);\n return { atom, children, blocks, bonds };\n },\n },\n {\n name: \"nexus_create_atom\",\n description: \"Create a new atom in a project.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project name or ID\" },\n title: { type: \"string\", description: \"Atom title/path\" },\n type: { type: \"string\", description: \"Atom type (text, memory, stream, thought, task)\" },\n parent_id: { type: \"string\", description: \"Parent atom ID (optional)\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"Tags (optional)\" },\n assistant_id: { type: \"string\", description: \"Creator assistant ID\" },\n },\n required: [\"project\", \"title\"],\n },\n handler: (args, store) => {\n const project = store.getProjectByName(args.project) || store.getProject(args.project);\n if (!project) throw new Error(\"Project not found\");\n const assistantId = args.assistant_id || \"mcp-assistant\";\n const atom = store.createAtom(project.id, args.title, args.type || \"text\", assistantId, {\n parentId: args.parent_id,\n tags: args.tags,\n });\n return { success: true, atom };\n },\n },\n {\n name: \"nexus_update_atom\",\n description: \"Update an atom's title or parent.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"New title\" },\n parent_id: { type: [\"string\", \"null\"], description: \"New parent ID or null for root\" },\n assistant_id: { type: \"string\", description: \"Updater assistant ID\" },\n },\n required: [\"id\"],\n },\n handler: (args, store) => {\n const assistantId = args.assistant_id || \"mcp-assistant\";\n if (args.parent_id !== undefined) {\n const updated = store.updateAtomParent(args.id, args.parent_id, assistantId);\n if (!updated) throw new Error(\"Invalid parent or atom not found\");\n }\n const updated = store.updateAtom(args.id, { title: args.title }, assistantId);\n return { success: true, atom: updated || store.getAtom(args.id) };\n },\n },\n {\n name: \"nexus_create_bond\",\n description: \"Create a bond (graph connection) between two atoms.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source_id: { type: \"string\", description: \"Source atom ID\" },\n target_id: { type: \"string\", description: \"Target atom ID\" },\n label: { type: \"string\", description: \"Bond label (default: connects)\" },\n color: { type: \"string\", description: \"Hex color (optional)\" },\n },\n required: [\"source_id\", \"target_id\"],\n },\n handler: (args, store) => {\n const bond = store.createBond(args.source_id, args.target_id, args.label || \"connects\", args.color);\n return { success: true, bond };\n },\n },\n {\n name: \"nexus_request_checkout\",\n description: \"Request an exclusive checkout (lock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant requesting checkout\" },\n reason: { type: \"string\", description: \"Reason for checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const result = store.checkout(args.atom_id, args.assistant_id, \"exclusive\", args.reason || \"\");\n return result;\n },\n },\n {\n name: \"nexus_release_checkout\",\n description: \"Release a checkout (unlock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant releasing checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const success = store.releaseCheckout(args.atom_id, args.assistant_id);\n return { success };\n },\n },\n {\n name: \"nexus_subscribe_to_atom\",\n description: \"Subscribe to real-time updates for an atom via WebSocket.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID to subscribe to\" },\n },\n required: [\"atom_id\"],\n },\n handler: (args, _store) => {\n return { success: true, wsEndpoint: \"ws://localhost:7321/ws\", atom_id: args.atom_id, message: \"Connect via WebSocket and send { type: 'subscribe', atomId: '<id>' }\" };\n },\n },\n {\n name: \"nexus_batch\",\n description: \"Execute multiple MCP tools in a single request. Reduces round-trip token waste.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operations: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n tool: { type: \"string\", description: \"Tool name to call\" },\n params: { type: \"object\", description: \"Parameters for the tool\" },\n },\n required: [\"tool\"],\n },\n description: \"Ordered list of tool calls\",\n },\n stop_on_error: { type: \"boolean\", description: \"If true, stop at first error. Default: false\", default: false },\n },\n required: [\"operations\"],\n },\n handler: (args, store) => {\n const operations = args.operations || [];\n const stopOnError = args.stop_on_error ?? false;\n const results: any[] = [];\n const toolMap = new Map<string, McpTool>();\n for (const t of TOOLS) toolMap.set(t.name, t);\n\n for (let i = 0; i < operations.length; i++) {\n const op = operations[i];\n const tool = toolMap.get(op.tool);\n if (!tool) {\n results.push({ index: i, tool: op.tool, error: `Tool not found: ${op.tool}` });\n if (stopOnError) break;\n continue;\n }\n try {\n const result = tool.handler(op.params || {}, store);\n results.push({ index: i, tool: op.tool, success: true, result });\n } catch (err: any) {\n results.push({ index: i, tool: op.tool, error: err.message });\n if (stopOnError) break;\n }\n }\n return { count: operations.length, completed: results.length, results };\n },\n },\n];\n","/**\n * MCP Server\n * JSON-RPC handler for Model Context Protocol.\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport { TOOLS } from \"./tools.js\";\nimport type { JsonRpcRequest, JsonRpcResponse, McpTool } from \"./types.js\";\n\nexport class McpServer {\n private store: Store;\n private toolMap = new Map<string, McpTool>();\n\n constructor(store: Store) {\n this.store = store;\n for (const t of TOOLS) this.toolMap.set(t.name, t);\n }\n\n /**\n * Returns `null` for notifications (no response needed).\n */\n handleRequest(req: JsonRpcRequest): JsonRpcResponse | null {\n // Notifications have no id — do not send a response\n if (req.id === null || req.id === undefined) {\n return null;\n }\n\n try {\n switch (req.method) {\n case \"initialize\":\n return this.ok(req.id, {\n protocolVersion: \"2024-11-05\",\n capabilities: { tools: {}, resources: {}, prompts: {} },\n serverInfo: { name: \"mnemosyne-mcp\", version: \"2.0.0\" },\n });\n\n case \"tools/list\":\n return this.ok(req.id, {\n tools: TOOLS.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),\n });\n\n case \"tools/call\": {\n const { name, arguments: args } = req.params || {};\n const tool = this.toolMap.get(name);\n if (!tool) return this.err(req.id, -32601, `Tool not found: ${name}`);\n const result = tool.handler(args || {}, this.store);\n return this.ok(req.id, { content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }] });\n }\n\n case \"resources/list\":\n return this.ok(req.id, { resources: [] });\n\n case \"prompts/list\":\n return this.ok(req.id, { prompts: [] });\n\n default:\n return this.err(req.id, -32601, `Method not found: ${req.method}`);\n }\n } catch (e: any) {\n return this.err(req.id, -32603, e.message);\n }\n }\n\n getManifest() {\n return {\n name: \"Mnemosyne\",\n version: \"2.0.0\",\n description: \"Knowledge base MCP server for projects, atoms, blocks, and bonds.\",\n protocol: \"mcp\",\n transport: [\"stdio\", \"sse\"],\n endpoints: {\n sse: \"/mcp/sse\",\n messages: \"/mcp/messages\",\n },\n tools: TOOLS.map(t => ({ name: t.name, description: t.description })),\n };\n }\n\n private ok(id: string | number | null, result: any): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, result };\n }\n private err(id: string | number | null, code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, error: { code, message } };\n }\n}\n","/**\n * MCP SSE Transport\n * Server-Sent Events transport for MCP over HTTP.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest } from \"./types.js\";\n\ninterface SseSession {\n id: string;\n res: import(\"http\").ServerResponse;\n}\n\nexport class McpSseTransport {\n private server: McpServer;\n private sessions = new Map<string, SseSession>();\n private sessionCounter = 0;\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n handleSse(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse): void {\n const id = `sess_${++this.sessionCounter}_${Date.now()}`;\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n \"Connection\": \"keep-alive\",\n });\n this.sessions.set(id, { id, res });\n\n // Send endpoint event\n this.sendSse(id, \"endpoint\", \"/mcp/messages?session_id=\" + id);\n\n req.on(\"close\", () => this.sessions.delete(id));\n }\n\n handleMessage(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse, body: any): void {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n const sessionId = url.searchParams.get(\"session_id\") || \"\";\n\n const request = body as JsonRpcRequest;\n if (!request || request.jsonrpc !== \"2.0\") {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"invalid_jsonrpc\" }));\n return;\n }\n\n const response = this.server.handleRequest(request);\n // Notifications return null — send empty 200\n if (!response) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n return;\n }\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(response));\n\n // Also broadcast via SSE if the session is active\n if (sessionId) this.sendSse(sessionId, \"message\", JSON.stringify(response));\n }\n\n private sendSse(sessionId: string, event: string, data: string): void {\n const session = this.sessions.get(sessionId);\n if (!session) return;\n session.res.write(`event: ${event}\\ndata: ${data}\\n\\n`);\n }\n}\n","/**\n * MCP Stdio Transport\n * Line-delimited JSON-RPC over stdin/stdout.\n * This is what Claude Desktop uses to communicate with MCP servers.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n\nexport class McpStdioTransport {\n private server: McpServer;\n private buffer = \"\";\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n start(): void {\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n\n process.stdin.on(\"data\", (chunk: string) => {\n this.buffer += chunk;\n const lines = this.buffer.split(\"\\n\");\n this.buffer = lines.pop() || \"\";\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const request = JSON.parse(line) as JsonRpcRequest;\n const response = this.server.handleRequest(request);\n if (response) this.send(response);\n // Notifications return null — no output\n } catch (err: any) {\n this.send({ jsonrpc: \"2.0\", id: null, error: { code: -32700, message: \"Parse error: \" + err.message } });\n }\n }\n });\n\n process.stdin.on(\"end\", () => {\n process.exit(0);\n });\n }\n\n send(message: JsonRpcResponse): void {\n process.stdout.write(JSON.stringify(message) + \"\\n\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,QAAmB;AAAA,EAC9B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa,EAAE,MAAM,UAAU,YAAY,CAAC,EAAE;AAAA,IAC9C,SAAS,CAAC,OAAO,UAAU;AACzB,aAAO,EAAE,UAAU,MAAM,YAAY,EAAE,IAAI,QAAM,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,aAAa,EAAE,aAAa,WAAW,MAAM,kBAAkB,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE;AAAA,IAC7J;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,OAAO,EAAE,MAAM,UAAU,aAAa,eAAe;AAAA,QACrD,SAAS,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,QACxE,OAAO,EAAE,MAAM,UAAU,aAAa,2BAA2B;AAAA,MACnE;AAAA,MACA,UAAU,CAAC,OAAO;AAAA,IACpB;AAAA,IACA,SAAS,CAAC,MAAM,UAAU;AACxB,YAAM,YAAY,KAAK,UAAU,MAAM,iBAAiB,KAAK,OAAO,GAAG,MAAM,KAAK,UAAU;AAC5F,YAAM,UAAU,MAAM,OAAO,WAAW,KAAK,OAAO,KAAK,SAAS,EAAE;AACpE,aAAO,EAAE,OAAO,KAAK,OAAO,OAAO,QAAQ,QAAQ,QAAQ;AAAA,IAC7D;AAAA,EACF;AAAA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