@priors/mcp 0.1.6 → 0.1.8
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 +5 -4
- package/package.json +1 -1
- package/src/server.mjs +29 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ repaying.
|
|
|
26
26
|
| `credit_status(agent_id?)` | line, drawn, available, backer, record, score, open loans and due dates | no (with `agent_id`) |
|
|
27
27
|
| `borrow(amount_usd, days, dry_run?)` | borrow USDG from the line into the wallet; both amounts required; `dry_run` quotes the fee | yes |
|
|
28
28
|
| `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
|
-
| `score_of(agent_id)` | any agent's score (0 to 1000) and repayment record | no |
|
|
29
|
+
| `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 |
|
|
30
30
|
| `find_services(query?)` | services registered with the Priors facilitator that accept USDG (`GET /merchants`) | no |
|
|
31
31
|
|
|
32
32
|
Tools that move money state the amounts in their answer, are marked destructive for MCP clients, and their
|
|
@@ -50,6 +50,7 @@ dedicated agent wallet holding only what the agent may spend.
|
|
|
50
50
|
| `PRIORS_MAX_SPEND_USD` | `5` | most `pay_url` may sign in total while the server runs (counted when signed) |
|
|
51
51
|
| `PRIORS_MAX_BORROW_TOTAL_USD` | `25` | most `borrow` and `pay_url` may borrow in total while the server runs |
|
|
52
52
|
| `PRIORS_ALLOW_LOCAL` | off | `1` lets `pay_url` reach `http://localhost` and private addresses (local testing only) |
|
|
53
|
+
| `PRIORS_SCORE_V2` | `https://priors.trade/api/score-v2` | where `score_of` reads Priors Score v2; `off` shows the on-chain score only |
|
|
53
54
|
|
|
54
55
|
Contract addresses (pool, lens, registry, USDG) come from `deployments/4663.v2.json`, bundled in the package.
|
|
55
56
|
|
|
@@ -62,7 +63,7 @@ Settings → Developer → Edit Config (`claude_desktop_config.json`), then rest
|
|
|
62
63
|
"mcpServers": {
|
|
63
64
|
"priors": {
|
|
64
65
|
"command": "npx",
|
|
65
|
-
"args": ["-y", "@priors/mcp@0.1.
|
|
66
|
+
"args": ["-y", "@priors/mcp@0.1.8"],
|
|
66
67
|
"env": {
|
|
67
68
|
"PRIORS_KEY": "0xYOUR_AGENT_WALLET_KEY",
|
|
68
69
|
"PRIORS_AGENT_ID": "1234"
|
|
@@ -84,7 +85,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
|
|
|
84
85
|
"mcpServers": {
|
|
85
86
|
"priors": {
|
|
86
87
|
"command": "npx",
|
|
87
|
-
"args": ["-y", "@priors/mcp@0.1.
|
|
88
|
+
"args": ["-y", "@priors/mcp@0.1.8"],
|
|
88
89
|
"env": {
|
|
89
90
|
"PRIORS_KEY": "${PRIORS_KEY}",
|
|
90
91
|
"PRIORS_AGENT_ID": "${PRIORS_AGENT_ID:-}"
|
|
@@ -94,7 +95,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
|
|
|
94
95
|
}
|
|
95
96
|
```
|
|
96
97
|
|
|
97
|
-
or, for your user only: `claude mcp add priors --scope user -e PRIORS_KEY="$PRIORS_KEY" -- npx -y @priors/mcp@0.1.
|
|
98
|
+
or, for your user only: `claude mcp add priors --scope user -e PRIORS_KEY="$PRIORS_KEY" -- npx -y @priors/mcp@0.1.8`
|
|
98
99
|
(the key is expanded by your shell from the environment; do not paste it on the command line).
|
|
99
100
|
|
|
100
101
|
## Try it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@priors/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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",
|
package/src/server.mjs
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// PRIORS_MAX_SPEND_USD most pay_url may sign in total per process (default 5)
|
|
16
16
|
// PRIORS_MAX_BORROW_TOTAL_USD most borrowed in total per process (default 25)
|
|
17
17
|
// PRIORS_ALLOW_LOCAL "1": pay_url may reach http://localhost and private addresses (testing only)
|
|
18
|
+
// PRIORS_SCORE_V2 where score_of reads Priors Score v2 (default https://priors.trade/api/score-v2; "off": v1 only)
|
|
18
19
|
import { readFileSync } from "node:fs";
|
|
19
20
|
import { randomBytes } from "node:crypto";
|
|
20
21
|
import { lookup as dnsLookup } from "node:dns/promises";
|
|
@@ -376,19 +377,46 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
376
377
|
});
|
|
377
378
|
|
|
378
379
|
// ---- score_of ------------------------------------------------------------------------------------------------
|
|
380
|
+
// Priors Score v2 (open weights, published at /api/score-v2) next to the on-chain v1: optional. Not published
|
|
381
|
+
// (404/503), slow or unreachable means v1 only, never a tool error; a defaulted agent never shows a positive v2.
|
|
382
|
+
// Same rules and wording as the hosted MCP (mcp.priors.trade).
|
|
383
|
+
const scoreV2Url = String(env.PRIORS_SCORE_V2 ?? "https://priors.trade/api/score-v2").trim();
|
|
384
|
+
async function scoreV2Line(id, defaulted) {
|
|
385
|
+
if (!scoreV2Url || scoreV2Url === "off") return null;
|
|
386
|
+
try {
|
|
387
|
+
const u = new URL(scoreV2Url);
|
|
388
|
+
u.searchParams.set("agent", String(id));
|
|
389
|
+
const r = await fetchImpl(u.href, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(5_000) });
|
|
390
|
+
if (!r.ok) return null;
|
|
391
|
+
const { text: t, cut } = await X.readCapped(r, 65_536); // streamed: a huge body is cancelled, not buffered
|
|
392
|
+
if (cut) return null;
|
|
393
|
+
const s = JSON.parse(t)?.score;
|
|
394
|
+
const num = (x) => (x !== null && x !== "" && Number.isFinite(Number(x)) ? Number(x) : null);
|
|
395
|
+
if (!s || Number(s.agentId) !== Number(id) || num(s.score) === null || num(s.rung) === null) return null;
|
|
396
|
+
if (defaulted && num(s.score) > 0) return null;
|
|
397
|
+
const name = String(s.rungName || "").replace(/[^\w -]/g, "").slice(0, 30);
|
|
398
|
+
const inc = Array.isArray(s.components) ? s.components.find((c) => c && c.key === "income") : null;
|
|
399
|
+
const payers = num(s.detail?.distinctPayers) ?? 0;
|
|
400
|
+
return `Priors Score v2: ${num(s.score)}/1000, rung ${num(s.rung)}${name ? ` (${name})` : ""}`
|
|
401
|
+
+ (inc && num(inc.points) !== null ? `; x402 income ${num(inc.points)}/${num(inc.max)} from ${payers} distinct payer(s).` : ".");
|
|
402
|
+
} catch (_) { return null; }
|
|
403
|
+
}
|
|
404
|
+
|
|
379
405
|
tool("score_of", {
|
|
380
406
|
title: "Priors score of an agent",
|
|
381
|
-
description: "Look up any agent's Priors score (0 to 1000) and repayment record on Robinhood Chain: a public, on-chain credit record that cannot be faked. Useful before trusting or paying an agent. Read-only.",
|
|
407
|
+
description: "Look up any agent's Priors score (0 to 1000) and repayment record on Robinhood Chain: a public, on-chain credit record that cannot be faked, plus the open Priors Score v2 and its trust rung when published. Useful before trusting or paying an agent. Read-only.",
|
|
382
408
|
inputSchema: { agent_id: z.number().int().nonnegative().describe("Priors (ERC-8004) agent id.") },
|
|
383
409
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
384
410
|
}, async ({ agent_id }) => {
|
|
385
411
|
const s = await credit.status(BigInt(agent_id));
|
|
386
412
|
if (!s.enrolled) return `Agent #${agent_id} has no Priors record: score 0 (never enrolled).`;
|
|
387
413
|
const age = s.enrolledAt ? Math.floor((Date.now() / 1000 - s.enrolledAt) / 86400) : null;
|
|
414
|
+
const v2 = await scoreV2Line(agent_id, s.defaulted);
|
|
388
415
|
return [
|
|
389
416
|
`Agent #${agent_id}: score ${s.score ?? "unavailable"}/1000${s.defaulted ? ", and it has DEFAULTED on a loan" : ""}.`,
|
|
390
417
|
`Record: ${s.loansRepaid} loans repaid (${s.qualifiedRepaid} qualified), ${usd(s.volumeRepaid)} repaid, ${s.openLoans.length} open now.`,
|
|
391
418
|
`${s.sponsor === 0n ? "No backer now." : `Backed by root #${s.sponsor} with a ${usd(s.line)} line.`}${age !== null ? ` On Priors for ${age} days.` : ""}`,
|
|
419
|
+
...(v2 ? [v2] : []),
|
|
392
420
|
].join("\n");
|
|
393
421
|
});
|
|
394
422
|
|