@prismnetwork/mcp 0.8.1 → 0.8.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.
Files changed (3) hide show
  1. package/budget.mjs +5 -8
  2. package/package.json +1 -1
  3. 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
- // The wallet balance is the real ceiling: fund the agent wallet with what you
4
- // are willing to lose, because nothing here can spend money that is not in the
5
- // account. This file is the second line, and it exists because the per-call cap
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 whether Claude, Codex, or a script is holding it.
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismnetwork/mcp",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "MCP server for leasing and running on Prism Network GPUs.",
5
5
  "mcpName": "io.github.prismnetwork-tech/mcp",
6
6
  "type": "module",
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
- book.settle(id, { micros: settledMicros, reference });
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) book.settle(id, { reference: funded });
89
- else book.revert(id);
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.1" }, { capabilities: { tools: {} } });
693
+ const server = new Server({ name: "prism", version: "0.8.2" }, { capabilities: { tools: {} } });
683
694
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
684
695
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
685
696
  try {