@priors/mcp 0.6.2 → 0.6.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/README.md CHANGED
@@ -44,7 +44,8 @@ repaying.
44
44
  Tools that move money state the amounts in their answer, are marked destructive for MCP clients, and their
45
45
  descriptions tell the assistant to confirm with you first. They run one at a time and each answers within 45 s, under an
46
46
  MCP client's usual 60 s timeout: one whose transactions have not confirmed by then says so and goes on, and a money
47
- call made meanwhile does nothing and says so. Merchant text (response bodies, listings, redirect targets)
47
+ call made meanwhile does nothing and says so. After two minutes a new call can act while that one still runs; what that
48
+ one may still borrow, sign or save keeps counting against the session caps until it ends. Merchant text (response bodies, listings, redirect targets)
48
49
  comes back between random `<<merchant-data …>>` markers, as data. They act on Robinhood Chain mainnet.
49
50
 
50
51
  ## Savings
@@ -134,7 +135,7 @@ Settings → Developer → Edit Config (`claude_desktop_config.json`), then rest
134
135
  "mcpServers": {
135
136
  "priors": {
136
137
  "command": "npx",
137
- "args": ["-y", "@priors/mcp@0.6.2"],
138
+ "args": ["-y", "@priors/mcp@0.6.3"],
138
139
  "env": {
139
140
  "PRIORS_KEY": "0xYOUR_AGENT_WALLET_KEY",
140
141
  "PRIORS_AGENT_ID": "1234"
@@ -156,7 +157,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
156
157
  "mcpServers": {
157
158
  "priors": {
158
159
  "command": "npx",
159
- "args": ["-y", "@priors/mcp@0.6.2"],
160
+ "args": ["-y", "@priors/mcp@0.6.3"],
160
161
  "env": {
161
162
  "PRIORS_KEY": "${PRIORS_KEY}",
162
163
  "PRIORS_AGENT_ID": "${PRIORS_AGENT_ID:-}"
@@ -166,7 +167,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
166
167
  }
167
168
  ```
168
169
 
169
- or, for your user only: `claude mcp add priors --scope user -e PRIORS_KEY="$PRIORS_KEY" -- npx -y @priors/mcp@0.6.2`
170
+ or, for your user only: `claude mcp add priors --scope user -e PRIORS_KEY="$PRIORS_KEY" -- npx -y @priors/mcp@0.6.3`
170
171
  (the key is expanded by your shell from the environment; do not paste it on the command line).
171
172
 
172
173
  ## Try it
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@priors/mcp",
3
3
  "mcpName": "io.github.priors-agents/priors",
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
5
5
  "private": false,
6
6
  "description": "MCP server for Priors on Robinhood Chain: pay x402 URLs in USDG, read balances, credit lines and scores, borrow and repay, and buy, sell and redeem PT-USDG. Key from PRIORS_KEY only.",
7
7
  "type": "module",
package/src/server.mjs CHANGED
@@ -254,7 +254,14 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
254
254
  // Every money call answers by its deadline, whatever it waits for (GHSA-rg79: pt_buy waited for its receipts past the
255
255
  // client's timeout, the model saw nothing, and its retry bought again). One still running then goes on, and holds
256
256
  // every later money call, as a savings withdrawal in flight does: what it sent may still land.
257
- const p = fn(args, deadline);
257
+ // What a call may still borrow, sign or save counts against the session caps from the moment its check passes
258
+ // (`count`, with no await between the two) until it ends; then only what it did, counted as before. The hold ends
259
+ // after HOLD_MAX_MS even while the call runs, and a call made then runs beside it: its check read a total that left
260
+ // the first one out, and a second borrow passed PRIORS_MAX_BORROW_TOTAL_USD (GHSA-cq9v). One that never ends stays
261
+ // counted, the safe direction (as a borrow whose answer was lost, GHSA-v9xj).
262
+ const kept = {};
263
+ const count = (k, amount) => { session[k] += amount; kept[k] = (kept[k] ?? 0n) + amount; };
264
+ const p = fn(args, deadline, count).finally(() => { for (const k of Object.keys(kept)) session[k] -= kept[k]; });
258
265
  let timer;
259
266
  const late = new Promise((_, no) => {
260
267
  timer = setTimeout(() => {
@@ -606,7 +613,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
606
613
  use_savings: z.boolean().optional().describe("Default true: once the price is known, if the wallet holds less, first take the difference out of the agent's savings, before any borrowing."),
607
614
  },
608
615
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
609
- }, serial(async ({ url, method = "GET", body, max_price_usd, max_borrow_usd, use_savings = true }, deadline) => {
616
+ }, serial(async ({ url, method = "GET", body, max_price_usd, max_borrow_usd, use_savings = true }, deadline, count) => {
610
617
  const signer = needWallet("pay_url");
611
618
  const u = await checkTarget(url);
612
619
  if (method === "GET" && body !== undefined) throw new ToolError("A GET request cannot carry a body: use POST (or another method) with body.");
@@ -655,6 +662,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
655
662
  } else {
656
663
  if (session.spent + maxPrice > spendCap) throw new ToolError(`this would bring what pay_url may sign in this session to ${usd(session.spent + maxPrice)}, above ${usd(spendCap)} (PRIORS_MAX_SPEND_USD). ${usd(session.spent)} was signed so far; the user can raise the limit and restart the server.`);
657
664
  if (maxBorrow > 0n && session.borrowed + maxBorrow > borrowTotalCap) throw new ToolError(`this could bring what is borrowed in this session to ${usd(session.borrowed + maxBorrow)}, above ${usd(borrowTotalCap)} (PRIORS_MAX_BORROW_TOTAL_USD).`);
665
+ count("spent", maxPrice); count("borrowed", maxBorrow); // the most it may sign and borrow, until it ends (GHSA-cq9v)
658
666
  let agentId;
659
667
  if (maxBorrow > 0n) { agentId = await resolveAgent(); await needController(agentId); }
660
668
  // The agent's own savings before a loan: once the 402 names the price, only what the wallet is short of.
@@ -829,12 +837,13 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
829
837
  dry_run: z.boolean().optional().describe("true: only quote the fee and due amount, borrow nothing."),
830
838
  },
831
839
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
832
- }, serial(async ({ amount_usd, days, dry_run }) => {
840
+ }, serial(async ({ amount_usd, days, dry_run }, _deadline, count) => {
833
841
  needWallet("borrow");
834
842
  const amount = dollars(amount_usd, "amount_usd");
835
843
  if (amount === 0n) throw new ToolError("amount_usd must be above zero");
836
844
  if (amount > maxBorrowCeiling) throw new ToolError(`amount_usd ${X.formatUsdg(amount)} is above this server's ceiling of ${usd(maxBorrowCeiling)} (PRIORS_MAX_BORROW_USD).`);
837
845
  if (!dry_run && session.borrowed + amount > borrowTotalCap) throw new ToolError(`this would bring what is borrowed in this session to ${usd(session.borrowed + amount)}, above ${usd(borrowTotalCap)} (PRIORS_MAX_BORROW_TOTAL_USD).`);
846
+ if (!dry_run) count("borrowed", amount); // until this call ends (GHSA-cq9v)
838
847
  const term = BigInt(Math.round(days * 86400));
839
848
  const id = await resolveAgent();
840
849
  await needController(id);
@@ -984,7 +993,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
984
993
  description: "Move USDG from the configured wallet into the savings vault (Steakhouse USDG on Morpho by default), where it earns the vault's rate (which moves with its markets) until the agent needs it; pay_url and repay take it back out automatically when the wallet is short. Moves real money into a third-party vault, whose risk the agent carries: state the amount to the user and get their go-ahead first. Keep enough in the wallet for loans coming due and payments expected soon. Needs ETH for gas.",
985
994
  inputSchema: { amount_usd: z.number().positive().describe("How much to save, in US dollars of USDG.") },
986
995
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
987
- }, serial(async ({ amount_usd }) => {
996
+ }, serial(async ({ amount_usd }, _deadline, count) => {
988
997
  needSavings();
989
998
  if (savingsOff) throw new ToolError("Savings are off on this server (PRIORS_SAVINGS_VAULT=off): save is disabled. The savings and unsave tools still work.");
990
999
  needWallet("save");
@@ -992,6 +1001,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
992
1001
  if (amount === 0n) throw new ToolError("amount_usd must be above zero");
993
1002
  if (amount > maxSaveCeiling) throw new ToolError(`amount_usd ${X.formatUsdg(amount)} is above this server's ceiling of ${usd(maxSaveCeiling)} per save (PRIORS_MAX_SAVE_USD).`);
994
1003
  if (session.saved + amount > saveTotalCap) throw new ToolError(`this would bring what save moved in this session to ${usd(session.saved + amount)}, above ${usd(saveTotalCap)} (PRIORS_MAX_SAVE_TOTAL_USD).`);
1004
+ count("saved", amount); // until this call ends (GHSA-cq9v)
995
1005
  // Payments signed and not yet settled still need their USDG in the wallet: never save it away from under them.
996
1006
  const nowS = Math.floor(Date.now() / 1000);
997
1007
  refresh(); // another session's pending payments need their USDG too