@postnesia/mcp 0.1.15 → 0.1.16

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 +29 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -267,6 +267,35 @@ server.registerTool('memory_unlink', {
267
267
  content: [{ type: 'text', text: `Deleted relationship #${relationshipId}` }],
268
268
  };
269
269
  });
270
+ server.registerTool('memory_supersede', {
271
+ description: 'Mark an existing memory as superseded by another — use for deduplication. Demotes the duplicate\'s importance and links it to the canonical memory. Refuses core memories.',
272
+ inputSchema: {
273
+ duplicateId: z.number().describe('ID of the duplicate memory to demote'),
274
+ canonicalId: z.number().describe('ID of the canonical memory to keep'),
275
+ },
276
+ }, async ({ duplicateId, canonicalId }) => {
277
+ if (duplicateId === canonicalId)
278
+ throw new Error('duplicate and canonical must be different memories');
279
+ const dup = db.prepare('SELECT id, core FROM memory WHERE id = ?').get(duplicateId);
280
+ if (!dup)
281
+ throw new Error(`Memory #${duplicateId} not found`);
282
+ if (dup.core)
283
+ throw new Error(`Memory #${duplicateId} is a core memory and cannot be superseded — use memory_update_core instead`);
284
+ const can = db.prepare('SELECT id FROM memory WHERE id = ?').get(canonicalId);
285
+ if (!can)
286
+ throw new Error(`Canonical memory #${canonicalId} not found`);
287
+ const alreadyLinked = db.prepare('SELECT supersedes_id FROM memory WHERE id = ? AND supersedes_id IS NOT NULL').get(duplicateId);
288
+ if (alreadyLinked)
289
+ throw new Error(`Memory #${duplicateId} already has a supersedes_id — check memory_supersede_chain first`);
290
+ db.prepare('UPDATE memory SET supersedes_id = ?, importance = MAX(1, importance - 2), updated_at = datetime(\'now\') WHERE id = ?').run(canonicalId, duplicateId);
291
+ const existing = queries.findRelationshipBetween(db).get(duplicateId, canonicalId, 'supersedes');
292
+ if (!existing) {
293
+ queries.insertRelationship(db).run(duplicateId, canonicalId, 'supersedes');
294
+ }
295
+ return {
296
+ content: [{ type: 'text', text: `Memory #${duplicateId} now superseded by #${canonicalId} (importance demoted by 2)` }],
297
+ };
298
+ });
270
299
  // ---------------------------------------------------------------------------
271
300
  // journal tools
272
301
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postnesia/mcp",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "An MCP server to interact with the Postnesia database",
5
5
  "type": "module",
6
6
  "private": false,
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@modelcontextprotocol/sdk": "^1.26.0",
16
16
  "zod": "^4.3.6",
17
- "@postnesia/db": "0.1.15"
17
+ "@postnesia/db": "0.1.16"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "^24.12.0",