mnemosyne-core 2.0.1 → 2.0.3
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/dist/cli/index.js +198 -28
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +197 -28
- package/dist/cli/index.mjs.map +1 -1
- package/dist/dashboard/index.html +9401 -0
- package/dist/index.js +105 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -25
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/index.js +19 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +26 -2
- package/dist/mcp/index.mjs.map +1 -1
- package/dist/server/api.js +66 -13
- package/dist/server/api.js.map +1 -1
- package/dist/server/api.mjs +72 -13
- package/dist/server/api.mjs.map +1 -1
- package/dist/server/index.js +80 -23
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +79 -23
- package/dist/server/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/mcp/index.js
CHANGED
|
@@ -244,6 +244,23 @@ var TOOLS = [
|
|
|
244
244
|
];
|
|
245
245
|
|
|
246
246
|
// src/mcp/server.ts
|
|
247
|
+
function getVersion() {
|
|
248
|
+
try {
|
|
249
|
+
const { readFileSync } = require("fs");
|
|
250
|
+
const { resolve } = require("path");
|
|
251
|
+
const pkg = JSON.parse(readFileSync(resolve(__dirname, "../../package.json"), "utf-8"));
|
|
252
|
+
return pkg.version;
|
|
253
|
+
} catch {
|
|
254
|
+
try {
|
|
255
|
+
const { readFileSync } = require("fs");
|
|
256
|
+
const { resolve } = require("path");
|
|
257
|
+
const pkg = JSON.parse(readFileSync(resolve(process.cwd(), "package.json"), "utf-8"));
|
|
258
|
+
return pkg.version;
|
|
259
|
+
} catch {
|
|
260
|
+
return "2.0.3";
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
247
264
|
var McpServer = class {
|
|
248
265
|
store;
|
|
249
266
|
toolMap = /* @__PURE__ */ new Map();
|
|
@@ -264,7 +281,7 @@ var McpServer = class {
|
|
|
264
281
|
return this.ok(req.id, {
|
|
265
282
|
protocolVersion: "2024-11-05",
|
|
266
283
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
267
|
-
serverInfo: { name: "mnemosyne-mcp", version:
|
|
284
|
+
serverInfo: { name: "mnemosyne-mcp", version: getVersion() }
|
|
268
285
|
});
|
|
269
286
|
case "tools/list":
|
|
270
287
|
return this.ok(req.id, {
|
|
@@ -291,7 +308,7 @@ var McpServer = class {
|
|
|
291
308
|
getManifest() {
|
|
292
309
|
return {
|
|
293
310
|
name: "Mnemosyne",
|
|
294
|
-
version:
|
|
311
|
+
version: getVersion(),
|
|
295
312
|
description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
|
|
296
313
|
protocol: "mcp",
|
|
297
314
|
transport: ["stdio", "sse"],
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +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;AAA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,CAAC,UAAkB;AAC1C,WAAK,UAAU;AACf,YAAM,QAAQ,KAAK,OAAO,MAAM,IAAI;AACpC,WAAK,SAAS,MAAM,IAAI,KAAK;AAE7B,iBAAW,QAAQ,OAAO;AACxB,YAAI,CAAC,KAAK,KAAK,EAAG;AAClB,YAAI;AACF,gBAAM,UAAU,KAAK,MAAM,IAAI;AAC/B,gBAAM,WAAW,KAAK,OAAO,cAAc,OAAO;AAClD,cAAI,SAAU,MAAK,KAAK,QAAQ;AAAA,QAElC,SAAS,KAAU;AACjB,eAAK,KAAK,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,SAAS,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAAA,QACzG;AAAA,MACF;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
|
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\nfunction getVersion(): string {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(process.cwd(), \"package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n return \"2.0.3\";\n }\n }\n}\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: getVersion() },\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: getVersion(),\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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AE,SAAS,OAAO,IAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,SAAS,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAAA,QACzG;AAAA,MACF;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
package/dist/mcp/index.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
1
8
|
// src/mcp/tools.ts
|
|
2
9
|
var TOOLS = [
|
|
3
10
|
{
|
|
@@ -215,6 +222,23 @@ var TOOLS = [
|
|
|
215
222
|
];
|
|
216
223
|
|
|
217
224
|
// src/mcp/server.ts
|
|
225
|
+
function getVersion() {
|
|
226
|
+
try {
|
|
227
|
+
const { readFileSync } = __require("fs");
|
|
228
|
+
const { resolve } = __require("path");
|
|
229
|
+
const pkg = JSON.parse(readFileSync(resolve(__dirname, "../../package.json"), "utf-8"));
|
|
230
|
+
return pkg.version;
|
|
231
|
+
} catch {
|
|
232
|
+
try {
|
|
233
|
+
const { readFileSync } = __require("fs");
|
|
234
|
+
const { resolve } = __require("path");
|
|
235
|
+
const pkg = JSON.parse(readFileSync(resolve(process.cwd(), "package.json"), "utf-8"));
|
|
236
|
+
return pkg.version;
|
|
237
|
+
} catch {
|
|
238
|
+
return "2.0.3";
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
218
242
|
var McpServer = class {
|
|
219
243
|
store;
|
|
220
244
|
toolMap = /* @__PURE__ */ new Map();
|
|
@@ -235,7 +259,7 @@ var McpServer = class {
|
|
|
235
259
|
return this.ok(req.id, {
|
|
236
260
|
protocolVersion: "2024-11-05",
|
|
237
261
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
238
|
-
serverInfo: { name: "mnemosyne-mcp", version:
|
|
262
|
+
serverInfo: { name: "mnemosyne-mcp", version: getVersion() }
|
|
239
263
|
});
|
|
240
264
|
case "tools/list":
|
|
241
265
|
return this.ok(req.id, {
|
|
@@ -262,7 +286,7 @@ var McpServer = class {
|
|
|
262
286
|
getManifest() {
|
|
263
287
|
return {
|
|
264
288
|
name: "Mnemosyne",
|
|
265
|
-
version:
|
|
289
|
+
version: getVersion(),
|
|
266
290
|
description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
|
|
267
291
|
protocol: "mcp",
|
|
268
292
|
transport: ["stdio", "sse"],
|
package/dist/mcp/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["/**\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":";AAQO,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,E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YAAI,CAAC,KAAK,KAAK,EAAG;AAClB,YAAI;AACF,gBAAM,UAAU,KAAK,MAAM,IAAI;AAC/B,gBAAM,WAAW,KAAK,OAAO,cAAc,OAAO;AAClD,cAAI,SAAU,MAAK,KAAK,QAAQ;AAAA,QAElC,SAAS,KAAU;AACjB,eAAK,KAAK,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,SAAS,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAAA,QACzG;AAAA,MACF;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["/**\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\nfunction getVersion(): string {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(process.cwd(), \"package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n return \"2.0.3\";\n }\n }\n}\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: getVersion() },\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: getVersion(),\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":";;;;;;;;AAQO,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,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Config() {
|
|
|
106
106
|
return defaultConfig();
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
function getVersion2() {
|
|
110
|
+
try {
|
|
111
|
+
const { readFileSync: readFileSync4 } = require("fs");
|
|
112
|
+
const { resolve: resolve4 } = require("path");
|
|
113
|
+
const pkg = JSON.parse(readFileSync4(resolve4(__dirname, "../package.json"), "utf-8"));
|
|
114
|
+
return pkg.version;
|
|
115
|
+
} catch {
|
|
116
|
+
try {
|
|
117
|
+
const { readFileSync: readFileSync4 } = require("fs");
|
|
118
|
+
const { resolve: resolve4 } = require("path");
|
|
119
|
+
const pkg = JSON.parse(readFileSync4(resolve4(process.cwd(), "package.json"), "utf-8"));
|
|
120
|
+
return pkg.version;
|
|
121
|
+
} catch {
|
|
122
|
+
return "2.0.3";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
109
126
|
function defaultConfig() {
|
|
110
127
|
return {
|
|
111
|
-
server: { port: 7321, host: "localhost", version:
|
|
128
|
+
server: { port: 7321, host: "localhost", version: getVersion2() },
|
|
112
129
|
database: { path: "data/nexus.db", wal_mode: true, vec_extension_path: "data/vec0" },
|
|
113
130
|
storage: { files_dir: "data/files", max_file_size_mb: 50, backups_dir: "data/backups", backup_interval_hours: 24, max_backups: 7 },
|
|
114
131
|
limits: { max_atoms_per_project: 1e4, rate_limit_requests: 100, rate_limit_window_ms: 6e4 },
|
|
@@ -131,13 +148,22 @@ function mergeDeep(target, source) {
|
|
|
131
148
|
}
|
|
132
149
|
return output;
|
|
133
150
|
}
|
|
134
|
-
|
|
151
|
+
function getConfig() {
|
|
152
|
+
if (!_config) _config = loadConfig();
|
|
153
|
+
return _config;
|
|
154
|
+
}
|
|
155
|
+
var import_fs, import_path, _config, CONFIG;
|
|
135
156
|
var init_config = __esm({
|
|
136
157
|
"src/config.ts"() {
|
|
137
158
|
"use strict";
|
|
138
159
|
import_fs = require("fs");
|
|
139
160
|
import_path = require("path");
|
|
140
|
-
|
|
161
|
+
_config = null;
|
|
162
|
+
CONFIG = new Proxy({}, {
|
|
163
|
+
get(_, prop) {
|
|
164
|
+
return getConfig()[prop];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
141
167
|
}
|
|
142
168
|
});
|
|
143
169
|
|
|
@@ -442,6 +468,23 @@ var TOOLS = [
|
|
|
442
468
|
];
|
|
443
469
|
|
|
444
470
|
// src/mcp/server.ts
|
|
471
|
+
function getVersion() {
|
|
472
|
+
try {
|
|
473
|
+
const { readFileSync: readFileSync4 } = require("fs");
|
|
474
|
+
const { resolve: resolve4 } = require("path");
|
|
475
|
+
const pkg = JSON.parse(readFileSync4(resolve4(__dirname, "../../package.json"), "utf-8"));
|
|
476
|
+
return pkg.version;
|
|
477
|
+
} catch {
|
|
478
|
+
try {
|
|
479
|
+
const { readFileSync: readFileSync4 } = require("fs");
|
|
480
|
+
const { resolve: resolve4 } = require("path");
|
|
481
|
+
const pkg = JSON.parse(readFileSync4(resolve4(process.cwd(), "package.json"), "utf-8"));
|
|
482
|
+
return pkg.version;
|
|
483
|
+
} catch {
|
|
484
|
+
return "2.0.3";
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
445
488
|
var McpServer = class {
|
|
446
489
|
store;
|
|
447
490
|
toolMap = /* @__PURE__ */ new Map();
|
|
@@ -462,7 +505,7 @@ var McpServer = class {
|
|
|
462
505
|
return this.ok(req.id, {
|
|
463
506
|
protocolVersion: "2024-11-05",
|
|
464
507
|
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
465
|
-
serverInfo: { name: "mnemosyne-mcp", version:
|
|
508
|
+
serverInfo: { name: "mnemosyne-mcp", version: getVersion() }
|
|
466
509
|
});
|
|
467
510
|
case "tools/list":
|
|
468
511
|
return this.ok(req.id, {
|
|
@@ -489,7 +532,7 @@ var McpServer = class {
|
|
|
489
532
|
getManifest() {
|
|
490
533
|
return {
|
|
491
534
|
name: "Mnemosyne",
|
|
492
|
-
version:
|
|
535
|
+
version: getVersion(),
|
|
493
536
|
description: "Knowledge base MCP server for projects, atoms, blocks, and bonds.",
|
|
494
537
|
protocol: "mcp",
|
|
495
538
|
transport: ["stdio", "sse"],
|
|
@@ -1323,12 +1366,14 @@ var import_crypto = require("crypto");
|
|
|
1323
1366
|
var import_fs2 = require("fs");
|
|
1324
1367
|
var import_path2 = require("path");
|
|
1325
1368
|
init_config();
|
|
1326
|
-
|
|
1369
|
+
function getFilesDir() {
|
|
1370
|
+
return (0, import_path2.resolve)(process.cwd(), CONFIG.storage.files_dir);
|
|
1371
|
+
}
|
|
1327
1372
|
function ensureDir(path) {
|
|
1328
1373
|
if (!(0, import_fs2.existsSync)(path)) (0, import_fs2.mkdirSync)(path, { recursive: true });
|
|
1329
1374
|
}
|
|
1330
1375
|
function hashPath(hash) {
|
|
1331
|
-
return (0, import_path2.resolve)(
|
|
1376
|
+
return (0, import_path2.resolve)(getFilesDir(), hash.slice(0, 2), hash.slice(2));
|
|
1332
1377
|
}
|
|
1333
1378
|
function computeHash(buffer) {
|
|
1334
1379
|
return (0, import_crypto.createHash)("sha256").update(buffer).digest("hex");
|
|
@@ -1398,7 +1443,7 @@ var import_crypto2 = require("crypto");
|
|
|
1398
1443
|
var import_fs3 = require("fs");
|
|
1399
1444
|
var import_path3 = require("path");
|
|
1400
1445
|
var DB_PATH = (0, import_path3.resolve)(process.cwd(), "data", "nexus.db");
|
|
1401
|
-
var
|
|
1446
|
+
var FILES_DIR = (0, import_path3.resolve)(process.cwd(), "data", "files");
|
|
1402
1447
|
function sha256File(path) {
|
|
1403
1448
|
return (0, import_crypto2.createHash)("sha256").update((0, import_fs3.readFileSync)(path)).digest("hex");
|
|
1404
1449
|
}
|
|
@@ -1418,11 +1463,11 @@ function sha256Dir(dir) {
|
|
|
1418
1463
|
function buildMnemosyneExport(projectId, projectName) {
|
|
1419
1464
|
const zip = new import_adm_zip.default();
|
|
1420
1465
|
zip.addLocalFile(DB_PATH, "", "nexus.db");
|
|
1421
|
-
if ((0, import_fs3.existsSync)(
|
|
1422
|
-
zip.addLocalFolder(
|
|
1466
|
+
if ((0, import_fs3.existsSync)(FILES_DIR)) {
|
|
1467
|
+
zip.addLocalFolder(FILES_DIR, "files");
|
|
1423
1468
|
}
|
|
1424
1469
|
const dbChecksum = sha256File(DB_PATH);
|
|
1425
|
-
const filesChecksum = (0, import_fs3.existsSync)(
|
|
1470
|
+
const filesChecksum = (0, import_fs3.existsSync)(FILES_DIR) ? sha256Dir(FILES_DIR) : "";
|
|
1426
1471
|
const manifest = {
|
|
1427
1472
|
version: "1.1",
|
|
1428
1473
|
app: "Mnemosyne",
|
|
@@ -1548,12 +1593,20 @@ function handleEvents(store, pathname, method, res, searchParams) {
|
|
|
1548
1593
|
}
|
|
1549
1594
|
|
|
1550
1595
|
// src/api/routes/health.ts
|
|
1596
|
+
var PKG_VERSION = (() => {
|
|
1597
|
+
try {
|
|
1598
|
+
const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../../package.json"), "utf-8"));
|
|
1599
|
+
return pkg.version;
|
|
1600
|
+
} catch {
|
|
1601
|
+
return "2.0.3";
|
|
1602
|
+
}
|
|
1603
|
+
})();
|
|
1551
1604
|
function handleHealth(store, pathname, method, res) {
|
|
1552
|
-
if (pathname === "/health" && method === "GET") {
|
|
1605
|
+
if ((pathname === "/health" || pathname === "/api/v1/health") && method === "GET") {
|
|
1553
1606
|
const stats = store.getStats();
|
|
1554
1607
|
json(res, 200, {
|
|
1555
1608
|
status: "ok",
|
|
1556
|
-
version:
|
|
1609
|
+
version: PKG_VERSION,
|
|
1557
1610
|
storage: "sqlite",
|
|
1558
1611
|
database: store.config.database.path,
|
|
1559
1612
|
uptime: process.uptime(),
|