@priors/mcp 0.1.8 → 0.2.1

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
@@ -23,7 +23,9 @@ repaying.
23
23
  |---|---|---|
24
24
  | `pay_url(url, method?, body?, max_price_usd?, max_borrow_usd?)` | fetch an https URL, pay its x402 402 in USDG if the price is ≤ `max_price_usd` (default **$0.10**); borrows the gap only if `max_borrow_usd` is given. Refuses private and local addresses, never follows a redirect, answers within 45 s, and never signs a second payment for a purchase that is still pending (a new call resends the same one) | yes |
25
25
  | `wallet_balance(address?)` | USDG and gas ETH of the wallet (or any address) | no (with `address`) |
26
- | `credit_status(agent_id?)` | line, drawn, available, backer, record, score, open loans and due dates | no (with `agent_id`) |
26
+ | `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`) |
27
+ | `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 |
28
+ | `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`) |
27
29
  | `borrow(amount_usd, days, dry_run?)` | borrow USDG from the line into the wallet; both amounts required; `dry_run` quotes the fee | yes |
28
30
  | `repay(loan_id? \| all)` | repay one of the agent's own loans, or all of them earliest due first; another agent's loan is refused | yes |
29
31
  | `score_of(agent_id)` | any agent's on-chain score (0 to 1000) and repayment record, plus its Priors Score v2 and trust rung when published | no |
@@ -51,8 +53,11 @@ dedicated agent wallet holding only what the agent may spend.
51
53
  | `PRIORS_MAX_BORROW_TOTAL_USD` | `25` | most `borrow` and `pay_url` may borrow in total while the server runs |
52
54
  | `PRIORS_ALLOW_LOCAL` | off | `1` lets `pay_url` reach `http://localhost` and private addresses (local testing only) |
53
55
  | `PRIORS_SCORE_V2` | `https://priors.trade/api/score-v2` | where `score_of` reads Priors Score v2; `off` shows the on-chain score only |
56
+ | `PRIORS_STOCK_VAULT` | the bundled deployments file's `stockVault` | the stock vault the stock tools and `credit_status` read |
54
57
 
55
- Contract addresses (pool, lens, registry, USDG) come from `deployments/4663.v2.json`, bundled in the package.
58
+ Contract addresses (pool, lens, registry, USDG) come from `deployments/4663.v2.json`, bundled in the package, and the
59
+ accepted stock tokens from `deployments/stock-assets.4663.json`. The stock vault's address (live since 2026-09-28)
60
+ comes from the same deployments file, or from `PRIORS_STOCK_VAULT`.
56
61
 
57
62
  ### Claude Desktop
58
63
 
