@postnesia/mcp 0.1.6 → 0.1.7
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/index.js +39 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -154,6 +154,45 @@ server.registerTool("memory_relationships", {
|
|
|
154
154
|
content: [{ type: "text", text: JSON.stringify(relationships, null, 2) }],
|
|
155
155
|
};
|
|
156
156
|
});
|
|
157
|
+
server.registerTool("memory_link", {
|
|
158
|
+
description: "Explicitly create a typed relationship between two memories",
|
|
159
|
+
inputSchema: {
|
|
160
|
+
fromId: z.number().describe("Source memory ID"),
|
|
161
|
+
toId: z.number().describe("Target memory ID"),
|
|
162
|
+
type: z.enum(["related", "supersedes", "supports", "contradicts", "derives_from"])
|
|
163
|
+
.describe("Relationship type"),
|
|
164
|
+
},
|
|
165
|
+
}, async ({ fromId, toId, type }) => {
|
|
166
|
+
const from = db.prepare("SELECT id FROM memory WHERE id = ?").get(fromId);
|
|
167
|
+
if (!from)
|
|
168
|
+
throw new Error(`Memory #${fromId} not found`);
|
|
169
|
+
const to = db.prepare("SELECT id FROM memory WHERE id = ?").get(toId);
|
|
170
|
+
if (!to)
|
|
171
|
+
throw new Error(`Memory #${toId} not found`);
|
|
172
|
+
const existing = queries.findRelationshipBetween(db).get(fromId, toId, type);
|
|
173
|
+
if (existing) {
|
|
174
|
+
return { content: [{ type: "text", text: `Relationship already exists (id: ${existing.id})` }] };
|
|
175
|
+
}
|
|
176
|
+
const result = queries.insertRelationship(db).run(fromId, toId, type);
|
|
177
|
+
const id = Number(result.lastInsertRowid);
|
|
178
|
+
return {
|
|
179
|
+
content: [{ type: "text", text: `Created relationship #${id}: #${fromId} -[${type}]-> #${toId}` }],
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
server.registerTool("memory_unlink", {
|
|
183
|
+
description: "Remove a relationship between two memories by relationship ID",
|
|
184
|
+
inputSchema: {
|
|
185
|
+
relationshipId: z.number().describe("Relationship ID to delete"),
|
|
186
|
+
},
|
|
187
|
+
}, async ({ relationshipId }) => {
|
|
188
|
+
const existing = db.prepare("SELECT id FROM relationship WHERE id = ?").get(relationshipId);
|
|
189
|
+
if (!existing)
|
|
190
|
+
throw new Error(`Relationship #${relationshipId} not found`);
|
|
191
|
+
queries.deleteRelationship(db).run(relationshipId);
|
|
192
|
+
return {
|
|
193
|
+
content: [{ type: "text", text: `Deleted relationship #${relationshipId}` }],
|
|
194
|
+
};
|
|
195
|
+
});
|
|
157
196
|
// ---------------------------------------------------------------------------
|
|
158
197
|
// journal tools
|
|
159
198
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postnesia/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "An MCP server to interact with the Postnesia database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"zod": "^4.3.6",
|
|
16
|
+
"@postnesia/db": "0.1.7"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^22.10.5",
|