@prismnetwork/mcp 0.4.2 → 0.5.0
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/README.md +11 -0
- package/package.json +1 -1
- package/server.mjs +112 -1
package/README.md
CHANGED
|
@@ -18,10 +18,14 @@ real prices. Leasing spends money, so those tools ask for a wallet and say so.
|
|
|
18
18
|
| Tool | Wallet |
|
|
19
19
|
| --- | --- |
|
|
20
20
|
| `prism_list_gpus` | no |
|
|
21
|
+
| `prism_price_index` | no |
|
|
22
|
+
| `prism_receipts` | no |
|
|
21
23
|
| `prism_wallet` | yes |
|
|
24
|
+
| `prism_leases` | yes |
|
|
22
25
|
| `prism_lease_and_run` | yes |
|
|
23
26
|
| `prism_lease` | yes |
|
|
24
27
|
| `prism_run` | yes |
|
|
28
|
+
| `prism_batch_run` | yes |
|
|
25
29
|
| `prism_end_lease` | yes |
|
|
26
30
|
| `prism_vault_store` | yes |
|
|
27
31
|
| `prism_vault_list` | yes |
|
|
@@ -31,9 +35,16 @@ real prices. Leasing spends money, so those tools ask for a wallet and say so.
|
|
|
31
35
|
|
|
32
36
|
- `prism_wallet`: the agent's address and USDG/ETH balances.
|
|
33
37
|
- `prism_list_gpus`: GPUs available to lease, with price per second and per hour.
|
|
38
|
+
- `prism_price_index`: sourced and settled pricing per GPU model, for cost estimates.
|
|
39
|
+
- `prism_receipts`: recent settled receipts from the public proof feed, with the
|
|
40
|
+
settlement transaction on Robinhood Chain.
|
|
41
|
+
- `prism_leases`: this wallet's leases and their state.
|
|
34
42
|
- `prism_lease_and_run`: lease a GPU, run a command, return the output (one shot).
|
|
35
43
|
- `prism_lease`: lease a GPU and keep it; returns a `lease_id` and SSH access.
|
|
36
44
|
- `prism_run`: run a command on an existing lease.
|
|
45
|
+
- `prism_batch_run`: fund a lease that runs one command with no interactive
|
|
46
|
+
access; the node reports the signed output. Matches only suppliers at trust
|
|
47
|
+
class `isolated` or above, so it can find no supplier when none is online.
|
|
37
48
|
- `prism_end_lease`: release a lease.
|
|
38
49
|
- `prism_vault_store`: seal private data under the wallet-derived key.
|
|
39
50
|
- `prism_vault_list`: list sealed items; values are never returned.
|
package/package.json
CHANGED
package/server.mjs
CHANGED
|
@@ -52,6 +52,14 @@ async function publicOffers(minTrust) {
|
|
|
52
52
|
return response.json();
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
const PROOF_FEED = process.env.PRISM_PROOF_URL ?? "https://prismnetwork.tech/api/proof";
|
|
56
|
+
|
|
57
|
+
async function publicJson(url, what) {
|
|
58
|
+
const response = await fetch(url, { headers: { accept: "application/json" } });
|
|
59
|
+
if (!response.ok) throw new Error(`prism ${what} unavailable (${response.status})`);
|
|
60
|
+
return response.json();
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
const leases = new Map();
|
|
56
64
|
const usdg = (micros) => `${(Number(micros) / 1e6).toFixed(6)} USDG`;
|
|
57
65
|
|
|
@@ -92,6 +100,39 @@ const TOOLS = [
|
|
|
92
100
|
},
|
|
93
101
|
},
|
|
94
102
|
},
|
|
103
|
+
{
|
|
104
|
+
name: "prism_price_index",
|
|
105
|
+
description: "Current GPU pricing on Prism Network by model: sourced low/median/high and settled mean, in USDG per hour. Needs no wallet. Use it to estimate what an analysis job will cost before leasing.",
|
|
106
|
+
inputSchema: { type: "object", properties: {} },
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "prism_receipts",
|
|
110
|
+
description: "Recent settled lease receipts from the public proof feed: GPU model, runtime, what was charged and refunded, and the settlement transaction hash on Robinhood Chain. Needs no wallet. Every Prism lease ends in one of these.",
|
|
111
|
+
inputSchema: {
|
|
112
|
+
type: "object",
|
|
113
|
+
properties: {
|
|
114
|
+
limit: { type: "integer", description: "Max receipts to return (default 10)." },
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "prism_leases",
|
|
120
|
+
description: "List this wallet's leases on Prism Network with their current state.",
|
|
121
|
+
inputSchema: { type: "object", properties: {} },
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "prism_batch_run",
|
|
125
|
+
description: "Fund a lease that runs one command with no interactive access at all: the node executes it and reports the signed output. Matches only suppliers at trust class 'isolated' or above, so it can find no supplier when none is online — prefer prism_lease_and_run for broad availability. Output is capped at 64 KiB per stream.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
command: { type: "string", description: "Shell command to run (max 8 KiB)." },
|
|
130
|
+
duration_seconds: { type: "integer", description: "Paid window in seconds (default 900, max 21600). A command still running at the end is killed and reported exit 124." },
|
|
131
|
+
min_vram_mib: { type: "integer", description: "Minimum GPU memory in MiB (default 16000)." },
|
|
132
|
+
},
|
|
133
|
+
required: ["command"],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
95
136
|
{
|
|
96
137
|
name: "prism_lease_and_run",
|
|
97
138
|
description: "Lease a GPU, run one shell command on it, and return the output. The lease stays alive (use prism_run for more commands, prism_end_lease to release). Prefer this for a single command; use prism_lease when you'll run several.",
|
|
@@ -227,6 +268,76 @@ async function handle(name, args) {
|
|
|
227
268
|
})),
|
|
228
269
|
};
|
|
229
270
|
}
|
|
271
|
+
if (name === "prism_price_index") {
|
|
272
|
+
const index = await publicJson(new URL("/v1/price-index", PUBLIC_API), "price index");
|
|
273
|
+
return {
|
|
274
|
+
currency: index.currency,
|
|
275
|
+
generated_at: index.generated_at,
|
|
276
|
+
gpus: (index.gpus ?? []).map((g) => ({
|
|
277
|
+
model: g.gpu_model,
|
|
278
|
+
sourced_low_per_hour: usdg(g.sourced_low_micros_per_hour),
|
|
279
|
+
sourced_median_per_hour: usdg(g.sourced_median_micros_per_hour),
|
|
280
|
+
sourced_high_per_hour: usdg(g.sourced_high_micros_per_hour),
|
|
281
|
+
settled_mean_per_hour: g.settled_mean_micros_per_hour == null ? null : usdg(g.settled_mean_micros_per_hour),
|
|
282
|
+
settled_leases: g.settled_leases,
|
|
283
|
+
})),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
if (name === "prism_receipts") {
|
|
287
|
+
const feed = await publicJson(PROOF_FEED, "proof feed");
|
|
288
|
+
const limit = Number.isInteger(args.limit) && args.limit > 0 ? args.limit : 10;
|
|
289
|
+
return {
|
|
290
|
+
generated_at: feed.generated_at,
|
|
291
|
+
receipts: (feed.receipts ?? []).slice(0, limit).map((r) => ({
|
|
292
|
+
lease_id: r.lease_id,
|
|
293
|
+
outcome: r.outcome,
|
|
294
|
+
gpu_model: r.gpu_model,
|
|
295
|
+
trust: r.trust_class,
|
|
296
|
+
runtime_seconds: r.runtime_seconds,
|
|
297
|
+
charged: usdg(r.charged_base_units),
|
|
298
|
+
refunded: usdg(r.refunded_base_units),
|
|
299
|
+
settlement_tx: r.transaction_hash,
|
|
300
|
+
})),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
if (name === "prism_leases") {
|
|
304
|
+
requireWallet(name);
|
|
305
|
+
await ensureAuth();
|
|
306
|
+
const all = await agent.leases();
|
|
307
|
+
return {
|
|
308
|
+
total: all.length,
|
|
309
|
+
showing: Math.min(all.length, 20),
|
|
310
|
+
leases: all.slice(0, 20).map((l) => ({
|
|
311
|
+
lease_id: l.lease_id,
|
|
312
|
+
state: l.state,
|
|
313
|
+
image: l.image,
|
|
314
|
+
duration_seconds: l.duration_seconds,
|
|
315
|
+
max_escrow: usdg(l.maximum_escrow),
|
|
316
|
+
trust: l.trust_class,
|
|
317
|
+
funding_tx: l.funding_transaction_hash,
|
|
318
|
+
created_at: l.created_at,
|
|
319
|
+
})),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
if (name === "prism_batch_run") {
|
|
323
|
+
if (!args.command) throw new Error("command is required");
|
|
324
|
+
requireWallet(name);
|
|
325
|
+
await ensureAuth();
|
|
326
|
+
const batch = await agent.lease({
|
|
327
|
+
image: IMAGE,
|
|
328
|
+
durationSeconds: args.duration_seconds ?? 900,
|
|
329
|
+
minVramMib: args.min_vram_mib ?? 16000,
|
|
330
|
+
command: args.command,
|
|
331
|
+
});
|
|
332
|
+
return {
|
|
333
|
+
lease_id: batch.leaseId,
|
|
334
|
+
funding_tx: batch.fundingHash,
|
|
335
|
+
exit_code: batch.result?.exit_code,
|
|
336
|
+
stdout: batch.result?.stdout,
|
|
337
|
+
stderr: batch.result?.stderr,
|
|
338
|
+
truncated: batch.result?.truncated ?? false,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
230
341
|
if (name === "prism_lease_and_run" || name === "prism_lease") {
|
|
231
342
|
if (name === "prism_lease_and_run" && !args.command) throw new Error("command is required");
|
|
232
343
|
requireWallet(name);
|
|
@@ -331,7 +442,7 @@ function ensureAuth() {
|
|
|
331
442
|
return authPromise;
|
|
332
443
|
}
|
|
333
444
|
|
|
334
|
-
const server = new Server({ name: "prism", version: "0.
|
|
445
|
+
const server = new Server({ name: "prism", version: "0.5.0" }, { capabilities: { tools: {} } });
|
|
335
446
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
336
447
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
337
448
|
try {
|