@priors/mcp 0.10.0 → 0.10.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/CHANGELOG.md +30 -0
- package/README.md +8 -8
- package/package.json +2 -2
- package/src/server.mjs +44 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @priors/mcp changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.2 (2026-10-23)
|
|
4
|
+
|
|
5
|
+
- **Every money tool needs the agent's owner or its declared ERC-8004 wallet.** CreditPoolV2 lets an owner name any
|
|
6
|
+
address its pool delegate without that address's consent. A buyer of an agent this wallet once held (or was the
|
|
7
|
+
key of) could name the wallet delegate, borrow, and have `repay` (by `loan_id` or `all: true`) pay the buyer's loans
|
|
8
|
+
from the wallet's USDG, after taking the difference out of its savings, whether the agent came from
|
|
9
|
+
`PRIORS_AGENT_ID` or from the lookup. A wallet that is not the owner must now be the agent's declared wallet (set
|
|
10
|
+
only by its own `AgentWalletSet` signature naming the owner, cleared by a transfer: AutoRepay v2's rule).
|
|
11
|
+
`repay`, `borrow`, `pay_url`, `pay_gateway`, `fund_base` and `autopay_on` all check it, before anything is read,
|
|
12
|
+
signed or sent, and `repay` leaves savings untouched. **Borrowing and repaying are deliberately symmetric:** a key
|
|
13
|
+
that may not repay here may not borrow here either, so no agent can draw a loan this server would then refuse to
|
|
14
|
+
settle before its due date.
|
|
15
|
+
- **Breaking for a delegate-only key.** A key named with `setDelegate` but never declared as the agent's wallet now
|
|
16
|
+
does nothing with money here. Its owner declares it once: run `priors-mcp link-wallet --agent <id>`, which prints
|
|
17
|
+
the key's `AgentWalletSet` signature, and the owner sends the registry's `setAgentWallet` (Go mode's Start key is
|
|
18
|
+
already both). Until then, act from the owner's key. Every refusal says this.
|
|
19
|
+
- **The agent the lookup found is kept only while the wallet owns it.** Without `PRIORS_AGENT_ID`, the identity found
|
|
20
|
+
was kept for the whole process; one sold since is now looked up again (and so no longer taken as the wallet's).
|
|
21
|
+
|
|
22
|
+
## 0.10.1 (2026-10-22)
|
|
23
|
+
|
|
24
|
+
- **`pay_url` no longer times out for a wallet with no `PRIORS_AGENT_ID`.** Since 0.10.0 bundles AutoRepay's address,
|
|
25
|
+
`pay_url` keeps back what Autopay pulls in the next 24 h, which first looks up the wallet's agent in the registry's
|
|
26
|
+
logs (some 470 reads on chain 4663). 0.10.0 waited for that lookup with no bound and repeated it before every
|
|
27
|
+
payment, so a payment from a wallet that owns no agent, or whose agent the lookup is slow to find, ran out of its
|
|
28
|
+
45 s. The lookup now gets a quarter of the call's budget (10 s at most) and keeps nothing back when it runs out, as a
|
|
29
|
+
failed Autopay read always did; a wallet found to own no agent is not looked up again for 10 minutes, unless another
|
|
30
|
+
tool (such as `credit_status`) has found its agent since, and then its plan is read at once. With
|
|
31
|
+
`PRIORS_AGENT_ID` set, nothing changes. `fund_base`'s reserve is the same code. Use 0.10.1 rather than 0.10.0.
|
|
32
|
+
|
|
3
33
|
## 0.10.0 (2026-10-22)
|
|
4
34
|
|
|
5
35
|
- **Repay on time works with no setting.** The bundled deployment record names AutoRepay v2
|
package/README.md
CHANGED
|
@@ -33,8 +33,8 @@ repaying.
|
|
|
33
33
|
| `credit_status(agent_id?)` | line, drawn, available, backer, record, score, open loans and due dates; on a stock line, the stock tokens behind it, and `available` capped by what the stock vault lets it draw | no (with `agent_id`) |
|
|
34
34
|
| `stock_assets(symbol?)` | the stock tokens the Priors stock vault accepts: live Chainlink price, whether it lends against each now (or why not: a sharp price move, a multiplier change, a paused or blocked token), loan-to-value | no |
|
|
35
35
|
| `stock_position(agent_id?)` | the stock tokens behind an agent's stock line: amount, what the vault values them at, loan-to-value, what the line can draw now, any lending hold | no (with `agent_id`) |
|
|
36
|
-
| `borrow(amount_usd, days, dry_run?)` | borrow USDG from the line into the wallet; both amounts required; `dry_run` quotes the fee. A borrow sent whose answer is lost is counted and said to be possibly open (check `credit_status`) | yes |
|
|
37
|
-
| `repay(loan_id? \| all, use_savings?)` | repay one of the agent's own loans, or all of them earliest due first; another agent's loan is refused, and (0.8.1) so is a loan opened while someone else held the agent
|
|
36
|
+
| `borrow(amount_usd, days, dry_run?)` | borrow USDG from the line into the wallet; both amounts required; `dry_run` quotes the fee. (unreleased) Needs the wallet to be the agent's owner or its declared ERC-8004 wallet, the same rule as `repay`. A borrow sent whose answer is lost is counted and said to be possibly open (check `credit_status`) | yes |
|
|
37
|
+
| `repay(loan_id? \| all, use_savings?)` | repay one of the agent's own loans, or all of them earliest due first; another agent's loan is refused, and (0.8.1) so is a loan opened while someone else held the agent; (unreleased) a wallet that is neither the agent's owner nor its declared ERC-8004 wallet (a pool delegate the owner named) repays nothing — and, symmetrically, borrows nothing, so no loan is drawn that this server would then refuse to repay: the owner declares the agent's key with `priors-mcp link-wallet`. If the wallet is short of what is due, it first takes the difference out of savings (unless `use_savings: false`). From 0.8.0 its answer ends with share facts for each loan repaid (amount, on time or late, the record's page; also as structured content); the server never posts | yes |
|
|
38
38
|
| `savings(address?)` | what the wallet (or any address) has saved in the savings vault, how much can come out right now, and the USDG in the wallet | no (with `address`) |
|
|
39
39
|
| `save(amount_usd)` | move spare USDG from the wallet into the savings vault, where it earns the vault's rate (at most `PRIORS_MAX_SAVE_USD` per call, `PRIORS_MAX_SAVE_TOTAL_USD` per run); needs ETH for gas | yes |
|
|
40
40
|
| `unsave(amount_usd? \| all)` | take USDG back out of savings into the wallet: a normal withdrawal, and when that is not enough, the rest from the vault's other markets in the same transaction (only where that costs no penalty); refused before any transaction when even that cannot pay it; needs ETH for gas | yes |
|
|
@@ -209,7 +209,7 @@ Settings → Developer → Edit Config (`claude_desktop_config.json`), then rest
|
|
|
209
209
|
"mcpServers": {
|
|
210
210
|
"priors": {
|
|
211
211
|
"command": "npx",
|
|
212
|
-
"args": ["-y", "@priors/mcp@0.10.
|
|
212
|
+
"args": ["-y", "@priors/mcp@0.10.2"],
|
|
213
213
|
"env": {
|
|
214
214
|
"PRIORS_KEY": "0xYOUR_AGENT_WALLET_KEY",
|
|
215
215
|
"PRIORS_AGENT_ID": "1234"
|
|
@@ -231,7 +231,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
|
|
|
231
231
|
"mcpServers": {
|
|
232
232
|
"priors": {
|
|
233
233
|
"command": "npx",
|
|
234
|
-
"args": ["-y", "@priors/mcp@0.10.
|
|
234
|
+
"args": ["-y", "@priors/mcp@0.10.2"],
|
|
235
235
|
"env": {
|
|
236
236
|
"PRIORS_KEY": "${PRIORS_KEY}",
|
|
237
237
|
"PRIORS_AGENT_ID": "${PRIORS_AGENT_ID:-}"
|
|
@@ -244,7 +244,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
|
|
|
244
244
|
or, for your user only, from a macOS or Linux terminal:
|
|
245
245
|
|
|
246
246
|
```sh
|
|
247
|
-
(read -rs PRIORS_KEY && umask 077 && mkdir -p ~/.config/priors && rm -f ~/.config/priors/agent.key && printf '%s\n' "$PRIORS_KEY" > ~/.config/priors/agent.key) && claude mcp add priors --scope user -- sh -c 'read -r PRIORS_KEY < "$1" && export PRIORS_KEY && exec npx -y @priors/mcp@0.10.
|
|
247
|
+
(read -rs PRIORS_KEY && umask 077 && mkdir -p ~/.config/priors && rm -f ~/.config/priors/agent.key && printf '%s\n' "$PRIORS_KEY" > ~/.config/priors/agent.key) && claude mcp add priors --scope user -- sh -c 'read -r PRIORS_KEY < "$1" && export PRIORS_KEY && exec npx -y @priors/mcp@0.10.2' priors-mcp ~/.config/priors/agent.key
|
|
248
248
|
```
|
|
249
249
|
|
|
250
250
|
It waits for the key without showing it (paste it, then Enter), saves it in a file only you can read, and gives Claude
|
|
@@ -300,7 +300,7 @@ to approve a borrow; this package, with the key, pays for APIs. With borrowing o
|
|
|
300
300
|
approves each loan in Priors' Go mode. ElizaOS (`@elizaos/plugin-mcp`):
|
|
301
301
|
|
|
302
302
|
```ts
|
|
303
|
-
"priors-wallet": { type: "stdio", command: "npx", args: ["-y", "@priors/mcp@0.10.
|
|
303
|
+
"priors-wallet": { type: "stdio", command: "npx", args: ["-y", "@priors/mcp@0.10.2"],
|
|
304
304
|
env: { PRIORS_KEY_FILE: "/home/agent/.config/priors/agent-7311.key", PRIORS_AGENT_ID: "7311",
|
|
305
305
|
PRIORS_MAX_BORROW_USD: "0", PRIORS_MAX_BORROW_DAY_USD: "0", PRIORS_MAX_SPEND_DAY_USD: "1", PRIORS_MAX_PRICE_USD: "0.10",
|
|
306
306
|
PRIORS_PAY_HOSTS: "api.example.com" } }
|
|
@@ -312,7 +312,7 @@ OpenClaw (`mcp.servers`, JSON5) takes the same `command`, `args` and `env`; Herm
|
|
|
312
312
|
mcp_servers:
|
|
313
313
|
priors-wallet:
|
|
314
314
|
command: npx
|
|
315
|
-
args: ["-y", "@priors/mcp@0.10.
|
|
315
|
+
args: ["-y", "@priors/mcp@0.10.2"]
|
|
316
316
|
env:
|
|
317
317
|
PRIORS_KEY_FILE: /home/agent/.config/priors/agent-7311.key
|
|
318
318
|
PRIORS_AGENT_ID: "7311"
|
|
@@ -339,7 +339,7 @@ key proves it is there: it signs the ERC-8004 identity registry's `AgentWalletSe
|
|
|
339
339
|
agent's).
|
|
340
340
|
|
|
341
341
|
```sh
|
|
342
|
-
PRIORS_KEY_FILE=~/.config/priors/agent-7311.key npx -y @priors/mcp@0.10.
|
|
342
|
+
PRIORS_KEY_FILE=~/.config/priors/agent-7311.key npx -y @priors/mcp@0.10.2 link-wallet --agent 7311
|
|
343
343
|
```
|
|
344
344
|
|
|
345
345
|
It reads the registry's EIP-712 domain and refuses to sign for any other, takes the owner from the chain (`--owner`
|
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.10.
|
|
4
|
+
"version": "0.10.2",
|
|
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_FILE (a file only you can read) or PRIORS_KEY, never the command line.",
|
|
7
7
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@modelcontextprotocol/sdk": "^1.30.1",
|
|
48
|
-
"@priors/x402": "0.8.
|
|
48
|
+
"@priors/x402": "0.8.1",
|
|
49
49
|
"ethers": "^6.13.4",
|
|
50
50
|
"undici": "6.29.0",
|
|
51
51
|
"viem": "^2.56.9",
|
package/src/server.mjs
CHANGED
|
@@ -744,6 +744,8 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
744
744
|
// who held the agent when the loan was opened (the pool's Loan.owner), and who holds it now
|
|
745
745
|
loanOwner: async (loanId) => (await contracts.pool.getLoan(loanId)).owner,
|
|
746
746
|
agentOwner: (id) => contracts.registry.ownerOf(id),
|
|
747
|
+
// the agent's declared ERC-8004 wallet: set only with that wallet's own signature naming the owner, cleared by a transfer
|
|
748
|
+
agentWallet: (id) => contracts.registry.getAgentWallet(id),
|
|
747
749
|
isController: (id, addr) => contracts.pool.isController(id, addr),
|
|
748
750
|
agentsOf: (addr) => discoverAgents(addr),
|
|
749
751
|
loanDue: async (loanId) => { const l = await contracts.pool.getLoan(loanId); return Number(l.status) === 1 ? l.principal + l.fee : null; },
|
|
@@ -759,7 +761,8 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
759
761
|
topUp: async (need, o) => S.topUpFromSavings(await savingsC(), wallet, need, o),
|
|
760
762
|
// fund_base's loan: pay_url's borrow-the-gap (a draw of max(shortfall, the pool's minimum loan), simulated first),
|
|
761
763
|
// and the pool's minimum loan, read so a refusal can name the max_borrow_usd that would do
|
|
762
|
-
|
|
764
|
+
// the parties come from this server's own registry contract (GHSA-9pw7: borrowing takes the repayment rule)
|
|
765
|
+
borrowGap: (o) => C.borrowGap({ signer: wallet, pool: addresses.pool, ...v5, ownerOf: (id) => contracts.registry.ownerOf(id), agentWalletOf: (id) => contracts.registry.getAgentWallet(id), ...o }),
|
|
763
766
|
minLoan: async () => (await contracts.pool.getParams()).minLoan,
|
|
764
767
|
};
|
|
765
768
|
let savingsCache = null;
|
|
@@ -850,11 +853,15 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
850
853
|
return BigInt(env.PRIORS_AGENT_ID);
|
|
851
854
|
}
|
|
852
855
|
if (!wallet) throw new ToolError("No agent id given, and no wallet is configured (PRIORS_KEY) to look one up. Pass agent_id.");
|
|
853
|
-
|
|
856
|
+
// the identity found is kept only while this wallet still owns it: one sold since is looked up again (GHSA-9pw7)
|
|
857
|
+
if (agentCache !== null) {
|
|
858
|
+
if (String(await credit.agentOwner(agentCache)).toLowerCase() === wallet.address.toLowerCase()) return agentCache;
|
|
859
|
+
agentCache = null;
|
|
860
|
+
}
|
|
854
861
|
const mine = await credit.agentsOf(wallet.address);
|
|
855
862
|
if (mine.length === 1) return (agentCache = mine[0]);
|
|
856
863
|
if (mine.length > 1) throw new ToolError(`This wallet owns several agent identities (${mine.map((i) => "#" + i).join(", ")}). Set PRIORS_AGENT_ID or pass agent_id.`);
|
|
857
|
-
throw new ToolError("This wallet owns no Priors agent identity minted to it since the v2 deploy and held ever since. Set PRIORS_AGENT_ID if it owns an older one, or one that left it and came back, or register first (`npx priors-v2 join`, from a clone of github.com/priors-agents/priors).");
|
|
864
|
+
throw Object.assign(new ToolError("This wallet owns no Priors agent identity minted to it since the v2 deploy and held ever since. Set PRIORS_AGENT_ID if it owns an older one, or one that left it and came back, or register first (`npx priors-v2 join`, from a clone of github.com/priors-agents/priors)."), { noAgent: true });
|
|
858
865
|
}
|
|
859
866
|
|
|
860
867
|
function needWallet(action) {
|
|
@@ -863,8 +870,22 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
863
870
|
if (!wallet) throw new ToolError(`${action} moves money and needs a wallet: set PRIORS_KEY_FILE (the path of a file holding the key, readable by your user only) or PRIORS_KEY in the MCP server's environment (never pass a key as a tool argument or on the command line). Read-only tools (wallet_balance and savings with an address, credit_status, stock_assets, stock_position, score_of, find_services) work without it.`);
|
|
864
871
|
return wallet;
|
|
865
872
|
}
|
|
866
|
-
|
|
873
|
+
/**
|
|
874
|
+
* Before this wallet's money moves for agent `id`: it must control the agent at the pool AND be the agent's current
|
|
875
|
+
* owner or its declared ERC-8004 wallet. `setDelegate` lets an owner name any address its delegate with no word from
|
|
876
|
+
* that address (GHSA-9pw7), so being a controller is no proof this wallet acts for that owner: a buyer of an agent
|
|
877
|
+
* this wallet once held could otherwise borrow and have `repay` pay it from this wallet's USDG and savings. The
|
|
878
|
+
* declared wallet is set only by that wallet's own AgentWalletSet signature naming the owner and cleared by a
|
|
879
|
+
* transfer (AutoRepay v2's rule). Borrowing takes the same rule as repaying, so no key can borrow here and then be
|
|
880
|
+
* refused the repayment that would keep it out of a default. `did` is what did not happen.
|
|
881
|
+
*/
|
|
882
|
+
async function needController(id, did = "done") {
|
|
867
883
|
if (!(await credit.isController(id, wallet.address))) throw new ToolError(`This wallet (${wallet.address}) does not control agent #${id} on the pool (it is neither the owner nor its delegate).`);
|
|
884
|
+
const me = wallet.address.toLowerCase();
|
|
885
|
+
const holder = String(await credit.agentOwner(id));
|
|
886
|
+
if (holder.toLowerCase() === me) return;
|
|
887
|
+
if (String(await credit.agentWallet(id)).toLowerCase() === me) return;
|
|
888
|
+
throw new ToolError(`This wallet (${wallet.address}) is neither agent #${id}'s owner (${holder}) nor its declared ERC-8004 wallet, so nothing shows it acts for that owner: the pool lets an owner name any address its delegate. Nothing was ${did}. If this is the agent's own key, declare it as the agent's wallet (\`priors-mcp link-wallet\`, then its owner sends the registry's setAgentWallet), or act from the owner's key.`);
|
|
868
889
|
}
|
|
869
890
|
|
|
870
891
|
// Every answer as the model gets it (fence.mjs guarded): the third-party strings it quotes outside the server's own
|
|
@@ -899,13 +920,23 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
899
920
|
return autopay;
|
|
900
921
|
}
|
|
901
922
|
/** What pay_url keeps back: what the wallet's Autopay plan pulls for loans whose window opens in the next 24 h. A
|
|
902
|
-
* failed read keeps nothing back (the payment goes on as before) and is never an error.
|
|
923
|
+
* failed read keeps nothing back (the payment goes on as before) and is never an error. Without PRIORS_AGENT_ID the
|
|
924
|
+
* wallet's agent is looked up first, in the registry's logs: that lookup gets a quarter of the call's budget (10 s at
|
|
925
|
+
* most), and a wallet it finds owning no agent, so with no plan to keep anything for, is not looked up again for 10
|
|
926
|
+
* minutes, unless another tool has found its agent since (0.10.0 waited for the lookup with no bound before every
|
|
927
|
+
* payment, so a payment from such a wallet ran out of time). */
|
|
928
|
+
const RESERVE_LOOKUP_MS = Math.min(10_000, Math.floor(callBudgetMs / 4));
|
|
929
|
+
let noAgentUntil = 0;
|
|
903
930
|
async function autopayReserve() {
|
|
904
931
|
if (!reserveOn || !autopay || !wallet) return 0n;
|
|
932
|
+
if (agentCache === null && Date.now() < noAgentUntil) return 0n;
|
|
905
933
|
try {
|
|
906
|
-
const id = await resolveAgent();
|
|
934
|
+
const id = await withinTime(resolveAgent(), RESERVE_LOOKUP_MS);
|
|
907
935
|
return A.autopayReserve(await withinTime(autopay.status(wallet.address, id), 10_000));
|
|
908
|
-
} catch (
|
|
936
|
+
} catch (e) {
|
|
937
|
+
if (e?.noAgent) noAgentUntil = Date.now() + 600_000;
|
|
938
|
+
return 0n;
|
|
939
|
+
}
|
|
909
940
|
}
|
|
910
941
|
/** Autopay lines for credit_status: the wallet's plan, its budget, the next loan it pays, a shortfall. */
|
|
911
942
|
async function autopayLines(id) {
|
|
@@ -1033,7 +1064,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1033
1064
|
reserveDay(maxPrice, maxBorrow); // the day's limits, across restarts and sessions: refused here, nothing is signed
|
|
1034
1065
|
count("spent", maxPrice); count("borrowed", maxBorrow); // the most it may sign and borrow, until it ends (GHSA-cq9v)
|
|
1035
1066
|
let agentId;
|
|
1036
|
-
if (maxBorrow > 0n) { agentId = await resolveAgent(); await needController(agentId); }
|
|
1067
|
+
if (maxBorrow > 0n) { agentId = await resolveAgent(); await needController(agentId, "paid or borrowed"); }
|
|
1037
1068
|
// The agent's own savings before a loan: once the 402 names the price, only what the wallet is short of.
|
|
1038
1069
|
const topUp = o.useSavings && autoSavings && typeof credit.topUp === "function" ? (need) => topUpWithin(need, deadline) : undefined;
|
|
1039
1070
|
const payer = X.createPayer({ signer, maxPrice, maxBorrow, fetchImpl: payFetch, pendingRetries: 2, maxSleepMs: 10_000, timeoutMs: requestTimeoutMs, signal: AbortSignal.timeout(Math.max(1, deadline - Date.now())), ...(sleep ? { sleep } : {}), ...(maxBorrow > 0n ? { pool: addresses.pool, agentId, ...v5 } : {}), ...(topUp ? { topUp } : {}), ...(reserveOn && autopay ? { reserve: autopayReserve } : {}),
|
|
@@ -1343,7 +1374,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1343
1374
|
if (!dry_run) { reserveDay(0n, amount); count("borrowed", amount); } // until this call ends (GHSA-cq9v)
|
|
1344
1375
|
const term = BigInt(Math.round(days * 86400));
|
|
1345
1376
|
const id = await resolveAgent();
|
|
1346
|
-
await needController(id);
|
|
1377
|
+
await needController(id, "borrowed");
|
|
1347
1378
|
const q = await credit.quote(id, amount, term);
|
|
1348
1379
|
if (dry_run) return `Quote for agent #${id}: borrow ${usd(amount)} for ${days} days, fee ${usd(q.fee)}, ${usd(q.due)} due at the end. Nothing was borrowed.${await savedNote(wallet.address)}`;
|
|
1349
1380
|
let r;
|
|
@@ -1390,7 +1421,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1390
1421
|
|
|
1391
1422
|
tool("repay", {
|
|
1392
1423
|
title: "Repay Priors loans",
|
|
1393
|
-
description: "Repay the agent's own Priors loans in full (principal + fee) from the configured wallet's USDG; a loan of another agent, or one opened while someone else held the agent, is refused. Give either loan_id for one loan, or all: true to repay every open loan, earliest due first, as far as the balance covers. Moves real money: state the amounts (credit_status lists them) to the user and get their go-ahead first. The answer ends with share facts for each loan repaid (the amount, on time or late, the agent's record page), also as structured content with a suggested line; this server never posts anything.",
|
|
1424
|
+
description: "Repay the agent's own Priors loans in full (principal + fee) from the configured wallet's USDG; a loan of another agent, or one opened while someone else held the agent, is refused, and so is every loan when the wallet is neither the agent's owner nor its declared ERC-8004 wallet. Give either loan_id for one loan, or all: true to repay every open loan, earliest due first, as far as the balance covers. Moves real money: state the amounts (credit_status lists them) to the user and get their go-ahead first. The answer ends with share facts for each loan repaid (the amount, on time or late, the agent's record page), also as structured content with a suggested line; this server never posts anything.",
|
|
1394
1425
|
inputSchema: {
|
|
1395
1426
|
loan_id: z.number().int().nonnegative().optional().describe("The loan to repay."),
|
|
1396
1427
|
all: z.boolean().optional().describe("true: repay every open loan of the agent, earliest due first."),
|
|
@@ -1404,7 +1435,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1404
1435
|
// Only the loans of an agent this wallet controls: the pool lets anyone repay any loan, and this wallet's USDG is
|
|
1405
1436
|
// not for others. PRIORS_AGENT_ID alone is not proof: a stale or mistyped id would point at someone else's agent.
|
|
1406
1437
|
const id = await resolveAgent();
|
|
1407
|
-
await needController(id);
|
|
1438
|
+
await needController(id, "paid");
|
|
1408
1439
|
// Only loans the agent's current owner took: one opened while someone else held the agent is theirs (the pool marks
|
|
1409
1440
|
// them if it defaults), and an identity that changed hands can arrive carrying it (GHSA-mmp8).
|
|
1410
1441
|
const holder = String(await credit.agentOwner(id)).toLowerCase();
|
|
@@ -1512,7 +1543,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1512
1543
|
if (maxBorrow === 0n) throw new ToolError(`${holds} Nothing was done. A loan from the Priors line for it would be ${loanText}: to take it, ${atLeast}; or add USDG.`);
|
|
1513
1544
|
if (loanNeed > maxBorrow) throw new ToolError(`${holds} A loan for it would be ${loanText}, above max_borrow_usd ${X.formatUsdg(maxBorrow)}. Nothing was borrowed or moved: ${atLeast}; or move less.`);
|
|
1514
1545
|
const agentId = await resolveAgent();
|
|
1515
|
-
await needController(agentId);
|
|
1546
|
+
await needController(agentId, "borrowed or moved");
|
|
1516
1547
|
// The route first (a read-only quote): a transfer Across would refuse (its fee, its minimum, a token or spoke that
|
|
1517
1548
|
// is not the pinned one) never leaves behind a loan taken for it.
|
|
1518
1549
|
try { await bridge.quote({ amount, maxFeeBps: maxBridgeFeeBps }); } catch (e) { throw new ToolError(`${explain(e)}. Nothing was borrowed or moved.`); }
|
|
@@ -1607,7 +1638,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1607
1638
|
needWallet("autopay_on");
|
|
1608
1639
|
const ap = needAutopay();
|
|
1609
1640
|
const id = await resolveAgent();
|
|
1610
|
-
await needController(id);
|
|
1641
|
+
await needController(id, "sent"); // autopay_on approves an allowance: the same rule
|
|
1611
1642
|
let cap = cap_usd !== undefined ? dollars(cap_usd, "cap_usd") : null;
|
|
1612
1643
|
if (cap === null) { const st = await credit.status(id); cap = A.defaultCap(st.line, maxAutopayCap); }
|
|
1613
1644
|
if (cap === 0n) throw new ToolError("cap_usd must be above zero");
|