@@ -63,7 +68,7 @@ Settings → Developer → Edit Config (`claude_desktop_config.json`), then rest
63
68
  "mcpServers": {
64
69
  "priors": {
65
70
  "command": "npx",
66
- "args": ["-y", "@priors/mcp@0.1.8"],
71
+ "args": ["-y", "@priors/mcp@0.2.0"],
67
72
  "env": {
68
73
  "PRIORS_KEY": "0xYOUR_AGENT_WALLET_KEY",
69
74
  "PRIORS_AGENT_ID": "1234"
@@ -85,7 +90,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
85
90
  "mcpServers": {
86
91
  "priors": {
87
92
  "command": "npx",
88
- "args": ["-y", "@priors/mcp@0.1.8"],
93
+ "args": ["-y", "@priors/mcp@0.2.0"],
89
94
  "env": {
90
95
  "PRIORS_KEY": "${PRIORS_KEY}",
91
96
  "PRIORS_AGENT_ID": "${PRIORS_AGENT_ID:-}"
@@ -95,7 +100,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
95
100
  }
96
101
  ```
97
102
 
98
- or, for your user only: `claude mcp add priors --scope user -e PRIORS_KEY="$PRIORS_KEY" -- npx -y @priors/mcp@0.1.8`
103
+ or, for your user only: `claude mcp add priors --scope user -e PRIORS_KEY="$PRIORS_KEY" -- npx -y @priors/mcp@0.2.0`
99
104
  (the key is expanded by your shell from the environment; do not paste it on the command line).
100
105
 
101
106
  ## Try it
@@ -25,5 +25,8 @@
25
25
  "v1Pool": "0x0259889e6EBab1a18CeE7e62Bc5B9648FB6C44e5",
26
26
  "seatVaultV2": "0x6D934C07a33E7285cE691A9B258cdB53F18e6B5F",
27
27
  "seatVaultV2AgentId": 6229,
28
- "seatVaultBlock": 72192188
28
+ "seatVaultBlock": 72192188,
29
+ "stockVault": "0xbEcd07EC689988e16b870C121756C4c2C8cb02B6",
30
+ "stockVaultAgentId": 6424,
31
+ "stockVaultBlock": 74826641
29
32
  }
@@ -0,0 +1,430 @@
1
+ {
2
+ "chainId": 4663,
3
+ "generatedAt": "2026-09-27T16:24:57.452Z",
4
+ "sources": {
5
+ "tokens": "https://api.robinhood.com/rhj/assets",
6
+ "prices": "https://reference-data-directory.vercel.app/feeds-robinhood-mainnet.json"
7
+ },
8
+ "assets": [
9
+ {
10
+ "symbol": "AAPL",
11
+ "name": "Apple",
12
+ "token": "0xaF3D76f1834A1d425780943C99Ea8A608f8a93f9",
13
+ "decimals": 18,
14
+ "feed": "0x6B22A786bAa607d76728168703a39Ea9C99f2cD0",
15
+ "feedDecimals": 8,
16
+ "heartbeat": 86400,
17
+ "marketHours": "us_equities_24/5",
18
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xaf3d76f1834a1d425780943c99ea8a608f8a93f9.png",
19
+ "isin": "US0378331005"
20
+ },
21
+ {
22
+ "symbol": "AMD",
23
+ "name": "AMD",
24
+ "token": "0x86923f96303D656E4aa86D9d42D1e57ad2023fdC",
25
+ "decimals": 18,
26
+ "feed": "0x943A29E7ae51A4798823ca9eEd2ed533B2A22C72",
27
+ "feedDecimals": 8,
28
+ "heartbeat": 86400,
29
+ "marketHours": "us_equities_24/5",
30
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x86923f96303d656e4aa86d9d42d1e57ad2023fdc.png",
31
+ "isin": "US0079031078"
32
+ },
33
+ {
34
+ "symbol": "AMZN",
35
+ "name": "Amazon",
36
+ "token": "0x12f190a9F9d7D37a250758b26824B97CE941bF54",
37
+ "decimals": 18,
38
+ "feed": "0xD5a1508ceD74c084eBf3cBe853e2C968fB2a651C",
39
+ "feedDecimals": 8,
40
+ "heartbeat": 86400,
41
+ "marketHours": "us_equities_24/5",
42
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x12f190a9f9d7d37a250758b26824b97ce941bf54.png",
43
+ "isin": "US0231351067"
44
+ },
45
+ {
46
+ "symbol": "ASML",
47
+ "name": "ASML Holding NV",
48
+ "token": "0x47F93d52cBeC7C6D2CfC080e154002370a60dAEA",
49
+ "decimals": 18,
50
+ "feed": "0xB4106147E8cce40b7d46124090d373A71b70f87D",
51
+ "feedDecimals": 8,
52
+ "heartbeat": 86400,
53
+ "marketHours": "us_equities_24/5",
54
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x47f93d52cbec7c6d2cfc080e154002370a60daea.png",
55
+ "isin": "USN070592100"
56
+ },
57
+ {
58
+ "symbol": "BABA",
59
+ "name": "Alibaba",
60
+ "token": "0xad25Ac6C84D497db898fa1E8387bf6Af3532a1c4",
61
+ "decimals": 18,
62
+ "feed": "0x62Cc8F9b5f56a33c9C8A60c8B92779f523c4E984",
63
+ "feedDecimals": 8,
64
+ "heartbeat": 86400,
65
+ "marketHours": "us_equities_24/5",
66
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xad25ac6c84d497db898fa1e8387bf6af3532a1c4.png",
67
+ "isin": "US01609W1027"
68
+ },
69
+ {
70
+ "symbol": "CLSK",
71
+ "name": "CleanSpark",
72
+ "token": "0xcBB95BBF36099d34dA091dc6Fa6F49EfA257Cee3",
73
+ "decimals": 18,
74
+ "feed": "0x810c12D3a554Bc47fd39597Fe3b3AAC4941F50eF",
75
+ "feedDecimals": 8,
76
+ "heartbeat": 86400,
77
+ "marketHours": "us_equities_24/5",
78
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xcbb95bbf36099d34da091dc6fa6f49efa257cee3.png",
79
+ "isin": "US18452B2097"
80
+ },
81
+ {
82
+ "symbol": "COIN",
83
+ "name": "Coinbase",
84
+ "token": "0x6330D8C3178a418788dF01a47479c0ce7CCF450b",
85
+ "decimals": 18,
86
+ "feed": "0xA3a468A452940B7D6b69991207B508c609a98Ef2",
87
+ "feedDecimals": 8,
88
+ "heartbeat": 86400,
89
+ "marketHours": "us_equities_24/5",
90
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x6330d8c3178a418788df01a47479c0ce7ccf450b.png",
91
+ "isin": "US19260Q1076"
92
+ },
93
+ {
94
+ "symbol": "CRCL",
95
+ "name": "Circle Internet Group",
96
+ "token": "0xdF0992E440dD0be65BD8439b609d6D4366bf1CB5",
97
+ "decimals": 18,
98
+ "feed": "0x6652eDf64bA3731C4F2D3ce821A0Fb1f1f6b482a",
99
+ "feedDecimals": 8,
100
+ "heartbeat": 86400,
101
+ "marketHours": "us_equities_24/5",
102
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xdf0992e440dd0be65bd8439b609d6d4366bf1cb5.png",
103
+ "isin": "US1725731079"
104
+ },
105
+ {
106
+ "symbol": "CRWV",
107
+ "name": "CoreWeave",
108
+ "token": "0x5f10A1C971B69e47e059e1dC91901B59b3fB49C3",
109
+ "decimals": 18,
110
+ "feed": "0xe1b3aABCAFAd1c94708dc1367dcfF8Aa4407487C",
111
+ "feedDecimals": 8,
112
+ "heartbeat": 86400,
113
+ "marketHours": "us_equities_24/5",
114
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x5f10a1c971b69e47e059e1dc91901b59b3fb49c3.png",
115
+ "isin": "US21873S1087"
116
+ },
117
+ {
118
+ "symbol": "DELL",
119
+ "name": "Dell",
120
+ "token": "0x941AE714EC6D8130c7B75d67160Ca08f1e7d11Dd",
121
+ "decimals": 18,
122
+ "feed": "0x1C6c8cADBe02E19129c39dDB92281cE4c0bf206b",
123
+ "feedDecimals": 8,
124
+ "heartbeat": 86400,
125
+ "marketHours": "us_equities_24/5",
126
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x941ae714ec6d8130c7b75d67160ca08f1e7d11dd.png",
127
+ "isin": "US24703L2025"
128
+ },
129
+ {
130
+ "symbol": "EWY",
131
+ "name": "iShares MSCI South Korea fund",
132
+ "token": "0x7f0aBeF0C07280F82c6a08ead09dEd6BAE2C13Fc",
133
+ "decimals": 18,
134
+ "feed": "0xEFdf54610B62A7753Ec30bDc380847c12D32e1D1",
135
+ "feedDecimals": 8,
136
+ "heartbeat": 86400,
137
+ "marketHours": "us_equities_24/5",
138
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x7f0abef0c07280f82c6a08ead09ded6bae2c13fc.png",
139
+ "isin": "US4642867729"
140
+ },
141
+ {
142
+ "symbol": "GME",
143
+ "name": "GameStop",
144
+ "token": "0x1b0E319c6A659F002271B69dB8A7df2F911c153E",
145
+ "decimals": 18,
146
+ "feed": "0x27C71df6A64fB476468EdF256CF72c038baB5B67",
147
+ "feedDecimals": 8,
148
+ "heartbeat": 86400,
149
+ "marketHours": "us_equities_24/5",
150
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x1b0e319c6a659f002271b69db8a7df2f911c153e.png",
151
+ "isin": "US36467W1099"
152
+ },
153
+ {
154
+ "symbol": "GOOGL",
155
+ "name": "Alphabet Class A",
156
+ "token": "0x2e0847E8910a9732eB3fb1bb4b70a580ADAD4FE3",
157
+ "decimals": 18,
158
+ "feed": "0xF6f373a037c30F0e5010d854385cA89185AE638b",
159
+ "feedDecimals": 8,
160
+ "heartbeat": 86400,
161
+ "marketHours": "us_equities_24/5",
162
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x2e0847e8910a9732eb3fb1bb4b70a580adad4fe3.png",
163
+ "isin": "US02079K3059"
164
+ },
165
+ {
166
+ "symbol": "INTC",
167
+ "name": "Intel",
168
+ "token": "0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",
169
+ "decimals": 18,
170
+ "feed": "0x3f390C5C24628Ac7C489515402235FeAD71D1913",
171
+ "feedDecimals": 8,
172
+ "heartbeat": 86400,
173
+ "marketHours": "us_equities_24/5",
174
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xc72b96e0e48ecd4dc75e1e45396e26300bc39681.png",
175
+ "isin": "US4581401001"
176
+ },
177
+ {
178
+ "symbol": "IONQ",
179
+ "name": "IonQ",
180
+ "token": "0x558378E000D634A36593E338eBacdd6207640EfE",
181
+ "decimals": 18,
182
+ "feed": "0x22EfeC4919baf55F360E0EDee4AbEB26DE4971eb",
183
+ "feedDecimals": 8,
184
+ "heartbeat": 86400,
185
+ "marketHours": "us_equities_24/5",
186
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x558378e000d634a36593e338ebacdd6207640efe.png",
187
+ "isin": "US46222L1089"
188
+ },
189
+ {
190
+ "symbol": "META",
191
+ "name": "Meta Platforms",
192
+ "token": "0xc0D6457C16Cc70d6790Dd43521C899C87ce02f35",
193
+ "decimals": 18,
194
+ "feed": "0x7C38C00C30BEe9378381E7B6135d7283356D71b1",
195
+ "feedDecimals": 8,
196
+ "heartbeat": 86400,
197
+ "marketHours": "us_equities_24/5",
198
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xc0d6457c16cc70d6790dd43521c899c87ce02f35.png",
199
+ "isin": "US30303M1027"
200
+ },
201
+ {
202
+ "symbol": "MSFT",
203
+ "name": "Microsoft",
204
+ "token": "0xe93237C50D904957Cf27E7B1133b510C669c2e74",
205
+ "decimals": 18,
206
+ "feed": "0x45C3C877C15E6BA2EBB19eA114Ea508d14C1Af2E",
207
+ "feedDecimals": 8,
208
+ "heartbeat": 86400,
209
+ "marketHours": "us_equities_24/5",
210
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xe93237c50d904957cf27e7b1133b510c669c2e74.png",
211
+ "isin": "US5949181045"
212
+ },
213
+ {
214
+ "symbol": "MSTR",
215
+ "name": "Strategy Inc.",
216
+ "token": "0xec262a75e413fAfD0dF80480274532C79D42da09",
217
+ "decimals": 18,
218
+ "feed": "0x396118bdFB181e6240E74D243F266B061c0edc3D",
219
+ "feedDecimals": 8,
220
+ "heartbeat": 86400,
221
+ "marketHours": "us_equities_24/5",
222
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xec262a75e413fafd0df80480274532c79d42da09.png",
223
+ "isin": "US5949724083"
224
+ },
225
+ {
226
+ "symbol": "MU",
227
+ "name": "Micron Technology",
228
+ "token": "0xfF080c8ce2E5feadaCa0Da81314Ae59D232d4afD",
229
+ "decimals": 18,
230
+ "feed": "0x425EEFdCf05ed6526C3cE61Af99429A228a6d596",
231
+ "feedDecimals": 8,
232
+ "heartbeat": 86400,
233
+ "marketHours": "us_equities_24/5",
234
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xff080c8ce2e5feadaca0da81314ae59d232d4afd.png",
235
+ "isin": "US5951121038"
236
+ },
237
+ {
238
+ "symbol": "NBIS",
239
+ "name": "Nebius Group",
240
+ "token": "0x9D9c6684F596F66a64C030B93A886D51Fd4D7931",
241
+ "decimals": 18,
242
+ "feed": "0xE1D87B116Ba0fe898998f1D140339D1fA1E09705",
243
+ "feedDecimals": 8,
244
+ "heartbeat": 86400,
245
+ "marketHours": "us_equities_24/5",
246
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x9d9c6684f596f66a64c030b93a886d51fd4d7931.png",
247
+ "isin": "NL0009805522"
248
+ },
249
+ {
250
+ "symbol": "NVDA",
251
+ "name": "NVIDIA",
252
+ "token": "0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC",
253
+ "decimals": 18,
254
+ "feed": "0x379EC4f7C378F34a1B47E4F3cbeBCbAC3E8E9F15",
255
+ "feedDecimals": 8,
256
+ "heartbeat": 86400,
257
+ "marketHours": "us_equities_24/5",
258
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xd0601ce157db5bdc3162bbac2a2c8af5320d9eec.png",
259
+ "isin": "US67066G1040"
260
+ },
261
+ {
262
+ "symbol": "ORCL",
263
+ "name": "Oracle",
264
+ "token": "0xb0992820E760d836549ba69BC7598b4af75dEE03",
265
+ "decimals": 18,
266
+ "feed": "0x0e6a64a2B58A6693a531E6c555f3A5d042eEA844",
267
+ "feedDecimals": 8,
268
+ "heartbeat": 86400,
269
+ "marketHours": "us_equities_24/5",
270
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xb0992820e760d836549ba69bc7598b4af75dee03.png",
271
+ "isin": "US68389X1054"
272
+ },
273
+ {
274
+ "symbol": "PLTR",
275
+ "name": "Palantir Technologies",
276
+ "token": "0x894E1EC2D74FFE5AEF8Dc8A9e84686acCB964F2A",
277
+ "decimals": 18,
278
+ "feed": "0x820ABedFF239034956B7A9d2F0a331f9F075eB4c",
279
+ "feedDecimals": 8,
280
+ "heartbeat": 86400,
281
+ "marketHours": "us_equities_24/5",
282
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x894e1ec2d74ffe5aef8dc8a9e84686accb964f2a.png",
283
+ "isin": "US69608A1088"
284
+ },
285
+ {
286
+ "symbol": "QQQ",
287
+ "name": "Invesco QQQ",
288
+ "token": "0xD5f3879160bc7c32ebb4dC785F8a4F505888de68",
289
+ "decimals": 18,
290
+ "feed": "0x80901d846d5D7B030F26B480776EE3b29374C2ae",
291
+ "feedDecimals": 8,
292
+ "heartbeat": 86400,
293
+ "marketHours": "us_equities_24/5",
294
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xd5f3879160bc7c32ebb4dc785f8a4f505888de68.png",
295
+ "isin": "US46090E1038"
296
+ },
297
+ {
298
+ "symbol": "RGTI",
299
+ "name": "Rigetti Computing",
300
+ "token": "0x284358abc07F9359f19f4b5b4aC91901Be2597Ba",
301
+ "decimals": 18,
302
+ "feed": "0x2A045cF1C49c61c166C036d2f06FA2D2d984f765",
303
+ "feedDecimals": 8,
304
+ "heartbeat": 86400,
305
+ "marketHours": "us_equities_24/5",
306
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x284358abc07f9359f19f4b5b4ac91901be2597ba.png",
307
+ "isin": "US76655K1034"
308
+ },
309
+ {
310
+ "symbol": "RKLB",
311
+ "name": "Rocket Lab Corporation",
312
+ "token": "0x3b14C39E89D60D627b42a1A4CA45b5bb45Fc12e2",
313
+ "decimals": 18,
314
+ "feed": "0x045477BF65Aef6f4F2386ad0164579e48381CC74",
315
+ "feedDecimals": 8,
316
+ "heartbeat": 86400,
317
+ "marketHours": "us_equities_24/5",
318
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x3b14c39e89d60d627b42a1a4ca45b5bb45fc12e2.png",
319
+ "isin": "US7731211089"
320
+ },
321
+ {
322
+ "symbol": "SGOV",
323
+ "name": "iShares 0-3 Month Treasury Bond",
324
+ "token": "0x92FD66527192E3e61d4DDd13322Aa222DE86F9B5",
325
+ "decimals": 18,
326
+ "feed": "0xa0DF4ee0fFf975306345875E3548Fcc519577A11",
327
+ "feedDecimals": 8,
328
+ "heartbeat": 86400,
329
+ "marketHours": "us_equities_24/5",
330
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x92fd66527192e3e61d4ddd13322aa222de86f9b5.png",
331
+ "isin": "US46436E7186"
332
+ },
333
+ {
334
+ "symbol": "SLV",
335
+ "name": "iShares Silver Trust",
336
+ "token": "0x411eFb0E7f985935DAec3D4C3ebaEa0d0AD7D89f",
337
+ "decimals": 18,
338
+ "feed": "0x209b73908e92Ae021826eD79609845451Ecba2ce",
339
+ "feedDecimals": 8,
340
+ "heartbeat": 86400,
341
+ "marketHours": "us_equities_24/5",
342
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x411efb0e7f985935daec3d4c3ebaea0d0ad7d89f.png",
343
+ "isin": "US46428Q1094"
344
+ },
345
+ {
346
+ "symbol": "SNDK",
347
+ "name": "Sandisk Corporation",
348
+ "token": "0xB90A19fF0Af67f7779afF50A882A9CfF42446400",
349
+ "decimals": 18,
350
+ "feed": "0xfb133Fa4B7b385802B693a293606682Df47109A3",
351
+ "feedDecimals": 8,
352
+ "heartbeat": 86400,
353
+ "marketHours": "us_equities_24/5",
354
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xb90a19ff0af67f7779aff50a882a9cff42446400.png",
355
+ "isin": "US80004C2008"
356
+ },
357
+ {
358
+ "symbol": "SPCX",
359
+ "name": "Space Exploration Technologies Corp. Class A Common Stock",
360
+ "token": "0x4a0E65A3EcceC6dBe60AE065F2e7bb85Fae35eEa",
361
+ "decimals": 18,
362
+ "feed": "0xB265810950ba6c5C0Ff821c9963014a56fD8Bffb",
363
+ "feedDecimals": 8,
364
+ "heartbeat": 86400,
365
+ "marketHours": "us_equities_24/5",
366
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x4a0e65a3eccec6dbe60ae065f2e7bb85fae35eea.png",
367
+ "isin": "US84615Q1031"
368
+ },
369
+ {
370
+ "symbol": "SPY",
371
+ "name": "SPDR S&P 500 ETF Trust",
372
+ "token": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
373
+ "decimals": 18,
374
+ "feed": "0x319724394D3A0e3669269846abE664Cd621f9f6A",
375
+ "feedDecimals": 8,
376
+ "heartbeat": 86400,
377
+ "marketHours": "us_equities_24/5",
378
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x117cc2133c37b721f49de2a7a74833232b3b4c0c.png",
379
+ "isin": "US78462F1030"
380
+ },
381
+ {
382
+ "symbol": "TSLA",
383
+ "name": "Tesla",
384
+ "token": "0x322F0929c4625eD5bAd873c95208D54E1c003b2d",
385
+ "decimals": 18,
386
+ "feed": "0x4A1166a659A55625345e9515b32adECea5547C38",
387
+ "feedDecimals": 8,
388
+ "heartbeat": 86400,
389
+ "marketHours": "us_equities_24/5",
390
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x322f0929c4625ed5bad873c95208d54e1c003b2d.png",
391
+ "isin": "US88160R1014"
392
+ },
393
+ {
394
+ "symbol": "TSM",
395
+ "name": "Taiwan Semiconductor Manufacturing",
396
+ "token": "0x58FfE4a942d3885bAa22D7520691F611EF09e7AA",
397
+ "decimals": 18,
398
+ "feed": "0x874cF94aa8eC88Fd9560094dD065f2fB3E41Fc2F",
399
+ "feedDecimals": 8,
400
+ "heartbeat": 86400,
401
+ "marketHours": "us_equities_24/5",
402
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0x58ffe4a942d3885baa22d7520691f611ef09e7aa.png",
403
+ "isin": "US8740391003"
404
+ },
405
+ {
406
+ "symbol": "USAR",
407
+ "name": "USA Rare Earth",
408
+ "token": "0xd917B029C761D264c6A312BBbcDA868658eF86a6",
409
+ "decimals": 18,
410
+ "feed": "0xA994d3684e8400A6c8078226925779FdeE682DD9",
411
+ "feedDecimals": 8,
412
+ "heartbeat": 86400,
413
+ "marketHours": "us_equities_24/5",
414
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xd917b029c761d264c6a312bbbcda868658ef86a6.png",
415
+ "isin": "US91733P1075"
416
+ },
417
+ {
418
+ "symbol": "USO",
419
+ "name": "United States Oil Fund",
420
+ "token": "0xa30FA36Db767ad9eD3f7a60fC79526fB4d56D344",
421
+ "decimals": 18,
422
+ "feed": "0x75a9c76Ef439e2C7c2E5a34Ab105EcFe3766431c",
423
+ "feedDecimals": 8,
424
+ "heartbeat": 86400,
425
+ "marketHours": "us_equities_24/5",
426
+ "logo": "https://cdn.robinhood.com/ncw_assets/logos/0xa30fa36db767ad9ed3f7a60fc79526fb4d56d344.png",
427
+ "isin": "US91232N2071"
428
+ }
429
+ ]
430
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@priors/mcp",
3
- "version": "0.1.8",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "description": "MCP server for Priors on Robinhood Chain: pay x402 URLs in USDG, read balances, credit lines and scores, borrow and repay. Key from PRIORS_KEY only.",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@modelcontextprotocol/sdk": "^1.30.1",
45
- "@priors/x402": "0.1.3",
45
+ "@priors/x402": "0.2.1",
46
46
  "ethers": "^6.13.4",
47
47
  "undici": "6.29.0",
48
48
  "zod": "^4.6.5"
package/src/server.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // @priors/mcp: an MCP server that lets an AI assistant pay x402 URLs in USDG on Robinhood Chain and run a Priors
2
- // credit line. Tools: pay_url, wallet_balance, credit_status, borrow, repay, score_of, find_services.
2
+ // credit line. Tools: pay_url, wallet_balance, credit_status, stock_assets, stock_position, borrow, repay, score_of,
3
+ // find_services.
3
4
  //
4
5
  // The private key comes from the environment (PRIORS_KEY) only. It is never read from argv, never logged, and never
5
6
  // part of any tool result or error: every text this server returns passes through `redact()`, which removes the key
@@ -16,6 +17,7 @@
16
17
  // PRIORS_MAX_BORROW_TOTAL_USD most borrowed in total per process (default 25)
17
18
  // PRIORS_ALLOW_LOCAL "1": pay_url may reach http://localhost and private addresses (testing only)
18
19
  // PRIORS_SCORE_V2 where score_of reads Priors Score v2 (default https://priors.trade/api/score-v2; "off": v1 only)
20
+ // PRIORS_STOCK_VAULT the stock vault's address (default: deployments/4663.v2.json `stockVault`, once deployed)
19
21
  import { readFileSync } from "node:fs";
20
22
  import { randomBytes } from "node:crypto";
21
23
  import { lookup as dnsLookup } from "node:dns/promises";
@@ -39,6 +41,8 @@ const { X, C } = await loadX402();
39
41
 
40
42
  export const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
41
43
  const ADDRESSES = JSON.parse(readFileSync(new URL("../deployments/4663.v2.json", import.meta.url), "utf8"));
44
+ /** The stock tokens the stock vault accepts (a copy of the repository's deployments/stock-assets.4663.json). */
45
+ const STOCK_ASSETS = JSON.parse(readFileSync(new URL("../deployments/stock-assets.4663.json", import.meta.url), "utf8")).assets;
42
46
  const DEFAULT_PAY_MAX_USD = 0.1;
43
47
 
44
48
  /** A private key (64 hex, optional 0x) anywhere in a string: refused on the command line. */
@@ -67,19 +71,30 @@ function v6Bytes(s) {
67
71
  if (groups.length !== 8) return null;
68
72
  return groups.flatMap((g) => { const v = parseInt(g || "0", 16); return [v >> 8, v & 255]; });
69
73
  }
70
- /** Loopback, private, link-local, CGNAT, unspecified, multicast and IPv4-mapped forms of those. */
74
+ /**
75
+ * Loopback, private, link-local, CGNAT, unspecified, multicast, reserved and documentation blocks, and the IPv6 forms
76
+ * that carry an IPv4 address (IPv4-mapped, NAT64, 6to4) judged by that address; Teredo and site-local are refused.
77
+ */
71
78
  export function isPrivateAddress(ip) {
72
79
  const kind = isIP(ip.replace(/^\[|\]$/g, "").split("%")[0]);
73
80
  if (kind === 4) {
74
- const [a, b] = ip.split(".").map(Number);
75
- return a === 0 || a === 10 || a === 127 || a >= 224 || (a === 100 && b >= 64 && b <= 127) || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 198 && (b === 18 || b === 19));
81
+ const [a, b, c] = ip.split(".").map(Number);
82
+ return a === 0 || a === 10 || a === 127 || a >= 224 || (a === 100 && b >= 64 && b <= 127) || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 198 && (b === 18 || b === 19))
83
+ || (a === 192 && b === 0 && (c === 0 || c === 2)) || (a === 198 && b === 51 && c === 100) || (a === 203 && b === 0 && c === 113); // 192.0.0.0/24, TEST-NETs
76
84
  }
77
85
  if (kind !== 6) return true; // not an address: refuse rather than guess
78
86
  const x = v6Bytes(ip);
79
87
  if (!x) return true;
80
- if (x.slice(0, 10).every((v) => v === 0) && x[10] === 255 && x[11] === 255) return isPrivateAddress(x.slice(12).join(".")); // ::ffff:a.b.c.d
88
+ const v4at = (i) => isPrivateAddress(x.slice(i, i + 4).join("."));
89
+ if (x.slice(0, 10).every((v) => v === 0) && x[10] === 255 && x[11] === 255) return v4at(12); // ::ffff:a.b.c.d
81
90
  if (x.slice(0, 12).every((v) => v === 0)) return true; // ::, ::1 and the deprecated IPv4-compatible forms
82
- return (x[0] & 0xfe) === 0xfc || (x[0] === 0xfe && (x[1] & 0xc0) === 0x80) || x[0] === 0xff; // fc00::/7, fe80::/10, ff00::/8
91
+ if (x[0] === 0 && x[1] === 0x64 && x[2] === 0xff && x[3] === 0x9b) { // NAT64
92
+ if (x[4] === 0 && x[5] === 1) return true; // 64:ff9b:1::/48, local-use: it can translate to anything
93
+ if (x.slice(4, 12).every((v) => v === 0)) return v4at(12); // 64:ff9b::/96, the well-known prefix
94
+ }
95
+ if (x[0] === 0x20 && x[1] === 0x02) return v4at(2); // 2002::/16, 6to4
96
+ if (x[0] === 0x20 && x[1] === 0x01 && x[2] === 0 && x[3] === 0) return true; // 2001::/32, Teredo
97
+ return (x[0] & 0xfe) === 0xfc || (x[0] === 0xfe && (x[1] & 0xc0) === 0x80) || (x[0] === 0xfe && (x[1] & 0xc0) === 0xc0) || x[0] === 0xff; // fc00::/7, fe80::/10, fec0::/10, ff00::/8
83
98
  }
84
99
 
85
100
  /**
@@ -105,6 +120,14 @@ export function guardedFetch(resolve = dnsLookupCb) {
105
120
 
106
121
  const usd = (units) => `${X.formatUsdg(units)} USDG`;
107
122
  const when = (t) => new Date(Number(t) * 1000).toISOString().replace(".000Z", "Z");
123
+ /** A token amount (bigint base units) with `decimals` places, trailing zeros trimmed. */
124
+ const tokens = (units, decimals) => (Number.isInteger(decimals) ? ethers.formatUnits(units, decimals).replace(/\.0$/, "") : String(units));
125
+ /** One line for the stock collateral behind a line (creditStatus.collateral, or a stockPosition). */
126
+ export function collateralText(c, symbol = c.symbol, decimals = c.decimals) {
127
+ const what = symbol ? `${tokens(c.amount, decimals)} ${symbol}` : `${c.amount} base units of ${c.token}`;
128
+ return `Backed by ${what}${c.value !== null ? ` worth ${usd(c.value)} to the vault` : " (not priced for new loans right now)"}, at ${Number(c.ltvBps) / 100}% loan-to-value: ${usd(c.borrowRoom)} can be drawn now.`
129
+ + (c.hold ? ` New loans wait: ${c.holdReason || "a lending hold"}.` : "") + (c.closing ? " Closing: no new loans." : "");
130
+ }
108
131
  const short = (s, n) => (s.length > n ? `${s.slice(0, n)}… (${s.length - n} more characters cut)` : s);
109
132
  const clean = (s, n) => short(String(s ?? "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, ""), n);
110
133
 
@@ -188,22 +211,43 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
188
211
  for (const n of ["PAYMENT-RESPONSE", "X-PAYMENT-RESPONSE"]) { const h = res.headers.get(n); if (h) { try { return JSON.parse(Buffer.from(h, "base64").toString("utf8")); } catch (_) { /* not ours to read */ } } }
189
212
  return undefined;
190
213
  };
191
- const addresses = { ...ADDRESSES, ...(deps.addresses || {}) };
214
+ const addresses = { ...ADDRESSES, ...(env.PRIORS_STOCK_VAULT ? { stockVault: env.PRIORS_STOCK_VAULT } : {}), ...(deps.addresses || {}) };
192
215
 
193
- // Everything returned passes through here: the key (with or without 0x, any case) and a private RPC URL are cut.
216
+ // Everything returned passes through here. The key is cut with or without 0x, in any case, and with separators between
217
+ // its digits (spaced, split over lines, dashed, JSON-quoted chunks). A private RPC URL is cut whole and by its parts
218
+ // (the host, long path segments, query values, credentials), in any case, each also when percent-encoded.
194
219
  const secrets = [];
195
- if (rawKey) { const h = rawKey.replace(/^0x/i, ""); if (h.length >= 16) secrets.push(new RegExp(`(0x)?${h.replace(/[^0-9a-zA-Z]/g, "")}`, "gi")); }
196
- if (env.PRIORS_RPC && env.PRIORS_RPC !== X.robinhood.rpcUrl) secrets.push(new RegExp(env.PRIORS_RPC.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"));
197
- const redact = (s) => secrets.reduce((acc, re) => acc.replace(re, (m) => (m.startsWith("http") ? "<rpc>" : "<redacted>")), String(s));
220
+ if (rawKey) {
221
+ const h = rawKey.replace(/^0x/i, "").replace(/[^0-9a-zA-Z]/g, "");
222
+ if (h.length >= 16) secrets.push(new RegExp(`(0x)?${[...h].join("[\\s\"'+,\\-]{0,3}")}`, "gi"));
223
+ }
224
+ if (env.PRIORS_RPC && env.PRIORS_RPC !== X.robinhood.rpcUrl) {
225
+ const parts = [env.PRIORS_RPC];
226
+ try {
227
+ const u = new URL(env.PRIORS_RPC);
228
+ parts.push(u.href, u.host, u.username, u.password);
229
+ for (const seg of u.pathname.split("/")) if (seg.length >= 8) parts.push(seg, decodeURIComponent(seg));
230
+ for (const v of u.searchParams.values()) if (v.length >= 8) parts.push(v);
231
+ } catch (_) { /* not a URL: the literal is still cut */ }
232
+ // each character that is not a letter or a digit may also appear percent-encoded
233
+ const pattern = (p) => [...p].map((ch) => (/[0-9a-z]/i.test(ch) ? ch : `(?:${ch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}|%${ch.charCodeAt(0).toString(16).padStart(2, "0")})`)).join("");
234
+ const uniq = [...new Set(parts.filter((p) => p && p.length >= 6))].sort((a, b) => b.length - a.length);
235
+ if (uniq.length) secrets.push(new RegExp(uniq.map(pattern).join("|"), "gi"));
236
+ }
237
+ const redact = (s) => secrets.reduce((acc, re) => acc.replace(re, (m) => (/^http/i.test(m) ? "<rpc>" : "<redacted>")), String(s));
198
238
 
199
- const provider = deps.provider || new ethers.JsonRpcProvider(rpc, ethers.Network.from(X.robinhood.chainId), { staticNetwork: true, cacheTimeout: -1 });
239
+ // One call per request: ethers batches parallel reads up to 100 calls, and the public node (the default PRIORS_RPC)
240
+ // answers a batch that size with HTTP 429, which ethers retries until its 5-minute timeout (stock_assets' ~140 reads).
241
+ const provider = deps.provider || new ethers.JsonRpcProvider(rpc, ethers.Network.from(X.robinhood.chainId), { staticNetwork: true, cacheTimeout: -1, batchMaxCount: 1 });
200
242
  const wallet = key ? new ethers.Wallet(key, provider) : null;
201
- const contracts = C.creditContracts({ runner: provider, addresses: { pool: addresses.pool, lens: addresses.lens, usdg: addresses.usdg, registry: addresses.registry } });
243
+ const contracts = C.creditContracts({ runner: provider, addresses: { pool: addresses.pool, lens: addresses.lens, usdg: addresses.usdg, registry: addresses.registry, stockVault: addresses.stockVault || null } });
202
244
 
203
245
  // The chain, behind one facade (tests replace it).
204
246
  const credit = deps.credit || {
205
247
  balances: (addr) => C.balances(contracts, provider, addr),
206
248
  status: (id) => C.creditStatus(contracts, id),
249
+ stockAssets: () => C.stockAssets(contracts, STOCK_ASSETS),
250
+ stockPosition: (id) => C.stockPosition(contracts, id, STOCK_ASSETS),
207
251
  quote: (id, amount, term) => C.quoteBorrow(contracts, id, amount, term),
208
252
  borrow: (id, amount, term) => C.borrowLine(contracts, wallet, id, amount, term),
209
253
  repay: (loanId) => C.repayLoan(contracts, wallet, loanId),
@@ -244,7 +288,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
244
288
 
245
289
  function needWallet(action) {
246
290
  if (keyProblem) throw new ToolError(`${action} needs a wallet, but ${keyProblem}. Fix PRIORS_KEY in the MCP server's environment.`);
247
- if (!wallet) throw new ToolError(`${action} moves money and needs a wallet: set 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 with an address, credit_status, score_of, find_services) work without it.`);
291
+ if (!wallet) throw new ToolError(`${action} moves money and needs a wallet: set 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 with an address, credit_status, stock_assets, stock_position, score_of, find_services) work without it.`);
248
292
  return wallet;
249
293
  }
250
294
  async function needController(id) {
@@ -294,7 +338,9 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
294
338
  let json = false; try { JSON.parse(body); json = true; } catch (_) { /* text */ }
295
339
  init.body = body; init.headers = { "content-type": json ? "application/json" : "text/plain; charset=utf-8" };
296
340
  }
297
- const purchase = `${method} ${u.href}`;
341
+ const target = new URL(u.href);
342
+ target.hash = ""; // a fragment never reaches the merchant: url#a and url#b are the same purchase
343
+ const purchase = `${method} ${target.href}`;
298
344
  const now = Math.floor(Date.now() / 1000);
299
345
  for (const [k, v] of outstanding) if (v.validBefore <= now) outstanding.delete(k);
300
346
  const lines = [];
@@ -312,7 +358,18 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
312
358
  if (maxBorrow > 0n) { agentId = await resolveAgent(); await needController(agentId); }
313
359
  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 } : {}) });
