tereno-mcp 0.1.3 → 0.1.5
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 +48 -34
- package/bin/tereno-mcp.mjs +61 -9
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -31,19 +31,22 @@ npx -y tereno-mcp
|
|
|
31
31
|
|
|
32
32
|
## ⚡ Why this exists
|
|
33
33
|
|
|
34
|
-
An agent that
|
|
35
|
-
on information it cannot verify. Most tools answer *what*
|
|
36
|
-
them tell you how long that answer stays true.
|
|
34
|
+
An agent that interacts with a Base token or contract, or trades a prediction-market
|
|
35
|
+
proposition, is acting on information it cannot verify. Most tools answer *what*
|
|
36
|
+
something is. None of them tell you how long that answer stays true.
|
|
37
37
|
|
|
38
38
|
`tereno-mcp` puts [Tereno](https://www.tereno.xyz) inside any MCP client. Every
|
|
39
39
|
paid answer comes back with the evidence behind it, the limits of that evidence,
|
|
40
|
-
and **the block it stops being valid at**.
|
|
40
|
+
and **the block or timestamp it stops being valid at**.
|
|
41
41
|
|
|
42
42
|
- **No API key, no signup.** The agent's wallet *is* the identity.
|
|
43
|
-
- **Price before payment.** `tereno_price` tells you the cost
|
|
44
|
-
answer already exists,
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
- **Price & seeder dividend before payment.** `tereno_price` tells you the cost,
|
|
44
|
+
whether the answer already exists, and how much your wallet earns in reuse
|
|
45
|
+
dividends if you seed it — without a wallet and without committing to anything.
|
|
46
|
+
- **Positive-sum when shared.** Deterministic answers are reused across agents:
|
|
47
|
+
the first caller (or free publisher via `tereno_publish`) claims the **seeder**
|
|
48
|
+
slot, everyone after pays the lower reuse price, and the seeder earns a **20%
|
|
49
|
+
reuse dividend** in non-transferable credits on every cross-wallet reuse.
|
|
47
50
|
|
|
48
51
|
## 🚀 Install
|
|
49
52
|
|
|
@@ -66,39 +69,46 @@ Restart the client. Nothing else to configure — the free tools work immediatel
|
|
|
66
69
|
|
|
67
70
|
| Tool | The question it answers |
|
|
68
71
|
|---|---|
|
|
69
|
-
| 📖 `tereno_catalog` | What can Tereno answer, what does it cost, how long does each answer stay valid? |
|
|
70
|
-
| 🏷️ `tereno_price` | What would *this exact call* cost right now —
|
|
72
|
+
| 📖 `tereno_catalog` | What can Tereno answer, what does it cost, how long does each answer stay valid, and where is the open bounty queue? |
|
|
73
|
+
| 🏷️ `tereno_price` | What would *this exact call* cost right now — does the answer already exist, and what is the seeder dividend? |
|
|
71
74
|
| 🧾 `tereno_receipt` | What did a settled call actually charge: tier, list price, credit applied, price paid? |
|
|
75
|
+
| 🔗 `tereno_evidence_reference` | Resolve a portable `sha256:` evidence reference received from another agent. |
|
|
76
|
+
| 🌱 `tereno_publish` | Publish a contract bytecode fingerprint you computed yourself (audited by recomputation) to claim its seeder slot and earn reuse dividends + optional ERC-8004 on-chain attestation. |
|
|
77
|
+
| 🤝 `demand_pledge` | Name a capability you would pay for. Credit is released only after the same wallet settles it later. |
|
|
72
78
|
|
|
73
|
-
`tereno_price`
|
|
79
|
+
`tereno_price` names both the reuse tier and the `seederEconomics` out loud:
|
|
74
80
|
|
|
75
81
|
```
|
|
76
|
-
hit another agent already paid to compute this and it is still fresh
|
|
77
|
-
partial the durable half survived; only the expired part is recomputed
|
|
78
|
-
miss nothing to reuse — this call
|
|
82
|
+
hit another agent already paid to compute this and it is still fresh ($0.01)
|
|
83
|
+
partial the durable half survived; only the expired part is recomputed ($0.02)
|
|
84
|
+
miss nothing to reuse — settling this call makes your wallet the seeder, and every later cross-wallet reuse returns a 20% credit dividend to you
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
## 💳 Paid per call
|
|
87
|
+
## 💳 Paid per call (x402 in USDC on Base)
|
|
82
88
|
|
|
83
|
-
| Tool | Price | The question it answers |
|
|
89
|
+
| Tool | Price (hit → miss) | The question it answers |
|
|
84
90
|
|---|---:|---|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
| 🧬 `contract_interface` | $0.001–2 | ERC-20? NFT? Proxy? One bounded probe |
|
|
90
|
-
| ⛽ `chain_snapshot` | $0.001–2 | Latest Base block, base fee and suggested gas, zero parameters |
|
|
91
|
-
| 📄 `web_compile` | $0.001–5 | Public URL → bounded Markdown with resolved links, citations and a reusable artifact |
|
|
92
|
-
| 🔎 `evidence_artifact` | $0.001–3 | Can this public artifact be reused? Provenance, field validity, recomputation input |
|
|
93
|
-
| 🤝 `demand_pledge` | free | Name a capability you would pay for. Credit only after the same wallet pays for it later |
|
|
91
|
+
| 🪙 `token_metadata` | $0.01 – $0.03 | What Base ERC-20 token is this? (`name`, `symbol`, `decimals` shared for 7d + fresh `totalSupply` at current block) |
|
|
92
|
+
| ⛽ `chain_snapshot` | $0.01 – $0.02 | What is the current state of Base? Latest block number, timestamp, base fee and suggested gas fees, zero parameters |
|
|
93
|
+
| 🛡️ `contract_guard` | $0.01 – $0.03 | Is this Base contract safe to interact with? (executable code, EIP-1967 proxy & pause signals, bounded verdict) |
|
|
94
|
+
| 📊 `prediction_evidence` | $0.01 – $0.05 | Sourced, machine-readable evidence supporting or contradicting a prediction-market proposition, with provenance |
|
|
94
95
|
|
|
95
96
|
Calling a paid tool returns a `402` carrying the payment challenge in
|
|
96
|
-
`error.data.paymentRequired
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
`error.data.paymentRequired`, the payable resource URL in `error.data.resource`,
|
|
98
|
+
and the terms (network, asset, amount, `payTo`) in `error.data.offer`.
|
|
99
|
+
|
|
100
|
+
**Over stdio you cannot pay by retrying the tool call.** stdio has no headers in
|
|
101
|
+
either direction, so there is nowhere for a `PAYMENT-SIGNATURE` to travel back
|
|
102
|
+
through. Two ways to settle, both of which leave **this package never touching a
|
|
103
|
+
private key**:
|
|
104
|
+
|
|
105
|
+
- **Pay the resource over HTTP.** Sign `error.data.paymentRequired` with your
|
|
106
|
+
x402 client and send the signed request to `error.data.resource`. It returns
|
|
107
|
+
the same payload the tool would have, receipt included, billed once.
|
|
108
|
+
- **Use the remote server instead of this package.** If your client supports
|
|
109
|
+
remote MCP, point it at `https://www.tereno.xyz/api/mcp`. That transport does
|
|
110
|
+
have headers, so signing the challenge and retrying the same tool call is the
|
|
111
|
+
normal flow and everything stays inside MCP.
|
|
102
112
|
|
|
103
113
|
## ⚙️ Configuration
|
|
104
114
|
|
|
@@ -116,9 +126,13 @@ It is a **stdio transport** in front of the hosted endpoint at
|
|
|
116
126
|
the tool list, the prices and the payment challenge all come from the same place
|
|
117
127
|
an HTTP agent sees — and this package needs no release when a capability changes.
|
|
118
128
|
|
|
119
|
-
The one thing it translates is payment
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
The one thing it translates is payment, and the translation is lossy in one
|
|
130
|
+
direction. Over HTTP the challenge arrives in a response header and the caller
|
|
131
|
+
retries with a `PAYMENT-SIGNATURE` header. stdio has neither, so the challenge is
|
|
132
|
+
folded into the JSON-RPC error payload where a client can still reach it, while
|
|
133
|
+
the signature has no way back in. That is why a paid call is settled against the
|
|
134
|
+
resource URL rather than by retrying the tool, and why a client that speaks
|
|
135
|
+
remote MCP should prefer the hosted endpoint.
|
|
122
136
|
|
|
123
137
|
**No private key is ever read, stored or transmitted.** There are no
|
|
124
138
|
dependencies, and the whole thing is one readable file — [read it](./bin/tereno-mcp.mjs)
|
package/bin/tereno-mcp.mjs
CHANGED
|
@@ -7,15 +7,24 @@
|
|
|
7
7
|
// the payment challenge all come from the same place an HTTP agent sees, and
|
|
8
8
|
// this package never has to be redeployed when a capability changes.
|
|
9
9
|
//
|
|
10
|
-
// The one thing it does translate is payment
|
|
11
|
-
//
|
|
12
|
-
//
|
|
10
|
+
// The one thing it does translate is payment, and the translation is lossy in a
|
|
11
|
+
// way worth naming. Over HTTP the 402 challenge arrives in a response header and
|
|
12
|
+
// the caller retries with a PAYMENT-SIGNATURE header. stdio has no headers in
|
|
13
|
+
// either direction: the challenge can still be folded into the JSON-RPC error
|
|
14
|
+
// payload, but the signature has nowhere to come back through. So a paid tool
|
|
15
|
+
// cannot be settled by retrying it here, and saying otherwise sends an agent
|
|
16
|
+
// round a loop with no exit.
|
|
17
|
+
//
|
|
18
|
+
// What it does instead is hand the call off: the challenge names the capability's
|
|
19
|
+
// own invoke URL, which is payable by any x402 HTTP client and returns the same
|
|
20
|
+
// payload this tool would have. The 402 below says that explicitly and points at
|
|
21
|
+
// that URL rather than at this endpoint.
|
|
13
22
|
|
|
14
23
|
import { createInterface } from "node:readline";
|
|
15
24
|
|
|
16
25
|
// Travels in the user-agent, and the demand panel counts installs by it, so it
|
|
17
26
|
// has to track the published version rather than drift from it.
|
|
18
|
-
const VERSION = "0.1.
|
|
27
|
+
const VERSION = "0.1.5";
|
|
19
28
|
const BASE_URL = (process.env.TERENO_BASE_URL || "https://www.tereno.xyz").replace(/\/+$/, "");
|
|
20
29
|
const ENDPOINT = BASE_URL + "/api/mcp";
|
|
21
30
|
const WALLET = process.env.TERENO_WALLET?.trim();
|
|
@@ -33,6 +42,33 @@ function errorFor(id, code, message, data) {
|
|
|
33
42
|
return { jsonrpc: "2.0", id: id ?? null, error: data === undefined ? { code, message } : { code, message, data } };
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
// Reads the offer out of the base64 x402 challenge. This is not reimplementing
|
|
46
|
+
// payment: it is the only way to tell the agent *where* to pay, because the
|
|
47
|
+
// payable resource is the capability's invoke URL and never this JSON-RPC
|
|
48
|
+
// endpoint. Everything is optional on purpose, so a challenge whose shape we do
|
|
49
|
+
// not recognise degrades to "the challenge carries it" instead of throwing.
|
|
50
|
+
function readOffer(challenge) {
|
|
51
|
+
if (!challenge) return null;
|
|
52
|
+
try {
|
|
53
|
+
const decoded = JSON.parse(Buffer.from(challenge, "base64").toString("utf8"));
|
|
54
|
+
const accepts = Array.isArray(decoded?.accepts) ? decoded.accepts[0] : null;
|
|
55
|
+
const url = typeof decoded?.resource?.url === "string" ? decoded.resource.url : null;
|
|
56
|
+
if (!url && !accepts) return null;
|
|
57
|
+
return {
|
|
58
|
+
url,
|
|
59
|
+
network: accepts?.network ?? null,
|
|
60
|
+
asset: accepts?.asset ?? null,
|
|
61
|
+
// Smallest unit of `asset`, not USD. Naming it loosely is how an agent
|
|
62
|
+
// ends up signing six orders of magnitude more than it meant to.
|
|
63
|
+
amountInAssetUnits: accepts?.amount ?? null,
|
|
64
|
+
payTo: accepts?.payTo ?? null,
|
|
65
|
+
maxTimeoutSeconds: accepts?.maxTimeoutSeconds ?? null,
|
|
66
|
+
};
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
36
72
|
async function forward(request) {
|
|
37
73
|
const controller = new AbortController();
|
|
38
74
|
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
@@ -56,12 +92,28 @@ async function forward(request) {
|
|
|
56
92
|
|
|
57
93
|
if (response.status === 402) {
|
|
58
94
|
const challenge = response.headers.get(PAYMENT_REQUIRED_HEADER);
|
|
95
|
+
const offer = readOffer(challenge);
|
|
96
|
+
const where = offer?.url
|
|
97
|
+
? `send the signed request to data.resource (${offer.url})`
|
|
98
|
+
: "send the signed request to the resource URL named inside that challenge";
|
|
59
99
|
return errorFor(request.id, 402,
|
|
60
|
-
"Payment required
|
|
61
|
-
+ "
|
|
62
|
-
+ "
|
|
63
|
-
+
|
|
64
|
-
|
|
100
|
+
"Payment required, and this transport cannot carry the payment. stdio has no "
|
|
101
|
+
+ "headers, so retrying this tool call with a PAYMENT-SIGNATURE is not possible "
|
|
102
|
+
+ "and no argument on this tool accepts one. Settle it over HTTP instead: sign "
|
|
103
|
+
+ `data.paymentRequired with an x402 client and ${where}. That returns the same `
|
|
104
|
+
+ "payload this tool would have returned, including the receipt, and it is billed "
|
|
105
|
+
+ "once. Free here, needing no wallet and no payment: tereno_catalog, tereno_price, "
|
|
106
|
+
+ "tereno_receipt, tereno_evidence_reference, tereno_publish and demand_pledge. Call tereno_price "
|
|
107
|
+
+ "first if you only wanted to know the cost and seeder dividend economics.",
|
|
108
|
+
{
|
|
109
|
+
paymentRequired: challenge,
|
|
110
|
+
// The payable resource, which is the capability's invoke URL. This
|
|
111
|
+
// used to carry the MCP endpoint, which is not payable and is not
|
|
112
|
+
// what an x402 client should be pointed at.
|
|
113
|
+
resource: offer?.url ?? null,
|
|
114
|
+
offer,
|
|
115
|
+
mcpEndpoint: ENDPOINT,
|
|
116
|
+
});
|
|
65
117
|
}
|
|
66
118
|
|
|
67
119
|
const text = await response.text();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tereno-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"mcpName": "xyz.tereno/tereno",
|
|
5
|
-
"description": "MCP server for Tereno on Base:
|
|
5
|
+
"description": "MCP server for Tereno on Base: inspect token metadata, current chain state, contract risk and sourced prediction-market evidence. Free catalog, pricing, receipt and publish tools; paid answers settle per call with x402 in USDC and earn seeder reuse dividends.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"tereno-mcp": "bin/tereno-mcp.mjs"
|
|
@@ -26,9 +26,12 @@
|
|
|
26
26
|
"ai-agent",
|
|
27
27
|
"smart-contract",
|
|
28
28
|
"contract-security",
|
|
29
|
+
"token-metadata",
|
|
30
|
+
"prediction-market",
|
|
31
|
+
"polymarket",
|
|
29
32
|
"onchain",
|
|
30
33
|
"usdc",
|
|
31
|
-
"
|
|
34
|
+
"erc8004"
|
|
32
35
|
],
|
|
33
36
|
"homepage": "https://www.tereno.xyz",
|
|
34
37
|
"repository": {
|