velixar-mcp-server 0.1.2 → 0.1.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/LICENSE +21 -0
- package/package.json +1 -1
- package/src/index.js +44 -32
- package/tests/server.test.js +175 -78
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Velixar AI Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
const API_KEY = process.env.VELIXAR_API_KEY;
|
|
10
10
|
const API_BASE = process.env.VELIXAR_API_URL || "https://t4xrnwgo7f.execute-api.us-east-1.amazonaws.com/v1";
|
|
11
11
|
const USER_ID = process.env.VELIXAR_USER_ID || "kiro-cli";
|
|
12
|
+
const TIMEOUT_MS = 15000;
|
|
12
13
|
|
|
13
14
|
if (!API_KEY) {
|
|
14
15
|
console.error("VELIXAR_API_KEY environment variable required");
|
|
@@ -16,23 +17,33 @@ if (!API_KEY) {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
async function apiRequest(path, options = {}) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(`${API_BASE}${path}`, {
|
|
24
|
+
...options,
|
|
25
|
+
signal: controller.signal,
|
|
26
|
+
headers: {
|
|
27
|
+
"authorization": `Bearer ${API_KEY}`,
|
|
28
|
+
"Content-Type": "application/json",
|
|
29
|
+
...options.headers,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const body = await res.text().catch(() => "");
|
|
34
|
+
throw new Error(`API ${res.status}: ${body.slice(0, 200)}`);
|
|
35
|
+
}
|
|
36
|
+
return res.json();
|
|
37
|
+
} catch (e) {
|
|
38
|
+
if (e.name === "AbortError") throw new Error(`API timeout after ${TIMEOUT_MS}ms`);
|
|
39
|
+
throw e;
|
|
40
|
+
} finally {
|
|
41
|
+
clearTimeout(timer);
|
|
30
42
|
}
|
|
31
|
-
return res.json();
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
const server = new Server(
|
|
35
|
-
{ name: "velixar-mcp-server", version: "0.1.
|
|
46
|
+
{ name: "velixar-mcp-server", version: "0.1.3" },
|
|
36
47
|
{ capabilities: { tools: {} } }
|
|
37
48
|
);
|
|
38
49
|
|
|
@@ -46,7 +57,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
46
57
|
properties: {
|
|
47
58
|
content: { type: "string", description: "The memory content to store" },
|
|
48
59
|
tags: { type: "array", items: { type: "string" }, description: "Optional tags for categorization" },
|
|
49
|
-
tier: { type: "number", description: "Memory tier: 0=pinned, 1=session, 2=semantic, 3=org" },
|
|
60
|
+
tier: { type: "number", description: "Memory tier: 0=pinned, 1=session, 2=semantic (default), 3=org" },
|
|
50
61
|
},
|
|
51
62
|
required: ["content"],
|
|
52
63
|
},
|
|
@@ -65,7 +76,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
65
76
|
},
|
|
66
77
|
{
|
|
67
78
|
name: "velixar_delete",
|
|
68
|
-
description: "Delete a memory by ID.",
|
|
79
|
+
description: "Delete a memory by ID. Use velixar_list to find memory IDs first.",
|
|
69
80
|
inputSchema: {
|
|
70
81
|
type: "object",
|
|
71
82
|
properties: {
|
|
@@ -76,19 +87,19 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
76
87
|
},
|
|
77
88
|
{
|
|
78
89
|
name: "velixar_list",
|
|
79
|
-
description: "List memories with pagination
|
|
90
|
+
description: "List memories with pagination. Returns full metadata including IDs, tags, salience, and timestamps.",
|
|
80
91
|
inputSchema: {
|
|
81
92
|
type: "object",
|
|
82
93
|
properties: {
|
|
83
94
|
limit: { type: "number", description: "Max results (default 10)" },
|
|
84
|
-
cursor: { type: "string", description: "Pagination cursor" },
|
|
95
|
+
cursor: { type: "string", description: "Pagination cursor from previous response" },
|
|
85
96
|
},
|
|
86
97
|
required: [],
|
|
87
98
|
},
|
|
88
99
|
},
|
|
89
100
|
{
|
|
90
101
|
name: "velixar_update",
|
|
91
|
-
description: "Update an existing memory.",
|
|
102
|
+
description: "Update an existing memory's content or tags. Use velixar_list to find memory IDs first.",
|
|
92
103
|
inputSchema: {
|
|
93
104
|
type: "object",
|
|
94
105
|
properties: {
|
|
@@ -112,18 +123,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
112
123
|
body: JSON.stringify({
|
|
113
124
|
content: args.content,
|
|
114
125
|
user_id: USER_ID,
|
|
115
|
-
tier: args.tier
|
|
126
|
+
tier: args.tier ?? 2,
|
|
116
127
|
tags: args.tags || [],
|
|
117
128
|
}),
|
|
118
129
|
});
|
|
119
130
|
if (result.error) throw new Error(result.error);
|
|
120
131
|
if (!result.id) throw new Error("Store succeeded but no ID returned");
|
|
121
|
-
|
|
122
|
-
const verify = await apiRequest(`/memory/search?q=${encodeURIComponent(args.content.slice(0, 60))}&user_id=${USER_ID}&limit=1`);
|
|
123
|
-
const verified = verify.memories?.some(m => m.id === result.id);
|
|
124
|
-
return { content: [{ type: "text", text: verified
|
|
125
|
-
? `✓ Stored and verified memory (id: ${result.id})`
|
|
126
|
-
: `⚠ Stored memory (id: ${result.id}) but verification failed — may not be searchable yet` }] };
|
|
132
|
+
return { content: [{ type: "text", text: `✓ Stored memory (id: ${result.id})` }] };
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
if (name === "velixar_search") {
|
|
@@ -131,11 +137,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
131
137
|
if (args.limit) params.set("limit", String(args.limit));
|
|
132
138
|
const result = await apiRequest(`/memory/search?${params}`);
|
|
133
139
|
if (result.error) throw new Error(result.error);
|
|
134
|
-
|
|
140
|
+
|
|
135
141
|
if (!result.memories?.length) {
|
|
136
142
|
return { content: [{ type: "text", text: "No memories found." }] };
|
|
137
143
|
}
|
|
138
|
-
const memories = result.memories.map((m) =>
|
|
144
|
+
const memories = result.memories.map((m) =>
|
|
145
|
+
`• ${m.content}${m.score ? ` (score: ${m.score})` : ""}`
|
|
146
|
+
).join("\n");
|
|
139
147
|
return { content: [{ type: "text", text: `Found ${result.count} memories:\n${memories}` }] };
|
|
140
148
|
}
|
|
141
149
|
|
|
@@ -151,13 +159,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
151
159
|
if (args.cursor) params.set("cursor", args.cursor);
|
|
152
160
|
const result = await apiRequest(`/memory/list?${params}`);
|
|
153
161
|
if (result.error) throw new Error(result.error);
|
|
154
|
-
|
|
162
|
+
|
|
155
163
|
if (!result.memories?.length) {
|
|
156
164
|
return { content: [{ type: "text", text: "No memories found." }] };
|
|
157
165
|
}
|
|
158
|
-
const memories = result.memories.map((m) =>
|
|
166
|
+
const memories = result.memories.map((m) => {
|
|
167
|
+
const tags = m.tags?.length ? ` [${m.tags.join(", ")}]` : "";
|
|
168
|
+
const preview = m.content.length > 120 ? m.content.substring(0, 120) + "…" : m.content;
|
|
169
|
+
return `• ${m.id}: ${preview}${tags}`;
|
|
170
|
+
}).join("\n");
|
|
159
171
|
const cursor = result.cursor ? `\nNext cursor: ${result.cursor}` : "";
|
|
160
|
-
return { content: [{ type: "text", text:
|
|
172
|
+
return { content: [{ type: "text", text: `${result.count} memories:${cursor}\n${memories}` }] };
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
if (name === "velixar_update") {
|
|
@@ -172,9 +184,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
172
184
|
return { content: [{ type: "text", text: `✓ Updated memory: ${args.id}` }] };
|
|
173
185
|
}
|
|
174
186
|
|
|
175
|
-
return { content: [{ type: "text", text: `Unknown tool: ${name}` }] };
|
|
187
|
+
return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
|
|
176
188
|
} catch (error) {
|
|
177
|
-
return { content: [{ type: "text", text: `Error: ${error.message}` }] };
|
|
189
|
+
return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true };
|
|
178
190
|
}
|
|
179
191
|
});
|
|
180
192
|
|
package/tests/server.test.js
CHANGED
|
@@ -1,96 +1,193 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
1
|
+
import { test, describe, beforeEach } from "node:test";
|
|
2
2
|
import assert from "node:assert";
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// Capture the last fetch call for assertions
|
|
5
|
+
let lastFetch = {};
|
|
6
|
+
let mockResponse = {};
|
|
7
|
+
|
|
5
8
|
global.fetch = async (url, options) => {
|
|
6
|
-
|
|
7
|
-
"/memory": { success: true },
|
|
8
|
-
"/memory/search": { memories: [{ content: "test memory" }], count: 1 },
|
|
9
|
-
"/memory/test-id": { success: true }
|
|
10
|
-
};
|
|
11
|
-
|
|
9
|
+
lastFetch = { url, options };
|
|
12
10
|
const path = url.replace(/^.*\/v1/, "").split("?")[0];
|
|
13
|
-
|
|
11
|
+
const resp = mockResponse[path] || {};
|
|
12
|
+
return {
|
|
13
|
+
ok: resp._fail ? false : true,
|
|
14
|
+
status: resp._fail ? 500 : 200,
|
|
15
|
+
json: async () => resp,
|
|
16
|
+
text: async () => JSON.stringify(resp),
|
|
17
|
+
};
|
|
14
18
|
};
|
|
15
19
|
|
|
16
|
-
// Set required env vars
|
|
17
20
|
process.env.VELIXAR_API_KEY = "test-key";
|
|
21
|
+
process.env.VELIXAR_USER_ID = "test-user";
|
|
22
|
+
|
|
23
|
+
// Import the handler by extracting it from the server
|
|
24
|
+
// Since index.js connects to stdio on import, we test the logic via API calls
|
|
25
|
+
// These tests validate the request/response contract
|
|
26
|
+
|
|
27
|
+
describe("velixar_store", () => {
|
|
28
|
+
test("sends correct POST body", async () => {
|
|
29
|
+
mockResponse = { "/memory": { id: "abc-123", stored: true } };
|
|
30
|
+
const handler = makeHandler("velixar_store", { content: "test fact", tags: ["a"], tier: 0 });
|
|
31
|
+
const result = await handler();
|
|
32
|
+
assert.ok(lastFetch.url.endsWith("/memory"));
|
|
33
|
+
const body = JSON.parse(lastFetch.options.body);
|
|
34
|
+
assert.strictEqual(body.content, "test fact");
|
|
35
|
+
assert.strictEqual(body.tier, 0);
|
|
36
|
+
assert.deepStrictEqual(body.tags, ["a"]);
|
|
37
|
+
assert.strictEqual(body.user_id, "test-user");
|
|
38
|
+
});
|
|
18
39
|
|
|
19
|
-
test("
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
name: "velixar_search",
|
|
35
|
-
inputSchema: {
|
|
36
|
-
type: "object",
|
|
37
|
-
properties: {
|
|
38
|
-
query: { type: "string" },
|
|
39
|
-
limit: { type: "number" },
|
|
40
|
-
},
|
|
41
|
-
required: ["query"],
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "velixar_delete",
|
|
46
|
-
inputSchema: {
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: {
|
|
49
|
-
id: { type: "string" },
|
|
50
|
-
},
|
|
51
|
-
required: ["id"],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
assert.strictEqual(tools.length, 3);
|
|
57
|
-
assert.strictEqual(tools[0].name, "velixar_store");
|
|
58
|
-
assert.deepStrictEqual(tools[0].inputSchema.required, ["content"]);
|
|
59
|
-
assert.strictEqual(tools[1].name, "velixar_search");
|
|
60
|
-
assert.deepStrictEqual(tools[1].inputSchema.required, ["query"]);
|
|
61
|
-
assert.strictEqual(tools[2].name, "velixar_delete");
|
|
62
|
-
assert.deepStrictEqual(tools[2].inputSchema.required, ["id"]);
|
|
40
|
+
test("tier defaults to 2 when omitted", async () => {
|
|
41
|
+
mockResponse = { "/memory": { id: "abc-123", stored: true } };
|
|
42
|
+
const handler = makeHandler("velixar_store", { content: "test" });
|
|
43
|
+
await handler();
|
|
44
|
+
const body = JSON.parse(lastFetch.options.body);
|
|
45
|
+
assert.strictEqual(body.tier, 2);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("tier 0 is allowed (not coerced to default)", async () => {
|
|
49
|
+
mockResponse = { "/memory": { id: "abc-123", stored: true } };
|
|
50
|
+
const handler = makeHandler("velixar_store", { content: "pinned", tier: 0 });
|
|
51
|
+
await handler();
|
|
52
|
+
const body = JSON.parse(lastFetch.options.body);
|
|
53
|
+
assert.strictEqual(body.tier, 0);
|
|
54
|
+
});
|
|
63
55
|
});
|
|
64
56
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
describe("velixar_search", () => {
|
|
58
|
+
test("passes query and limit as URL params", async () => {
|
|
59
|
+
mockResponse = { "/memory/search": { memories: [{ content: "found it" }], count: 1 } };
|
|
60
|
+
const handler = makeHandler("velixar_search", { query: "test query", limit: 3 });
|
|
61
|
+
await handler();
|
|
62
|
+
assert.ok(lastFetch.url.includes("q=test+query") || lastFetch.url.includes("q=test%20query"));
|
|
63
|
+
assert.ok(lastFetch.url.includes("limit=3"));
|
|
64
|
+
});
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
test("returns 'No memories found' when empty", async () => {
|
|
67
|
+
mockResponse = { "/memory/search": { memories: [], count: 0 } };
|
|
68
|
+
const handler = makeHandler("velixar_search", { query: "nothing" });
|
|
69
|
+
const result = await handler();
|
|
70
|
+
assert.strictEqual(result.text, "No memories found.");
|
|
71
|
+
});
|
|
74
72
|
});
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
describe("velixar_list", () => {
|
|
75
|
+
test("passes cursor for pagination", async () => {
|
|
76
|
+
mockResponse = { "/memory/list": { memories: [{ id: "x", content: "hi", tags: [] }], count: 1 } };
|
|
77
|
+
const handler = makeHandler("velixar_list", { limit: 5, cursor: "abc" });
|
|
78
|
+
await handler();
|
|
79
|
+
assert.ok(lastFetch.url.includes("cursor=abc"));
|
|
80
|
+
assert.ok(lastFetch.url.includes("limit=5"));
|
|
81
|
+
});
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
test("returns 'No memories found' when empty", async () => {
|
|
84
|
+
mockResponse = { "/memory/list": { memories: [], count: 0 } };
|
|
85
|
+
const handler = makeHandler("velixar_list", {});
|
|
86
|
+
const result = await handler();
|
|
87
|
+
assert.strictEqual(result.text, "No memories found.");
|
|
88
|
+
});
|
|
85
89
|
});
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
describe("velixar_update", () => {
|
|
92
|
+
test("sends PATCH with content and tags", async () => {
|
|
93
|
+
mockResponse = { "/memory/up-123": { updated: true } };
|
|
94
|
+
const handler = makeHandler("velixar_update", { id: "up-123", content: "new", tags: ["x"] });
|
|
95
|
+
await handler();
|
|
96
|
+
assert.ok(lastFetch.url.includes("/memory/up-123"));
|
|
97
|
+
assert.strictEqual(lastFetch.options.method, "PATCH");
|
|
98
|
+
const body = JSON.parse(lastFetch.options.body);
|
|
99
|
+
assert.strictEqual(body.content, "new");
|
|
100
|
+
assert.deepStrictEqual(body.tags, ["x"]);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe("velixar_delete", () => {
|
|
105
|
+
test("sends DELETE to correct URL", async () => {
|
|
106
|
+
mockResponse = { "/memory/del-456": { deleted: true } };
|
|
107
|
+
const handler = makeHandler("velixar_delete", { id: "del-456" });
|
|
108
|
+
await handler();
|
|
109
|
+
assert.ok(lastFetch.url.includes("/memory/del-456"));
|
|
110
|
+
assert.strictEqual(lastFetch.options.method, "DELETE");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("error handling", () => {
|
|
115
|
+
test("returns isError on API error response", async () => {
|
|
116
|
+
mockResponse = { "/memory": { error: "bad request" } };
|
|
117
|
+
const handler = makeHandler("velixar_store", { content: "fail" });
|
|
118
|
+
const result = await handler();
|
|
119
|
+
assert.ok(result.text.includes("Error:"));
|
|
120
|
+
assert.strictEqual(result.isError, true);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Helper: simulates the CallTool handler logic from index.js
|
|
125
|
+
// This mirrors the actual handler without needing stdio transport
|
|
126
|
+
function makeHandler(name, args) {
|
|
127
|
+
const API_BASE = "https://t4xrnwgo7f.execute-api.us-east-1.amazonaws.com/v1";
|
|
128
|
+
const API_KEY = process.env.VELIXAR_API_KEY;
|
|
129
|
+
const USER_ID = process.env.VELIXAR_USER_ID;
|
|
130
|
+
|
|
131
|
+
async function apiRequest(path, options = {}) {
|
|
132
|
+
const res = await fetch(`${API_BASE}${path}`, {
|
|
133
|
+
...options,
|
|
134
|
+
headers: { authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", ...options.headers },
|
|
135
|
+
});
|
|
136
|
+
if (!res.ok) { const body = await res.text().catch(() => ""); throw new Error(`API ${res.status}: ${body.slice(0, 200)}`); }
|
|
137
|
+
return res.json();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return async () => {
|
|
141
|
+
try {
|
|
142
|
+
if (name === "velixar_store") {
|
|
143
|
+
const result = await apiRequest("/memory", {
|
|
144
|
+
method: "POST",
|
|
145
|
+
body: JSON.stringify({ content: args.content, user_id: USER_ID, tier: args.tier ?? 2, tags: args.tags || [] }),
|
|
146
|
+
});
|
|
147
|
+
if (result.error) throw new Error(result.error);
|
|
148
|
+
if (!result.id) throw new Error("Store succeeded but no ID returned");
|
|
149
|
+
return { text: `✓ Stored memory (id: ${result.id})` };
|
|
150
|
+
}
|
|
151
|
+
if (name === "velixar_search") {
|
|
152
|
+
const params = new URLSearchParams({ q: args.query, user_id: USER_ID });
|
|
153
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
154
|
+
const result = await apiRequest(`/memory/search?${params}`);
|
|
155
|
+
if (result.error) throw new Error(result.error);
|
|
156
|
+
if (!result.memories?.length) return { text: "No memories found." };
|
|
157
|
+
const memories = result.memories.map((m) => `• ${m.content}${m.score ? ` (score: ${m.score})` : ""}`).join("\n");
|
|
158
|
+
return { text: `Found ${result.count} memories:\n${memories}` };
|
|
159
|
+
}
|
|
160
|
+
if (name === "velixar_delete") {
|
|
161
|
+
const result = await apiRequest(`/memory/${args.id}`, { method: "DELETE" });
|
|
162
|
+
if (result.error) throw new Error(result.error);
|
|
163
|
+
return { text: `✓ Deleted memory: ${args.id}` };
|
|
164
|
+
}
|
|
165
|
+
if (name === "velixar_list") {
|
|
166
|
+
const params = new URLSearchParams({ user_id: USER_ID });
|
|
167
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
168
|
+
if (args.cursor) params.set("cursor", args.cursor);
|
|
169
|
+
const result = await apiRequest(`/memory/list?${params}`);
|
|
170
|
+
if (result.error) throw new Error(result.error);
|
|
171
|
+
if (!result.memories?.length) return { text: "No memories found." };
|
|
172
|
+
const memories = result.memories.map((m) => {
|
|
173
|
+
const tags = m.tags?.length ? ` [${m.tags.join(", ")}]` : "";
|
|
174
|
+
const preview = m.content.length > 120 ? m.content.substring(0, 120) + "…" : m.content;
|
|
175
|
+
return `• ${m.id}: ${preview}${tags}`;
|
|
176
|
+
}).join("\n");
|
|
177
|
+
const cursor = result.cursor ? `\nNext cursor: ${result.cursor}` : "";
|
|
178
|
+
return { text: `${result.count} memories:${cursor}\n${memories}` };
|
|
179
|
+
}
|
|
180
|
+
if (name === "velixar_update") {
|
|
181
|
+
const body = { user_id: USER_ID };
|
|
182
|
+
if (args.content) body.content = args.content;
|
|
183
|
+
if (args.tags) body.tags = args.tags;
|
|
184
|
+
const result = await apiRequest(`/memory/${args.id}`, { method: "PATCH", body: JSON.stringify(body) });
|
|
185
|
+
if (result.error) throw new Error(result.error);
|
|
186
|
+
return { text: `✓ Updated memory: ${args.id}` };
|
|
187
|
+
}
|
|
188
|
+
return { text: `Unknown tool: ${name}`, isError: true };
|
|
189
|
+
} catch (error) {
|
|
190
|
+
return { text: `Error: ${error.message}`, isError: true };
|
|
91
191
|
}
|
|
92
192
|
};
|
|
93
|
-
|
|
94
|
-
const result = await mockHandler("velixar_delete", { id: "test-id" });
|
|
95
|
-
assert.strictEqual(result.content[0].text, "✓ Deleted memory: test-id");
|
|
96
|
-
});
|
|
193
|
+
}
|