314
360
  try { r = await payer.pay(url, init); } catch (e) {
315
- if (e?.name === "TimeoutError" || e?.name === "AbortError") throw new ToolError(`${method} ${u.href} did not answer in time. Nothing was signed or paid.`);
361
+ // What the error carries was done: a loan taken and a payment signed are counted, whatever failed after.
362
+ if (e?.borrowed > 0n) session.borrowed += e.borrowed;
363
+ if (e?.signed) {
364
+ const price = BigInt(e.requirement.amount ?? e.requirement.maxAmountRequired);
365
+ session.spent += price;
366
+ outstanding.set(purchase, { ...e.signed, requirement: e.requirement, price });
367
+ const until = when(e.signed.validBefore);
368
+ throw new ToolError(`A payment of ${usd(price)} to ${e.requirement.payTo} was signed, then the request failed (${explain(e)}). The merchant may still settle it until ${until}, so do NOT call pay_url again for this URL before ${until}; check wallet_balance.${e.borrowed > 0n ? ` Borrowed ${usd(e.borrowed)}${e.loanId !== null ? ` as loan #${e.loanId}` : ""}: repay it with the repay tool.` : ""}`);
369
+ }
370
+ const loan = e?.borrowed > 0n ? ` ${usd(e.borrowed)} was borrowed${e.loanId !== null ? ` as loan #${e.loanId}` : ""} before it failed: repay it with the repay tool.` : "";
371
+ if (e?.name === "TimeoutError" || e?.name === "AbortError") throw new ToolError(`${method} ${u.href} did not answer in time. Nothing was signed or paid.${loan}`);
372
+ if (loan) throw new ToolError(`${explain(e)}.${loan}`);
316
373
  throw e;
317
374
  }
