@postnesia/mcp 0.1.7 → 0.1.8

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 (2) hide show
  1. package/dist/index.js +18 -5
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -6,7 +6,8 @@
6
6
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
8
  import { z } from "zod";
9
- import { getDb, queries, createMemory } from "@postnesia/db";
9
+ import { getDb, closeDb, createMemory } from "@postnesia/db";
10
+ import queries from "@postnesia/db/queries";
10
11
  import { embed } from "@postnesia/db/embeddings";
11
12
  import { logAccess } from "@postnesia/db/access";
12
13
  import { runConsolidation } from "@postnesia/db/importance";
@@ -25,7 +26,10 @@ server.registerTool("memory_search", {
25
26
  limit: z.number().optional().describe("Maximum results to return (default: 10)"),
26
27
  },
27
28
  }, async ({ query, limit = 10 }) => {
28
- const embedding = await embed(query);
29
+ const [embedding] = await embed(query);
30
+ if (!embedding) {
31
+ throw new ReferenceError('Unable to create query embedding');
32
+ }
29
33
  const results = queries.vectorSearch(db).all(Buffer.from(embedding.buffer), limit);
30
34
  for (const result of results) {
31
35
  logAccess(result.id, "search");
@@ -47,7 +51,10 @@ server.registerTool("memory_add", {
47
51
  },
48
52
  }, async ({ content, contentL1, type, importance, tags, context, core }) => {
49
53
  const content_l1 = contentL1 || content.slice(0, 200);
50
- const embedding = await embed(content);
54
+ const [embedding] = await embed(content);
55
+ if (!embedding) {
56
+ throw new ReferenceError('Unable to create query embedding');
57
+ }
51
58
  const id = createMemory(db, {
52
59
  timestamp: new Date().toISOString(),
53
60
  content,
@@ -81,7 +88,10 @@ server.registerTool("memory_update_core", {
81
88
  throw new Error(`Memory #${memoryId} not found`);
82
89
  if (!existing.core)
83
90
  throw new Error(`Memory #${memoryId} is not a core memory. Use memory_add with supersedes_id for regular memories.`);
84
- const embedding = await embed(content);
91
+ const [embedding] = await embed(content);
92
+ if (!embedding) {
93
+ throw new ReferenceError('Unable to create query embedding');
94
+ }
85
95
  db.prepare(`
86
96
  UPDATE memory
87
97
  SET content = ?, content_l1 = ?, updated_at = datetime('now')
@@ -232,7 +242,7 @@ server.registerTool("task_create", {
232
242
  inputSchema: {
233
243
  title: z.string().describe("Short task title"),
234
244
  description: z.string().optional().describe("Detailed description of what needs to be done"),
235
- session_id: z.string().optional().describe("Project or feature label to group related tasks (e.g. 'openmind-mcp', 'auth-refactor')"),
245
+ session_id: z.string().optional().describe("Project or feature label to group related tasks (e.g. 'postnesia-mcp', 'auth-refactor')"),
236
246
  memory_id: z.number().optional().describe("Optional ID of a related memory"),
237
247
  },
238
248
  }, async ({ title, description, session_id, memory_id }) => {
@@ -310,5 +320,8 @@ async function main() {
310
320
  }
311
321
  main().catch((error) => {
312
322
  console.error("Fatal error:", error);
323
+ closeDb();
313
324
  process.exit(1);
314
325
  });
326
+ process.on('SIGINT', () => { closeDb(); process.exit(0); });
327
+ process.on('SIGTERM', () => { closeDb(); process.exit(0); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postnesia/mcp",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "An MCP server to interact with the Postnesia database",
5
5
  "type": "module",
6
6
  "private": false,
@@ -8,21 +8,21 @@
8
8
  "dist"
9
9
  ],
10
10
  "bin": {
11
- "postnesia-mcp": "./dist/index.js"
11
+ "pn-mcp": "./dist/index.js"
12
+ },
13
+ "scripts": {
14
+ "build": "pnpm clean && tsc -p tsconfig.json",
15
+ "clean": "rm -rf ./dist",
16
+ "start": "tsx src/index.ts"
12
17
  },
13
18
  "dependencies": {
14
19
  "@modelcontextprotocol/sdk": "^1.26.0",
15
- "zod": "^4.3.6",
16
- "@postnesia/db": "0.1.7"
20
+ "@postnesia/db": "workspace:*",
21
+ "zod": "^4.3.6"
17
22
  },
18
23
  "devDependencies": {
19
24
  "@types/node": "^22.10.5",
20
25
  "tsx": "^4.19.2",
21
26
  "typescript": "^5.7.3"
22
- },
23
- "scripts": {
24
- "build": "pnpm clean && tsc -p tsconfig.json",
25
- "clean": "rm -rf ./dist",
26
- "start": "tsx src/index.ts"
27
27
  }
28
- }
28
+ }