@prismnetwork/mcp 0.8.1 → 0.8.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/budget.mjs +5 -8
- package/package.json +2 -2
- package/server.mjs +15 -4
package/budget.mjs
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
// What stands between a model deciding to rent a GPU and a wallet paying for it.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// alone never was one. `max_usdg` bounds a single lease at 1 USDG by default and
|
|
7
|
-
// says nothing about the fortieth lease in a row, which is the failure an
|
|
8
|
-
// unattended agent actually produces.
|
|
2
|
+
// The real ceiling is the balance; fund the agent wallet with what you are
|
|
3
|
+
// willing to lose. This is the second line, and it exists because `max_usdg`
|
|
4
|
+
// never was one: it bounds a single lease and says nothing about the fortieth in
|
|
5
|
+
// a row, which is what an unattended agent actually does.
|
|
9
6
|
//
|
|
10
7
|
// Spend is written before the money moves and reverted only when the attempt
|
|
11
8
|
// provably cost nothing, so a crash between funding and reply is counted rather
|
|
12
9
|
// than forgiven. The file is shared across clients on purpose: one wallet gets
|
|
13
|
-
// one daily ceiling
|
|
10
|
+
// one daily ceiling whoever is holding it.
|
|
14
11
|
import { mkdirSync, readFileSync, renameSync, writeFileSync, openSync, closeSync, unlinkSync, statSync } from "node:fs";
|
|
15
12
|
import { homedir } from "node:os";
|
|
16
13
|
import { dirname, join } from "node:path";
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismnetwork/mcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "MCP server for leasing and running on Prism Network GPUs.",
|
|
5
|
-
"mcpName": "
|
|
5
|
+
"mcpName": "tech.prismnetwork/mcp",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"prism-mcp": "server.mjs"
|
package/server.mjs
CHANGED
|
@@ -79,14 +79,25 @@ function requireLedger(tool) {
|
|
|
79
79
|
async function spending(tool, micros, run) {
|
|
80
80
|
const book = requireLedger(tool);
|
|
81
81
|
const id = book.commit({ tool, micros });
|
|
82
|
+
// Reconciling is bookkeeping and must never be the reason a caller loses a
|
|
83
|
+
// machine it paid for, or the reason a failure is reported as the wrong
|
|
84
|
+
// failure. A ledger that cannot be written says so on stderr and the
|
|
85
|
+
// committed figure stands, which errs towards counting the spend.
|
|
86
|
+
const reconcile = (action, ...args) => {
|
|
87
|
+
try {
|
|
88
|
+
book[action](id, ...args);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error(`prism mcp: could not ${action} the ledger entry for ${tool}: ${err?.message ?? err}`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
82
93
|
try {
|
|
83
94
|
const { value, settledMicros, reference } = await run();
|
|
84
|
-
|
|
95
|
+
reconcile("settle", { micros: settledMicros, reference });
|
|
85
96
|
return value;
|
|
86
97
|
} catch (err) {
|
|
87
98
|
const funded = err?.body?.funding_hash;
|
|
88
|
-
if (funded)
|
|
89
|
-
else
|
|
99
|
+
if (funded) reconcile("settle", { reference: funded });
|
|
100
|
+
else reconcile("revert");
|
|
90
101
|
throw err;
|
|
91
102
|
}
|
|
92
103
|
}
|
|
@@ -679,7 +690,7 @@ async function handleVault(name, args) {
|
|
|
679
690
|
throw new Error(`unknown tool ${name}`);
|
|
680
691
|
}
|
|
681
692
|
|
|
682
|
-
const server = new Server({ name: "prism", version: "0.8.
|
|
693
|
+
const server = new Server({ name: "prism", version: "0.8.3" }, { capabilities: { tools: {} } });
|
|
683
694
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
684
695
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
685
696
|
try {
|