318
375
  if (r.signed) {
@@ -323,7 +380,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
323
380
  if (r.borrowed > 0n) { session.borrowed += r.borrowed; lines.push(`Borrowed ${usd(r.borrowed)} from the Priors line for agent #${agentId}${r.loanId !== null ? ` as loan #${r.loanId}` : ""}${r.dueAt ? `, due ${when(r.dueAt)}` : ""}. Repay it with the repay tool before then.`); }
324
381
  else if (r.requirement) lines.push("Nothing was borrowed.");
325
382
  }
326
- const status = r.timedOut ? "no answer in time" : `HTTP ${r.response.status}`;
383
+ const status = r.timedOut ? "no answer in time" : r.transportError ? "the connection was lost" : `HTTP ${r.response.status}`;
327
384
  if (!r.requirement) lines.unshift(`No payment was asked for: ${method} ${u.href} answered ${status}. Nothing was paid.`);
328
385
  else if (r.paid > 0n) {
329
386
  outstanding.delete(purchase);
@@ -369,6 +426,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
369
426
  `Agent #${id}${s.owner ? ` (owner ${s.owner})` : ""}${s.defaulted ? " — DEFAULTED" : ""}${s.frozen ? " — frozen" : ""}${s.isRoot ? " — a backer (root)" : ""}`,
370
427
  s.sponsor === 0n ? "Backed by: nobody yet, so no line." : `Backed by: root #${s.sponsor}${s.premiumBps > 0n ? `, premium ${Number(s.premiumBps) / 100}%` : ""}.`,
371
428
  `Line ${usd(s.line)}: drawn ${usd(s.drawn)}, available ${usd(s.available)}.`,
429
+ ...(s.collateral ? [collateralText(s.collateral)] : []),
372
430
  `Record: ${s.loansRepaid} loans repaid (${s.qualifiedRepaid} qualified), ${usd(s.volumeRepaid)} repaid in total, ${usd(s.feesPaid)} in fees.${s.score !== null ? ` Score ${s.score}/1000.` : ""}`,
373
431
  ];
374
432
  if (s.openLoans.length === 0) lines.push("Open loans: none.");
@@ -376,6 +434,33 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
376
434
  return lines.join("\n");
377
435
  });
