@engramx/mcp 0.1.0-rc.2
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 +190 -0
- package/README.md +166 -0
- package/dist/connect-config.d.ts +51 -0
- package/dist/connect-config.js +108 -0
- package/dist/connect-config.js.map +1 -0
- package/dist/connect-config.test.d.ts +1 -0
- package/dist/connect-config.test.js +49 -0
- package/dist/connect-config.test.js.map +1 -0
- package/dist/connect.d.ts +1 -0
- package/dist/connect.js +89 -0
- package/dist/connect.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/profile-tools.d.ts +3 -0
- package/dist/profile-tools.js +144 -0
- package/dist/profile-tools.js.map +1 -0
- package/dist/resources.d.ts +3 -0
- package/dist/resources.js +22 -0
- package/dist/resources.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +51 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.js +398 -0
- package/dist/tools.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +30 -0
- package/dist/utils.js.map +1 -0
- package/package.json +40 -0
package/dist/tools.js
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toSerializable } from './utils.js';
|
|
3
|
+
function jsonText(value) {
|
|
4
|
+
return JSON.stringify(toSerializable(value), null, 2);
|
|
5
|
+
}
|
|
6
|
+
const MAX_PATH_LENGTH = 1024;
|
|
7
|
+
const E8S_PER_ICP = 100_000_000;
|
|
8
|
+
function validatePath(p) {
|
|
9
|
+
if (!p || p.length === 0)
|
|
10
|
+
return 'Path cannot be empty (rejected client-side; no request was sent and nothing changed — supply a non-empty path and retry immediately)';
|
|
11
|
+
if (p.length > MAX_PATH_LENGTH)
|
|
12
|
+
return `Path exceeds maximum length (${MAX_PATH_LENGTH} chars); rejected client-side — no request sent; shorten the path and retry immediately`;
|
|
13
|
+
if (p.includes('\0'))
|
|
14
|
+
return 'Path contains null byte (rejected client-side; no request sent — remove the null character and retry immediately)';
|
|
15
|
+
if (p.includes('..'))
|
|
16
|
+
return 'Path traversal sequences not allowed (".." rejected client-side; no request sent — use a plain path without ".." and retry immediately)';
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
export function registerTools(server, engram) {
|
|
20
|
+
// 1. engram_read_memory
|
|
21
|
+
server.tool('engram_read_memory', 'Read ONE memory file by exact path (e.g. "MEMORY.md", "memory/2026-02-11.md") and return its current decrypted content as JSON {path, content, version, lastModifiedAt}. Use when the path is known; discover paths with engram_list_memory_files. For several files use engram_read_memory_batch; for prior versions use engram_memory_history. Read-only.', {
|
|
22
|
+
path: z
|
|
23
|
+
.string()
|
|
24
|
+
.describe('Exact memory file path, e.g. "MEMORY.md" or "identity/preferences.md". Non-empty, max 1024 bytes, no ".." traversal.'),
|
|
25
|
+
}, async ({ path }) => {
|
|
26
|
+
const pathErr = validatePath(path);
|
|
27
|
+
if (pathErr)
|
|
28
|
+
return { content: [{ type: 'text', text: pathErr }], isError: true };
|
|
29
|
+
try {
|
|
30
|
+
const file = await engram.readMemory(path);
|
|
31
|
+
return {
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: 'text',
|
|
35
|
+
text: jsonText({
|
|
36
|
+
path: file.path,
|
|
37
|
+
content: file.content,
|
|
38
|
+
version: file.version,
|
|
39
|
+
lastModifiedAt: file.lastModifiedAt,
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// (engram_write_memory removed: writeMemory is owner-only by design — operators
|
|
58
|
+
// are append-only. Owner uses the dashboard at engramx.ai or the canister IDL
|
|
59
|
+
// directly via Internet Identity.)
|
|
60
|
+
// 2. engram_append_memory
|
|
61
|
+
server.tool('engram_append_memory', 'Append text to a memory file; the file is created if it does not exist. APPEND-ONLY: never overwrites or deletes, and this is the ONLY mutating memory tool on this surface (no write/delete/rollback exists here). Requires the memory.append scope (operator with canAppendMemory, or owner). Rejected: config/ and secrets/ paths (owner-only), owner-protected paths, and while guardian writes are paused. Returns JSON {path, version} with the new version number.', {
|
|
62
|
+
path: z
|
|
63
|
+
.string()
|
|
64
|
+
.describe('Target file path to append to; created if absent. Max 1024 bytes, no ".."; operators cannot use the config/ or secrets/ prefixes (owner-only).'),
|
|
65
|
+
content: z
|
|
66
|
+
.string()
|
|
67
|
+
.describe('Text to append. The client joins it to the existing file content with a newline and re-encrypts before storing.'),
|
|
68
|
+
}, async ({ path, content }) => {
|
|
69
|
+
const pathErr = validatePath(path);
|
|
70
|
+
if (pathErr)
|
|
71
|
+
return { content: [{ type: 'text', text: pathErr }], isError: true };
|
|
72
|
+
try {
|
|
73
|
+
const version = await engram.appendMemory(path, content);
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: 'text', text: jsonText({ path, version }) }],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: 'text',
|
|
83
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
isError: true,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
// 3. engram_list_memory_files
|
|
91
|
+
server.tool('engram_list_memory_files', 'List metadata for EVERY memory file: one {path, version, lastModifiedAt} entry per file, NO content. Call this first to discover paths, then fetch content with engram_read_memory or engram_read_memory_batch. Read-only.', async () => {
|
|
92
|
+
try {
|
|
93
|
+
const files = await engram.listMemoryFiles();
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: 'text', text: jsonText(files) }],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
isError: true,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// 5. engram_read_memory_batch
|
|
111
|
+
server.tool('engram_read_memory_batch', 'Read up to 50 memory files in one call. Returns a JSON array where each element is {path, content, version, lastModifiedAt} on success or {path, error} for that file; partial success is normal and a missing file never fails the whole batch. Prefer this over repeated engram_read_memory for 2+ known paths. Read-only.',
|
|
112
|
+
// Cap matches the canister's MAX_BATCH_READ_PATHS (50) and tool-schemas.json maxItems —
|
|
113
|
+
// a larger batch would pass zod here only to be rejected wholesale canister-side.
|
|
114
|
+
{
|
|
115
|
+
paths: z
|
|
116
|
+
.array(z.string())
|
|
117
|
+
.max(50)
|
|
118
|
+
.describe('Exact file paths to fetch (max 50; a larger batch is rejected wholesale). Discover paths with engram_list_memory_files.'),
|
|
119
|
+
}, async ({ paths }) => {
|
|
120
|
+
try {
|
|
121
|
+
for (const p of paths) {
|
|
122
|
+
const pathErr = validatePath(p);
|
|
123
|
+
if (pathErr)
|
|
124
|
+
return {
|
|
125
|
+
content: [
|
|
126
|
+
{
|
|
127
|
+
type: 'text',
|
|
128
|
+
text: `Invalid path "${p}": ${pathErr}. Whole batch rejected client-side — no canister call was made and no path was read. Fix this path and resend the batch.`,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
isError: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const results = await engram.readMemoryBatch(paths);
|
|
135
|
+
const serialized = results.map(([path, fileOrError]) => {
|
|
136
|
+
if (fileOrError instanceof Error) {
|
|
137
|
+
return { path, error: fileOrError.message };
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
path,
|
|
141
|
+
content: fileOrError.content,
|
|
142
|
+
version: fileOrError.version,
|
|
143
|
+
lastModifiedAt: fileOrError.lastModifiedAt,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
content: [{ type: 'text', text: jsonText(serialized) }],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
return {
|
|
152
|
+
content: [
|
|
153
|
+
{
|
|
154
|
+
type: 'text',
|
|
155
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
isError: true,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
// 6. engram_memory_history
|
|
163
|
+
server.tool('engram_memory_history', 'Get the full version history of ONE memory file. Returns an array of {version, modifiedBy, modifiedAt, operation, contentSnapshot} where operation is Set|Append|Rollback and contentSnapshot is the decrypted content of that prior version (empty array if the path is unknown). Use engram_read_memory for just the current version; use engram_read_audit_log for the engram-wide operation ledger. Read-only.', { path: z.string().describe('Path of the memory file whose history to fetch.') }, async ({ path }) => {
|
|
164
|
+
const pathErr = validatePath(path);
|
|
165
|
+
if (pathErr)
|
|
166
|
+
return { content: [{ type: 'text', text: pathErr }], isError: true };
|
|
167
|
+
try {
|
|
168
|
+
const history = await engram.getMemoryHistory(path);
|
|
169
|
+
return {
|
|
170
|
+
content: [{ type: 'text', text: jsonText(history) }],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: 'text',
|
|
178
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
isError: true,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
// 7. engram_wallet_balance
|
|
186
|
+
server.tool('engram_wallet_balance', 'Get the engram canister CYCLES balance: infrastructure fuel, NOT a token or money balance (no ckUSDC/ICP amounts). Returns JSON {cyclesBalance} (bigint serialized as a string). Requires wallet.read (canReadWallet) or owner. For a broader health snapshot use engram_status.', async () => {
|
|
187
|
+
try {
|
|
188
|
+
const cycles = await engram.walletBalance();
|
|
189
|
+
// Match HTTP MCP shape: {cyclesBalance: <number-or-string>}
|
|
190
|
+
// BigInt serialized via jsonText becomes a string representation.
|
|
191
|
+
return {
|
|
192
|
+
content: [
|
|
193
|
+
{
|
|
194
|
+
type: 'text',
|
|
195
|
+
text: jsonText({ cyclesBalance: cycles }),
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
return {
|
|
202
|
+
content: [
|
|
203
|
+
{
|
|
204
|
+
type: 'text',
|
|
205
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
isError: true,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
// NOTE: there is intentionally no `engram_transfer` tool. Operators are
|
|
213
|
+
// append-only and have zero owner-level fund control; the only money-moving
|
|
214
|
+
// canister method is the owner-only `ownerWithdraw`, which is never exposed on
|
|
215
|
+
// the operator MCP surface. (Removed: it called a non-existent
|
|
216
|
+
// `operatorTransfer` method and advertised a `wallet.spend` capability that
|
|
217
|
+
// contradicts the operator invariant.)
|
|
218
|
+
// 9. engram_status
|
|
219
|
+
server.tool('engram_status', 'FREE health snapshot of the engram canister: version, memoryFileCount, auditLogSize, operatorCount, guardianCount, paymentsFrozen, writesPaused, backup and write counters, encryptionEnabled; owner and cyclesBalance are included only when the session is an authorized owner/operator/guardian (masked to null/0 otherwise). Check paymentsFrozen/writesPaused before paying or appending. For just the cycles number use engram_wallet_balance.', async () => {
|
|
220
|
+
try {
|
|
221
|
+
const status = await engram.status();
|
|
222
|
+
return {
|
|
223
|
+
content: [{ type: 'text', text: jsonText(status) }],
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
return {
|
|
228
|
+
content: [
|
|
229
|
+
{
|
|
230
|
+
type: 'text',
|
|
231
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
isError: true,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
// engram_read_audit_log
|
|
239
|
+
server.tool('engram_read_audit_log', 'Read the engram-wide chained audit log: who did what across memory writes, payments, services, and custody. Returns entries {id, timestamp, caller, callerRole, operation, details, success}. For content changes of ONE file use engram_memory_history instead. Requires an authenticated owner/operator/guardian session; returns [] if unauthorized.', {
|
|
240
|
+
fromIndex: z
|
|
241
|
+
.number()
|
|
242
|
+
.optional()
|
|
243
|
+
.describe('Entry index to start reading from (0 = oldest; default 0)'),
|
|
244
|
+
limit: z
|
|
245
|
+
.number()
|
|
246
|
+
.min(1)
|
|
247
|
+
.max(1000)
|
|
248
|
+
.optional()
|
|
249
|
+
.default(100)
|
|
250
|
+
.describe('Max entries to return (default 100, max 1000; the canister caps a single read at 500)'),
|
|
251
|
+
}, async ({ fromIndex, limit }) => {
|
|
252
|
+
try {
|
|
253
|
+
const entries = await engram.readAuditLog(fromIndex ?? 0, limit);
|
|
254
|
+
return {
|
|
255
|
+
content: [{ type: 'text', text: jsonText(entries) }],
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
return {
|
|
260
|
+
content: [
|
|
261
|
+
{
|
|
262
|
+
type: 'text',
|
|
263
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
isError: true,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
// === ic402 Service Marketplace ===
|
|
271
|
+
server.tool('engram_list_services', 'FREE discovery of ic402 paid services on this engram (enabled services only): read-only, spends nothing. Each entry includes {id, name, enabled}; pass the id as serviceId to engram_submit_service_request, which is the step that actually pays.', {}, async () => {
|
|
272
|
+
try {
|
|
273
|
+
const services = await engram.listServices();
|
|
274
|
+
return { content: [{ type: 'text', text: jsonText(services) }] };
|
|
275
|
+
}
|
|
276
|
+
catch (err) {
|
|
277
|
+
return {
|
|
278
|
+
content: [
|
|
279
|
+
{
|
|
280
|
+
type: 'text',
|
|
281
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
isError: true,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
server.tool('engram_submit_service_request', 'MOVES FUNDS: submit a paid request to an ic402 service (auto-pays via x402). Calling this settles a payment at submit time: the client auto-approves ckUSDC and the canister pulls the quoted service price (from the service record; see engram_list_services) into escrow, then creates a job. On success the returned {jobId} means payment SETTLED into escrow — poll it with engram_get_job_result to a terminal status; NEVER resubmit after success (resubmitting pays again). Returns {approvalPending} instead when the charge exceeds the owner spending policy (owner must approve first). If an error says settlement is pending confirmation, funds may be in flight — wait and reconcile, do NOT re-pay. Requires wallet.spend and payments not frozen; only call when the user intends to pay. How escrow is released depends on the service verification mode: BuyerConfirm jobs pay the operator only after engram_confirm_job; AutoSettle/HashMatch/ZkGroth16 jobs pay automatically once the operator delivers a valid result.', {
|
|
289
|
+
serviceId: z
|
|
290
|
+
.string()
|
|
291
|
+
.describe('id of an enabled service from engram_list_services; its pricing sets the amount charged'),
|
|
292
|
+
params: z
|
|
293
|
+
.string()
|
|
294
|
+
.describe('Service-specific input, UTF-8 encoded and passed to the service as opaque bytes (JSON by convention)'),
|
|
295
|
+
}, async ({ serviceId, params }) => {
|
|
296
|
+
try {
|
|
297
|
+
// Auto-pay: builds the x402 payment (ICRC-2 approve + retry) so a paid request
|
|
298
|
+
// actually settles. The plain submitServiceRequest sends no sig and can never complete.
|
|
299
|
+
const result = await engram.submitServiceRequestWithPayment(serviceId, new TextEncoder().encode(params));
|
|
300
|
+
return { content: [{ type: 'text', text: jsonText(result) }] };
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
return {
|
|
304
|
+
content: [
|
|
305
|
+
{
|
|
306
|
+
type: 'text',
|
|
307
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
isError: true,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
server.tool('engram_get_job_result', 'Poll an ic402 service job every 2s until it reaches a terminal status (Settled, Verified, Refunded, Expired, or Disputed), then return the full job object {id, status, serviceId, amount, result}. Read-only, moves NO funds; errors if the job does not terminate within maxAttempts. Reading a result does not pay the operator: use engram_confirm_job to release payment or engram_dispute_job to reject.', {
|
|
315
|
+
jobId: z.string().describe('Job ID returned by engram_submit_service_request (e.g. "job-3")'),
|
|
316
|
+
maxAttempts: z
|
|
317
|
+
.number()
|
|
318
|
+
.optional()
|
|
319
|
+
.describe('Max 2-second poll cycles before giving up (default 30, about 60s total)'),
|
|
320
|
+
}, async ({ jobId, maxAttempts }) => {
|
|
321
|
+
try {
|
|
322
|
+
const job = await engram.pollJobResult(jobId, maxAttempts ?? 30);
|
|
323
|
+
return { content: [{ type: 'text', text: jsonText(job) }] };
|
|
324
|
+
}
|
|
325
|
+
catch (err) {
|
|
326
|
+
return {
|
|
327
|
+
content: [
|
|
328
|
+
{
|
|
329
|
+
type: 'text',
|
|
330
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
isError: true,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
server.tool('engram_dispute_job', 'Reject a completed BuyerConfirm job as the buyer who paid for it: marks the job Disputed and BLOCKS payout to the operator. No immediate refund; the owner resolves the dispute or escrow auto-refunds after timeout. Only valid while the job status is Submitted, and only for the same principal that submitted it. Unhappy-path counterpart of engram_confirm_job (which releases payment).', {
|
|
338
|
+
jobId: z
|
|
339
|
+
.string()
|
|
340
|
+
.describe('Job ID of the Submitted BuyerConfirm job to dispute (must be one this caller submitted)'),
|
|
341
|
+
reason: z.string().describe('Free-text explanation for the dispute; stored in the audit log'),
|
|
342
|
+
}, async ({ jobId, reason }) => {
|
|
343
|
+
try {
|
|
344
|
+
await engram.disputeJob(jobId, reason);
|
|
345
|
+
return {
|
|
346
|
+
content: [
|
|
347
|
+
{
|
|
348
|
+
type: 'text',
|
|
349
|
+
text: `Disputed job ${jobId} — job is now marked Disputed. No funds moved yet: this is NOT a refund. Resolution (refund or release) happens later via the owner resolveDispute or timeout. Next action: wait for resolution; do not re-dispute and do not pay again.`,
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
catch (err) {
|
|
355
|
+
return {
|
|
356
|
+
content: [
|
|
357
|
+
{
|
|
358
|
+
type: 'text',
|
|
359
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
isError: true,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
server.tool('engram_confirm_job', 'MOVES FUNDS: accept a completed BuyerConfirm job, irreversibly RELEASING the escrowed payment to the operator. The amount/asset is whatever engram_submit_service_request escrowed at the quoted service price (ckUSDC from the engram pool). Only valid while the job status is Submitted, and only for the buyer principal that submitted it. Verify the result via engram_get_job_result first; if it is bad, use engram_dispute_job instead (blocks payout). Requires wallet.spend.', {
|
|
367
|
+
jobId: z
|
|
368
|
+
.string()
|
|
369
|
+
.describe('Job ID of the Submitted BuyerConfirm job to accept (must be one this caller submitted)'),
|
|
370
|
+
}, async ({ jobId }) => {
|
|
371
|
+
try {
|
|
372
|
+
await engram.confirmJob(jobId);
|
|
373
|
+
return {
|
|
374
|
+
content: [
|
|
375
|
+
{
|
|
376
|
+
type: 'text',
|
|
377
|
+
text: `Confirmed job ${jobId} — payment RELEASED to the operator from escrow. Terminal: funds have moved and this cannot be undone. Do not confirm again and do not resubmit (a repeat confirm errors out and will not double-pay; a resubmit would create a NEW paid job).`,
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
catch (err) {
|
|
383
|
+
return {
|
|
384
|
+
content: [
|
|
385
|
+
{
|
|
386
|
+
type: 'text',
|
|
387
|
+
text: `Error: ${err instanceof Error ? err.message : String(err)}\n[The canister message above is authoritative — follow its embedded next-action guidance. If it says a settlement/payment is pending confirmation, funds may be in flight: do NOT re-pay or resubmit.]`,
|
|
388
|
+
},
|
|
389
|
+
],
|
|
390
|
+
isError: true,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
// (engram_sign_typed_data removed: signTypedData is owner-only — cryptographic
|
|
395
|
+
// signing as the agent's ERC-8004 identity is a value-bearing operation that
|
|
396
|
+
// operators must not be able to perform. Owner uses dashboard or canister IDL.)
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,SAAS,YAAY,CAAC,CAAS;IAC7B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QACtB,OAAO,sIAAsI,CAAC;IAChJ,IAAI,CAAC,CAAC,MAAM,GAAG,eAAe;QAC5B,OAAO,gCAAgC,eAAe,yFAAyF,CAAC;IAClJ,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClB,OAAO,mHAAmH,CAAC;IAC7H,IAA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E;QAClB,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC/B,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,iBAAiB,KAAK,gPAAgP;qBAC7Q;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,yMAAyM;qBAC1Q;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;IAEF,+EAA+E;IAC/E,6EAA6E;IAC7E,gFAAgF;AAClF,CAAC"}
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert BigInt values in an object to strings for JSON serialization.
|
|
3
|
+
* Uses string representation to avoid precision loss for values > 2^53.
|
|
4
|
+
*/
|
|
5
|
+
export function toSerializable(value) {
|
|
6
|
+
if (value === null || value === undefined)
|
|
7
|
+
return value;
|
|
8
|
+
// Always stringify BigInt: stable type per field for the model + no precision loss.
|
|
9
|
+
if (typeof value === 'bigint') {
|
|
10
|
+
return value.toString();
|
|
11
|
+
}
|
|
12
|
+
if (typeof value === 'object' &&
|
|
13
|
+
'toText' in value &&
|
|
14
|
+
typeof value['toText'] === 'function') {
|
|
15
|
+
return value.toText();
|
|
16
|
+
}
|
|
17
|
+
if (value instanceof Uint8Array)
|
|
18
|
+
return Array.from(value);
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return value.map(toSerializable);
|
|
21
|
+
if (typeof value === 'object') {
|
|
22
|
+
const obj = {};
|
|
23
|
+
for (const [k, v] of Object.entries(value)) {
|
|
24
|
+
obj[k] = toSerializable(v);
|
|
25
|
+
}
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,oFAAoF;IACpF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IACD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,QAAQ,IAAI,KAAK;QACjB,OAAQ,KAAiC,CAAC,QAAQ,CAAC,KAAK,UAAU,EAClE,CAAC;QACD,OAAQ,KAAkC,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC;IACD,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YACtE,GAAG,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@engramx/mcp",
|
|
3
|
+
"version": "0.1.0-rc.2",
|
|
4
|
+
"description": "MCP server for EngramX — persistent, decentralized agent memory",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "EngramX <developer@engramx.ai>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/vhew/engramx",
|
|
10
|
+
"directory": "integrations/mcp"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"engramx-mcp": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@icp-sdk/core": "^5.4.0",
|
|
27
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
28
|
+
"zod": "^4.4.3",
|
|
29
|
+
"@engramx/client": "^0.1.0-rc.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^25.9.2",
|
|
33
|
+
"typescript": "^6.0.3"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"start": "node dist/index.js",
|
|
38
|
+
"test": "vitest run"
|
|
39
|
+
}
|
|
40
|
+
}
|