378
436
 
437
+ // ---- stock_assets / stock_position -----------------------------------------------------------------------------
438
+ tool("stock_assets", {
439
+ title: "Stock tokens Priors lends against",
440
+ description: "List the Robinhood stock tokens the Priors stock vault accepts as collateral on Robinhood Chain: each token's live Chainlink price, whether the vault lends against it right now (and if not, why: a sharp price move, a multiplier change such as a split, a paused or blocked token), and its loan-to-value. Read-only.",
441
+ inputSchema: { symbol: z.string().max(12).optional().describe("One ticker, e.g. SPY. Omit for all.") },
442
+ annotations: { readOnlyHint: true, openWorldHint: true },
443
+ }, async ({ symbol }) => {
444
+ const want = symbol ? String(symbol).trim().toUpperCase() : null;
445
+ const all = await credit.stockAssets();
446
+ const list = all.filter((a) => !want || a.symbol.toUpperCase() === want);
447
+ if (want && list.length === 0) throw new ToolError(`${oneLine(symbol, 12)} is not among the ${all.length} stock tokens the vault accepts.`);
448
+ const rows = list.map((a) => `- ${a.symbol} (${a.name}): ${a.price === null ? "no price" : `$${a.price.toFixed(2)}`}${a.updatedAt ? ` as of ${when(a.updatedAt)}` : ""}; ${a.usable ? `lends at ${Number(a.ltvBps) / 100}% of value` : `no new loans (${a.holdReason || "price not usable now"})`}`);
449
+ return `The Priors stock vault accepts ${all.length} stock tokens; ${list.filter((a) => a.usable).length} of those shown take new lines now:\n${rows.join("\n")}`;
450
+ });
451
+
452
+ tool("stock_position", {
453
+ title: "Stock collateral behind an agent's line",
454
+ description: "Show the stock tokens behind a Priors agent's stock line on Robinhood Chain: the token and amount the vault holds, what the vault values them at, the loan-to-value, what the line can draw now, whether new loans wait on a lending hold, and whether the line is closing. agent_id defaults to the configured wallet's agent. Read-only.",
455
+ inputSchema: { agent_id: z.number().int().nonnegative().optional().describe("Priors (ERC-8004) agent id; default: the configured wallet's agent.") },
456
+ annotations: { readOnlyHint: true, openWorldHint: true },
457
+ }, async ({ agent_id }) => {
458
+ const id = await resolveAgent(agent_id);
459
+ const p = await credit.stockPosition(id);
460
+ if (!p) return `Agent #${id} has no stock position: its line (if any) is not backed by stock tokens.`;
461
+ return [`Agent #${id}: stock line of ${usd(p.line)}, ${p.status}.`, collateralText(p)].join("\n");
462
+ });
463
+
379
464
  // ---- score_of ------------------------------------------------------------------------------------------------
380
465
  // Priors Score v2 (open weights, published at /api/score-v2) next to the on-chain v1: optional. Not published
381
466
  // (404/503), slow or unreachable means v1 only, never a tool error; a defaulted agent never shows a positive v2.
@@ -498,7 +583,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
498
583
  if (hits.length === 0) return q ? `No registered service matches "${clean(q, 100)}" (${list.length} registered in all).` : "No services are registered with the facilitator yet.";
499
584
  const vol = (v) => (/^\d+$/.test(String(v ?? "")) ? usd(BigInt(v)) : clean(v ?? "0", 30));
500
585
  const httpsUrl = (v) => { try { const x = new URL(String(v)); return x.protocol === "https:" ? oneLine(x.href, 200) : "no https url"; } catch (_) { return "no url"; } };
501
- const rows = hits.slice(0, 25).map((m) => `- ${oneLine(m.name || "(unnamed)", 60)} — ${httpsUrl(m.url)}\n ${oneLine(m.description || "", 280)}\n pays to ${ethers.isAddress(String(m.payTo ?? "")) ? ethers.getAddress(m.payTo) : "?"}; ${Number.isFinite(Number(m.settled?.count)) ? Number(m.settled.count) : 0} payments settled, ${oneLine(vol(m.settled?.volume), 40)}`);
586
+ const rows = hits.slice(0, 25).map((m) => `- ${oneLine(m.name || "(unnamed)", 60)} — ${httpsUrl(m.url)}\n ${oneLine(m.description || "", 280)}\n pays to ${ethers.isAddress(String(m.payTo ?? "")) ? ethers.getAddress(m.payTo) : "?"}; ${Number.isFinite(Number(m.settled?.count)) ? Number(m.settled.count) : 0} payments settled, ${oneLine(vol(m.settled?.volume), 40)}; ${m.approved === true ? "approved by Priors" : "self-registered, not reviewed by Priors"}`);
502
587
  return `${hits.length} service${hits.length === 1 ? "" : "s"}${q ? ` matching "${oneLine(q, 100)}"` : ""}${hits.length > 25 ? " (first 25 shown)" : ""}. Names, links and descriptions are the merchants' own words:\n${fenced(rows.join("\n"), "merchant listings")}\nPay one with pay_url.`;
503
588
  });
504
589