@gblin-protocol/mcp-server 0.4.2 → 0.5.0

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.
Files changed (63) hide show
  1. package/AGENTS.md +49 -20
  2. package/README.md +110 -11
  3. package/dist/abi.d.ts +27 -0
  4. package/dist/abi.d.ts.map +1 -1
  5. package/dist/abi.js +1 -0
  6. package/dist/abi.js.map +1 -1
  7. package/dist/actions.d.ts +306 -0
  8. package/dist/actions.d.ts.map +1 -0
  9. package/dist/actions.js +740 -0
  10. package/dist/actions.js.map +1 -0
  11. package/dist/auction.d.ts.map +1 -1
  12. package/dist/auction.js +5 -4
  13. package/dist/auction.js.map +1 -1
  14. package/dist/config.d.ts +20 -3
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js +23 -6
  17. package/dist/config.js.map +1 -1
  18. package/dist/helpers.d.ts +6 -0
  19. package/dist/helpers.d.ts.map +1 -1
  20. package/dist/helpers.js +37 -13
  21. package/dist/helpers.js.map +1 -1
  22. package/dist/index.d.ts +3 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +53 -20
  25. package/dist/index.js.map +1 -1
  26. package/dist/output-schemas.d.ts +18 -0
  27. package/dist/output-schemas.d.ts.map +1 -0
  28. package/dist/output-schemas.js +243 -0
  29. package/dist/output-schemas.js.map +1 -0
  30. package/dist/payments.d.ts +170 -0
  31. package/dist/payments.d.ts.map +1 -0
  32. package/dist/payments.js +524 -0
  33. package/dist/payments.js.map +1 -0
  34. package/dist/paywall.d.ts +10 -1
  35. package/dist/paywall.d.ts.map +1 -1
  36. package/dist/paywall.js +1 -1
  37. package/dist/paywall.js.map +1 -1
  38. package/dist/prompts.d.ts +33 -0
  39. package/dist/prompts.d.ts.map +1 -0
  40. package/dist/prompts.js +139 -0
  41. package/dist/prompts.js.map +1 -0
  42. package/dist/receipts.d.ts +2 -1
  43. package/dist/receipts.d.ts.map +1 -1
  44. package/dist/receipts.js +16 -12
  45. package/dist/receipts.js.map +1 -1
  46. package/dist/resources.d.ts +17 -0
  47. package/dist/resources.d.ts.map +1 -0
  48. package/dist/resources.js +146 -0
  49. package/dist/resources.js.map +1 -0
  50. package/dist/shared.d.ts +35 -0
  51. package/dist/shared.d.ts.map +1 -0
  52. package/dist/shared.js +68 -0
  53. package/dist/shared.js.map +1 -0
  54. package/dist/tools.d.ts +106 -19
  55. package/dist/tools.d.ts.map +1 -1
  56. package/dist/tools.js +124 -117
  57. package/dist/tools.js.map +1 -1
  58. package/dist/version.d.ts +2 -0
  59. package/dist/version.d.ts.map +1 -0
  60. package/dist/version.js +3 -0
  61. package/dist/version.js.map +1 -0
  62. package/llms.txt +24 -2
  63. package/package.json +8 -3
@@ -0,0 +1,139 @@
1
+ /**
2
+ * GBLIN MCP — prompts.
3
+ *
4
+ * Ready-made workflows built only from this server's own tools. Each one states its rule before the
5
+ * steps, so the decision an agent reaches can be audited afterwards against the rule it was given.
6
+ */
7
+ export const PROMPT_DEFINITIONS = [
8
+ {
9
+ name: "risk_gate",
10
+ title: "Risk gate before deploying capital",
11
+ description: "Read the live on-chain risk regime and decide whether to deploy capital, reduce, or stand down, with the rule stated up front so the decision is auditable.",
12
+ arguments: [
13
+ { name: "action", description: "What you are about to do, e.g. 'buy 500 USDC of ETH'.", required: true },
14
+ { name: "risk_budget", description: "How much you are willing to lose on this action.", required: false },
15
+ ],
16
+ },
17
+ {
18
+ name: "pay_in_gblin",
19
+ title: "Pay in GBLIN with a signature and no ETH",
20
+ description: "Prepare a gasless GBLIN payment, sign it with your own wallet, verify it against the chain, and only then hand it on. The private key never leaves the wallet.",
21
+ arguments: [
22
+ { name: "from", description: "Your address: the wallet that will sign.", required: true },
23
+ { name: "to", description: "The recipient's address.", required: true },
24
+ { name: "amount_gblin", description: "Amount in GBLIN shares. Give this or amount_usd.", required: false },
25
+ { name: "amount_usd", description: "Amount in USD, converted at the live NAV. Give this or amount_gblin.", required: false },
26
+ ],
27
+ },
28
+ {
29
+ name: "pay_invoice_just_in_time",
30
+ title: "Pay a USDC invoice from a GBLIN treasury",
31
+ description: "When an invoice in USDC arrives and the treasury sits in GBLIN, exit just enough to pay it, checking the cooldown and the gas first.",
32
+ arguments: [
33
+ { name: "usdc_needed", description: "The amount of the invoice in USDC.", required: true },
34
+ { name: "wallet_address", description: "The treasury wallet.", required: true },
35
+ ],
36
+ },
37
+ {
38
+ name: "seal_and_verify",
39
+ title: "Seal an AI action and verify the receipt",
40
+ description: "Seal the hashes of an action into the public transparency log, fetch the receipt back, and state plainly what the receipt does and does not prove.",
41
+ arguments: [
42
+ { name: "action", description: "A short public label for what the AI did.", required: true },
43
+ { name: "input_hash", description: "sha256 hex (64 characters) of the input.", required: true },
44
+ { name: "output_hash", description: "sha256 hex of the output.", required: false },
45
+ ],
46
+ },
47
+ ];
48
+ function arg(args, key, fallback = "") {
49
+ const value = args[key];
50
+ return typeof value === "string" && value.trim() ? value.trim() : fallback;
51
+ }
52
+ function message(text) {
53
+ return { messages: [{ role: "user", content: { type: "text", text } }] };
54
+ }
55
+ export function getPrompt(name, args = {}) {
56
+ switch (name) {
57
+ case "risk_gate": {
58
+ const budget = arg(args, "risk_budget");
59
+ return {
60
+ description: "Risk gate: regime first, decision second.",
61
+ ...message(`Before doing this, run the risk gate.
62
+
63
+ Intended action: ${arg(args, "action", "(unspecified)")}${budget ? `\nRisk budget: ${budget}` : ""}
64
+
65
+ Rule, decided before looking:
66
+ - regime "calm": proceed as planned.
67
+ - regime "elevated": proceed at half size or wait.
68
+ - regime "crash": stand down and keep the capital defensive.
69
+
70
+ Steps:
71
+ 1. Call get_market_risk_regime.
72
+ 2. State the regime and the severity it reports.
73
+ 3. Apply the rule above and say which branch you took.
74
+ 4. If the regime could not be read, say so and do not proceed: an unread regime is not a calm one.`),
75
+ };
76
+ }
77
+ case "pay_in_gblin": {
78
+ const amount = arg(args, "amount_gblin") ? `amount_gblin: ${arg(args, "amount_gblin")}` : `amount_usd: ${arg(args, "amount_usd", "(unspecified)")}`;
79
+ return {
80
+ description: "Gasless GBLIN payment: prepare, sign, verify, then carry.",
81
+ ...message(`Pay in GBLIN with a signature. The payer needs no ETH.
82
+
83
+ From: ${arg(args, "from", "(your address)")}
84
+ To: ${arg(args, "to", "(recipient)")}
85
+ ${amount}
86
+
87
+ Rules:
88
+ - The private key stays in the wallet. Never paste it into a tool.
89
+ - Do not submit anything the verifier says would not settle.
90
+
91
+ Steps:
92
+ 1. Call prepare_gblin_payment with these values. Use method "receive" when paying a known recipient.
93
+ 2. Sign the returned typed_data with the payer's wallet (eth_signTypedData_v4).
94
+ 3. Call verify_gblin_authorization with the authorization and the signature.
95
+ 4. If would_settle is true, hand the calldata to the recipient (method "receive") or the x402 payload to a facilitator (method "transfer"). If it is false, report the failures and stop.
96
+ 5. If nobody will carry it on chain, prepare again with relay: true, sign both messages, and call relay_gblin_payment. The relay fee is paid in GBLIN, and the payment and the fee settle together or not at all.`),
97
+ };
98
+ }
99
+ case "pay_invoice_just_in_time": {
100
+ return {
101
+ description: "Just-in-time exit from GBLIN to USDC to settle an invoice.",
102
+ ...message(`An invoice in USDC has arrived and the treasury holds GBLIN.
103
+
104
+ Invoice: ${arg(args, "usdc_needed", "(unspecified)")} USDC
105
+ Wallet: ${arg(args, "wallet_address", "(treasury wallet)")}
106
+
107
+ Rules:
108
+ - Exit only what the invoice needs, not the whole position.
109
+ - Do not start the exit inside the redemption cooldown or without gas for three transactions.
110
+
111
+ Steps:
112
+ 1. Call analyze_treasury_health for the wallet and read the cooldown and the gas status.
113
+ 2. If the cooldown is active or the gas is insufficient, say which and stop.
114
+ 3. Call swap_gblin_to_usdc_jit with the invoice amount and the wallet.
115
+ 4. Call preview_steps with the returned steps. If it says they would not succeed, report the failing step and its reason, and stop.
116
+ 5. Send the steps in order from the wallet, each with the gas it carries, and confirm each with get_transaction_status before the next. The exit through the Zap is all or nothing: if a step reverts, report it rather than retrying blindly.`),
117
+ };
118
+ }
119
+ case "seal_and_verify": {
120
+ const output = arg(args, "output_hash");
121
+ return {
122
+ description: "Seal, fetch the receipt, and state its limits.",
123
+ ...message(`Seal this action into the public transparency log and verify the receipt.
124
+
125
+ Action: ${arg(args, "action", "(unspecified)")}
126
+ Input hash: ${arg(args, "input_hash", "(missing)")}${output ? `\nOutput hash: ${output}` : ""}
127
+
128
+ Steps:
129
+ 1. Call seal_action_demo with these values.
130
+ 2. Call get_receipt with the index it returns, and follow the verification it describes.
131
+ 3. State what the receipt proves: that these hashes were recorded at this position of an append-only log.
132
+ 4. State what it does not prove: that the action was correct, or that the hashes describe what the label says.`),
133
+ };
134
+ }
135
+ default:
136
+ return null;
137
+ }
138
+ }
139
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,MAAM,CAAC,MAAM,kBAAkB,GAAuB;IACpD;QACE,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,oCAAoC;QAC3C,WAAW,EACT,6JAA6J;QAC/J,SAAS,EAAE;YACT,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uDAAuD,EAAE,QAAQ,EAAE,IAAI,EAAE;YACxG,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,kDAAkD,EAAE,QAAQ,EAAE,KAAK,EAAE;SAC1G;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,0CAA0C;QACjD,WAAW,EACT,gKAAgK;QAClK,SAAS,EAAE;YACT,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,0CAA0C,EAAE,QAAQ,EAAE,IAAI,EAAE;YACzF,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,EAAE;YACvE,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,kDAAkD,EAAE,QAAQ,EAAE,KAAK,EAAE;YAC1G,EAAE,IAAI,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MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YACxC,OAAO;gBACL,WAAW,EAAE,gDAAgD;gBAC7D,GAAG,OAAO,CAClB;;UAEU,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,CAAC;cAChC,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;;;;;;+GAMkB,CAAC;aACzG,CAAC;QACJ,CAAC;QAED;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * 11. seal_action_demo → POST <worker>/v1/seal-demo (free, 5/day/IP, demo:true)
9
9
  * 12. get_receipt → GET <worker>/v1/receipt/:i (free forever)
10
- * 13. how_to_seal_paid → static instructions for the paid $0.01 x402 route
10
+ * 13. how_to_seal_paid → static instructions for the paid $0.0045 x402 route
11
11
  */
12
12
  export declare const SEAL_ACTION_DEMO_DEFINITION: {
13
13
  name: string;
@@ -74,6 +74,7 @@ export declare const HOW_TO_SEAL_PAID_DEFINITION: {
74
74
  };
75
75
  };
76
76
  type ToolAnnotations = {
77
+ title: string;
77
78
  readOnlyHint: boolean;
78
79
  idempotentHint: boolean;
79
80
  destructiveHint: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"receipts.d.ts","sourceRoot":"","sources":["../src/receipts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoDH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCvC,CAAC;AA+BF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;CAgBlC,CAAC;AAmCF,eAAO,MAAM,2BAA2B;;;;;;;;CAKvC,CAAC;AA8BF,KAAK,eAAe,GAAG;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC;AAI5H,eAAO,MAAM,wBAAwB;;;;;;;;;GAIpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAIrF,CAAC"}
1
+ {"version":3,"file":"receipts.d.ts","sourceRoot":"","sources":["../src/receipts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyDH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCvC,CAAC;AA+BF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;CAgBlC,CAAC;AAmCF,eAAO,MAAM,2BAA2B;;;;;;;;CAKvC,CAAC;AA8BF,KAAK,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC;AAM3I,eAAO,MAAM,wBAAwB;;;;;;;;;GAIpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAIrF,CAAC"}
package/dist/receipts.js CHANGED
@@ -7,17 +7,21 @@
7
7
  *
8
8
  * 11. seal_action_demo → POST <worker>/v1/seal-demo (free, 5/day/IP, demo:true)
9
9
  * 12. get_receipt → GET <worker>/v1/receipt/:i (free forever)
10
- * 13. how_to_seal_paid → static instructions for the paid $0.01 x402 route
10
+ * 13. how_to_seal_paid → static instructions for the paid $0.0045 x402 route
11
11
  */
12
12
  const WORKER_BASE = "https://gblin-mcp.gblin-mcp-worker.workers.dev";
13
13
  const SEAL_PAID_URL = "https://gblin.digital/api/x402/seal";
14
14
  const VERIFIER_URL = "https://raw.githubusercontent.com/gblinproject/gblin-treasury-risk-regime/main/verify-receipt.mjs";
15
15
  const RECEIPT_NOTE = "A seal proves existence and time in a signed append-only log (root anchored daily on Base via EAS) — NOT a compliance certificate and NOT an endorsement. PRIVACY: input/output go in as hashes only; the action/agent_id/tool/meta strings you send are published in the public log — identifiers, never secrets.";
16
16
  function receiptResult(payload) {
17
+ const structured = payload && typeof payload === "object" && !Array.isArray(payload)
18
+ ? payload
19
+ : undefined;
17
20
  return {
18
21
  content: [
19
22
  { type: "text", text: JSON.stringify(payload, null, 2) },
20
23
  ],
24
+ ...(structured ? { structuredContent: structured } : {}),
21
25
  };
22
26
  }
23
27
  function receiptError(message, hint) {
@@ -31,7 +35,7 @@ function receiptError(message, hint) {
31
35
  async function parseJsonBody(res) {
32
36
  try {
33
37
  const v = await res.json();
34
- // il body deve essere un oggetto JSON: 42, "x", [] o null non sono risposte valide
38
+ // The body must be a JSON object: 42, "x", [] and null are not valid responses.
35
39
  if (typeof v !== "object" || v === null || Array.isArray(v))
36
40
  return null;
37
41
  return v;
@@ -55,7 +59,7 @@ async function workerFetch(path, init) {
55
59
  // ───────────────────────────────────────────────────────────────────────────
56
60
  export const SEAL_ACTION_DEMO_DEFINITION = {
57
61
  name: "seal_action_demo",
58
- description: "Seal the HASHES of an AI action into GBLIN's public append-only RFC 6962 transparency log (FREE demo, 5/day/IP, receipt marked demo:true). Returns a portable receipt: Ed25519 signature + Merkle inclusion proof + operator-signed C2SP checkpoint, offline-verifiable forever with the zero-dependency verify-receipt.mjs. Input/output go in as sha256 HASHES only; the action label and metadata you send are published in the public log. Unlimited seals cost $0.01 via x402 — see how_to_seal_paid.",
62
+ description: "Seal the HASHES of an AI action into GBLIN's public append-only RFC 6962 transparency log (FREE demo, 5/day/IP, receipt marked demo:true). Returns a portable receipt: Ed25519 signature + Merkle inclusion proof + operator-signed C2SP checkpoint, offline-verifiable forever with the zero-dependency verify-receipt.mjs. Input/output go in as sha256 HASHES only; the action label and metadata you send are published in the public log. Unlimited seals cost $0.0045 via x402 — see how_to_seal_paid.",
59
63
  inputSchema: {
60
64
  type: "object",
61
65
  properties: {
@@ -105,7 +109,7 @@ async function handleSealActionDemo(args) {
105
109
  }
106
110
  if (!res.ok) {
107
111
  return receiptError(String(body.error ?? `seal-demo failed (HTTP ${res.status})`), res.status === 429
108
- ? "Demo limit is 5 seals/day/IP. Unlimited seals: $0.01 via x402 — call how_to_seal_paid."
112
+ ? "Demo limit is 5 seals/day/IP. Unlimited seals: $0.0045 via x402 — call how_to_seal_paid."
109
113
  : "Check that input_hash is 64 lowercase hex chars and action is <=128 chars.");
110
114
  }
111
115
  return receiptResult({ ...body, note: RECEIPT_NOTE, verify_offline: VERIFIER_URL });
@@ -135,7 +139,7 @@ export const GET_RECEIPT_DEFINITION = {
135
139
  };
136
140
  async function handleGetReceipt(args) {
137
141
  const raw = args?.index;
138
- // alcuni client MCP mandano i numeri come stringhe JSON: coerciamo "5" -> 5
142
+ // Some MCP clients send numbers as JSON strings: coerce "5" to 5.
139
143
  const index = typeof raw === "string" && /^\d+$/.test(raw) ? Number(raw) : raw;
140
144
  if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) {
141
145
  return receiptError("index must be a non-negative safe integer");
@@ -164,13 +168,13 @@ async function handleGetReceipt(args) {
164
168
  // ───────────────────────────────────────────────────────────────────────────
165
169
  export const HOW_TO_SEAL_PAID_DEFINITION = {
166
170
  name: "how_to_seal_paid",
167
- description: "Instructions for UNLIMITED paid seals ($0.01 USDC per seal via x402 on Base) in GBLIN's AI Action Receipts transparency log — endpoint, body schema, payment flow, and how to verify receipts offline. Free demo alternative: seal_action_demo (5/day/IP).",
171
+ description: "Instructions for UNLIMITED paid seals ($0.0045 USDC per seal via x402 on Base) in GBLIN's AI Action Receipts transparency log — endpoint, body schema, payment flow, and how to verify receipts offline. Free demo alternative: seal_action_demo (5/day/IP).",
168
172
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
169
173
  };
170
174
  async function handleHowToSealPaid() {
171
175
  return receiptResult({
172
176
  endpoint: `POST ${SEAL_PAID_URL}`,
173
- price: "$0.01 USDC per seal via x402 (Base, eip155:8453)",
177
+ price: "$0.0045 USDC per seal via x402 (Base, eip155:8453)",
174
178
  flow: "POST without payment first → HTTP 402 with the x402 v2 challenge (PAYMENT-REQUIRED header, mirrored in the body). Settle with any x402 client (e.g. @x402/fetch): gasless EIP-3009 USDC transfer, then the same POST returns the sealed receipt.",
175
179
  body_schema: {
176
180
  action: "string, <=128 chars, required — published in the log",
@@ -186,12 +190,12 @@ async function handleHowToSealPaid() {
186
190
  note: RECEIPT_NOTE,
187
191
  });
188
192
  }
189
- const READ_ONLY = { readOnlyHint: true, idempotentHint: true, destructiveHint: false, openWorldHint: true };
190
- const APPEND_ONLY = { readOnlyHint: false, idempotentHint: false, destructiveHint: false, openWorldHint: true };
193
+ const readOnly = (title) => ({ title, readOnlyHint: true, idempotentHint: true, destructiveHint: false, openWorldHint: true });
194
+ const appendOnly = (title) => ({ title, readOnlyHint: false, idempotentHint: false, destructiveHint: false, openWorldHint: true });
191
195
  export const RECEIPT_TOOL_DEFINITIONS = [
192
- { ...SEAL_ACTION_DEMO_DEFINITION, annotations: APPEND_ONLY },
193
- { ...GET_RECEIPT_DEFINITION, annotations: READ_ONLY },
194
- { ...HOW_TO_SEAL_PAID_DEFINITION, annotations: READ_ONLY },
196
+ { ...SEAL_ACTION_DEMO_DEFINITION, annotations: appendOnly("Seal an action into the transparency log") },
197
+ { ...GET_RECEIPT_DEFINITION, annotations: readOnly("Fetch a sealed receipt") },
198
+ { ...HOW_TO_SEAL_PAID_DEFINITION, annotations: readOnly("How to seal without limits") },
195
199
  ];
196
200
  export const RECEIPT_TOOL_HANDLERS = {
197
201
  seal_action_demo: handleSealActionDemo,
@@ -1 +1 @@
1
- {"version":3,"file":"receipts.js","sourceRoot":"","sources":["../src/receipts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAU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EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AACrG,MAAM,UAAU,GAAG,CAAC,KAAa,EAAmB,EAAE,CACpD,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AAEvG,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,EAAE,GAAG,2BAA2B,EAAE,WAAW,EAAE,UAAU,CAAC,0CAA0C,CAAC,EAAE;IACvG,EAAE,GAAG,sBAAsB,EAAE,WAAW,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EAAE;IAC9E,EAAE,GAAG,2BAA2B,EAAE,WAAW,EAAE,QAAQ,CAAC,4BAA4B,CAAC,EAAE;CACxF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAwD;IACxF,gBAAgB,EAAE,oBAAoB;IACtC,WAAW,EAAE,gBAAgB;IAC7B,gBAAgB,EAAE,mBAAmB;CACtC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * GBLIN MCP — resources.
3
+ *
4
+ * Reference data an agent reads once and keeps: the deployment, the keys to pin, how to pay in
5
+ * GBLIN, and what this server costs. Anything that can change on chain is read live when the
6
+ * resource is requested, never written into the text.
7
+ */
8
+ export interface ResourceDefinition {
9
+ uri: string;
10
+ name: string;
11
+ title: string;
12
+ description: string;
13
+ mimeType: "application/json";
14
+ }
15
+ export declare const RESOURCE_DEFINITIONS: ResourceDefinition[];
16
+ export declare function readResource(uri: string): Promise<Record<string, unknown> | null>;
17
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4BH,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,eAAO,MAAM,oBAAoB,EAAE,kBAAkB,EAiCpD,CAAC;AAgGF,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAavF"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * GBLIN MCP — resources.
3
+ *
4
+ * Reference data an agent reads once and keeps: the deployment, the keys to pin, how to pay in
5
+ * GBLIN, and what this server costs. Anything that can change on chain is read live when the
6
+ * resource is requested, never written into the text.
7
+ */
8
+ import { getAddress } from "viem";
9
+ import { BASE_CHAIN_ID, GBLIN_ATTESTOR, GBLIN_AUCTION_ORDER, GBLIN_FILL_AGENT, GBLIN_GUARDIAN, GBLIN_LENS, GBLIN_POOL, GBLIN_PREVIOUS, GBLIN_PREVIOUS_2, GBLIN_SENTINEL, GBLIN_TIMELOCK, GBLIN_UNISWAP_ADAPTER, GBLIN_VAULT, GBLIN_ZAP, USDC, WETH, } from "./config.js";
10
+ import { getTokenDomain } from "./payments.js";
11
+ import { TOOL_PRICES } from "./paywall.js";
12
+ const EXPLORER = "https://basescan.org/address/";
13
+ const HOSTED_MCP = "https://gblin-mcp.gblin-mcp-worker.workers.dev/mcp";
14
+ export const RESOURCE_DEFINITIONS = [
15
+ {
16
+ uri: "gblin://contracts",
17
+ name: "contracts",
18
+ title: "GBLIN deployment on Base",
19
+ description: "Every contract of the deployment in service, with its role and explorer link, and the earlier deployments that must not be used.",
20
+ mimeType: "application/json",
21
+ },
22
+ {
23
+ uri: "gblin://payments",
24
+ name: "payments",
25
+ title: "Paying and being paid in GBLIN",
26
+ description: "How GBLIN is paid with a signature and no ETH (EIP-3009): the EIP-712 domain read live from the token, the x402 payload shape, and the accepts block a seller publishes to be paid in GBLIN.",
27
+ mimeType: "application/json",
28
+ },
29
+ {
30
+ uri: "gblin://keys",
31
+ name: "keys",
32
+ title: "Keys to pin",
33
+ description: "The address that signs GBLIN risk attestations, which a verifier must pin, and where the transparency-log and witness keys are published.",
34
+ mimeType: "application/json",
35
+ },
36
+ {
37
+ uri: "gblin://limits",
38
+ name: "limits",
39
+ title: "What this server costs and limits",
40
+ description: "This server runs locally and holds no keys. Which tools could be metered, at what price, and what limits come from the RPC rather than from the server.",
41
+ mimeType: "application/json",
42
+ },
43
+ ];
44
+ const link = (address) => `${EXPLORER}${getAddress(address)}`;
45
+ async function readContracts() {
46
+ const entry = (address, role) => ({ address: getAddress(address), role, explorer: link(address) });
47
+ return {
48
+ network: `eip155:${BASE_CHAIN_ID}`,
49
+ in_service: {
50
+ vault: entry(GBLIN_VAULT, "The index and its ERC-20 share token. Mints and redeems at NAV."),
51
+ lens: entry(GBLIN_LENS, "Read-only quotes and state for the vault."),
52
+ zap: entry(GBLIN_ZAP, "Mints with any token and exits to ETH in one transaction."),
53
+ sequencer_sentinel: entry(GBLIN_SENTINEL, "Sequencer uptime check and bounded pause guardian."),
54
+ uniswap_v3_adapter: entry(GBLIN_UNISWAP_ADAPTER, "Swap adapter used by the vault and the Zap."),
55
+ cow_fill_agent: entry(GBLIN_FILL_AGENT, "Fills the rebalancing auction through CoW Protocol solvers."),
56
+ auction_order_handler: entry(GBLIN_AUCTION_ORDER, "ComposableCoW order handler for the auction."),
57
+ timelock: entry(GBLIN_TIMELOCK, "Owner of the vault and the sentinel; every change waits 48 hours."),
58
+ pool: entry(GBLIN_POOL, "Uniswap V3 WETH/GBLIN pool, fee tier 0.3%."),
59
+ },
60
+ roles: {
61
+ guardian: { address: getAddress(GBLIN_GUARDIAN), note: "May pause minting for a bounded period; redemption in kind stays open." },
62
+ },
63
+ deprecated: {
64
+ note: "Earlier deployments. They are not the token in service and must not be linked or bought.",
65
+ contracts: [getAddress(GBLIN_PREVIOUS), getAddress(GBLIN_PREVIOUS_2)],
66
+ },
67
+ assets: { weth: getAddress(WETH), usdc: getAddress(USDC) },
68
+ };
69
+ }
70
+ async function readPayments() {
71
+ const domain = await getTokenDomain();
72
+ return {
73
+ mechanism: "EIP-3009. The holder signs an authorization; anybody can carry it on chain, so the payer needs no ETH. A used or cancelled nonce can never be replayed.",
74
+ eip712_domain: { ...domain, source: "read live from the token through eip712Domain() (EIP-5267)" },
75
+ methods: {
76
+ receiveWithAuthorization: "Only the recipient can submit it, so nobody can front-run the transfer. Use it to pay a known counterparty.",
77
+ transferWithAuthorization: "Anybody can submit it. This is what an x402 facilitator carries on the seller's behalf.",
78
+ },
79
+ tools: {
80
+ prepare: "prepare_gblin_payment builds the message to sign, the calldata and the x402 payload.",
81
+ verify: "verify_gblin_authorization checks a signed authorization against the chain before anyone spends gas.",
82
+ relay: "relay_gblin_payment hands a signed payment and a signed fee to GBLIN's relay, for a payer that holds no ETH and has nobody to carry it.",
83
+ },
84
+ relay: {
85
+ url: process.env.GBLIN_RELAY_URL ?? "https://gblin.digital/api/relay/gblin",
86
+ fee: "Quoted live by a GET on the relay URL, in GBLIN at the NAV. Paid with a second authorization from the payer.",
87
+ atomicity: "The payment and the fee are submitted in one transaction through Multicall3: both settle or neither does.",
88
+ },
89
+ x402_payment_payload: {
90
+ x402Version: 2,
91
+ scheme: "exact",
92
+ network: `eip155:${BASE_CHAIN_ID}`,
93
+ payload: { signature: "0x…", authorization: { from: "0x…", to: "0x…", value: "atomic units", validAfter: "0", validBefore: "unix seconds", nonce: "0x… (32 bytes)" } },
94
+ },
95
+ x402_accepts_for_sellers: {
96
+ scheme: "exact",
97
+ network: `eip155:${BASE_CHAIN_ID}`,
98
+ asset: getAddress(GBLIN_VAULT),
99
+ extra: { name: domain.name, version: domain.version },
100
+ note: "The extra block is the token's EIP-712 domain. A facilitator uses it to verify the signature.",
101
+ },
102
+ decimals: 18,
103
+ };
104
+ }
105
+ function readKeys() {
106
+ return {
107
+ risk_attestation_attestor: {
108
+ address: getAddress(GBLIN_ATTESTOR),
109
+ rule: "Pin this address. Checking a signature against the attestor field of the same response proves nothing.",
110
+ used_by: "verify_risk_attestation",
111
+ },
112
+ transparency_log_and_witness: {
113
+ published_by: HOSTED_MCP,
114
+ how: "Read the gblin://keys resource of the hosted server; it carries the log verifier key, the witness key and the rotation policy.",
115
+ },
116
+ };
117
+ }
118
+ function readLimits() {
119
+ const metered = Object.fromEntries(Object.entries(TOOL_PRICES).map(([name, def]) => [name, def.priceLabel]));
120
+ return {
121
+ runs: "locally, over stdio. The server holds no keys and never sends a transaction.",
122
+ rate_limit: "none of its own. The practical limit is the RPC in GBLIN_RPC_URL.",
123
+ price: "Every tool is free by default.",
124
+ metered_when_enabled: {
125
+ switch: 'MCP_PAYWALL="true"',
126
+ tools: metered,
127
+ note: "Off by default: a stdio server cannot verify and settle a payment on its own, so metering it would be bypassable.",
128
+ },
129
+ paid_endpoints: "Paid data lives on x402 HTTP endpoints at https://gblin.digital, not in this server.",
130
+ };
131
+ }
132
+ export async function readResource(uri) {
133
+ switch (uri) {
134
+ case "gblin://contracts":
135
+ return readContracts();
136
+ case "gblin://payments":
137
+ return readPayments();
138
+ case "gblin://keys":
139
+ return readKeys();
140
+ case "gblin://limits":
141
+ return readLimits();
142
+ default:
143
+ return null;
144
+ }
145
+ }
146
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EACL,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,IAAI,EACJ,IAAI,GACL,MAAM,aAAa,C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C,CAAC,CAAC;IAC7G,OAAO;QACL,IAAI,EAAE,8EAA8E;QACpF,UAAU,EAAE,mEAAmE;QAC/E,KAAK,EAAE,gCAAgC;QACvC,oBAAoB,EAAE;YACpB,MAAM,EAAE,oBAAoB;YAC5B,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,mHAAmH;SAC1H;QACD,cAAc,EAAE,sFAAsF;KACvG,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,mBAAmB;YACtB,OAAO,aAAa,EAAE,CAAC;QACzB,KAAK,kBAAkB;YACrB,OAAO,YAAY,EAAE,CAAC;QACxB,KAAK,cAAc;YACjB,OAAO,QAAQ,EAAE,CAAC;QACpB,KAAK,gBAAgB;YACnB,OAAO,UAAU,EAAE,CAAC;QACtB;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * GBLIN MCP — helpers shared by every tool module: the MCP result envelopes, the builder-code
3
+ * suffix, the routing data the Zap needs, and the gas limit set on Zap steps.
4
+ */
5
+ export declare const BUILDER_CODE_SUFFIX = "62635f6762646f33326a300b0080218021802180218021802180218021";
6
+ export declare const VENUE_FEE_DATA: `0x${string}`;
7
+ /**
8
+ * Gas limit set on every step that goes through the Zap. The vault forwards gas-capped transfers
9
+ * and keeps a reserve for them (the 63/64 rule), so a wallet's automatic estimate can land just
10
+ * under what the call needs and revert out of gas. Measured on a fork of Base: the exit uses about
11
+ * 810,000 and needs a limit above 1,013,000; the investment uses about 720,000 against an estimate
12
+ * of 855,000. On Base the extra limit costs nothing unless it is used.
13
+ */
14
+ export declare const ZAP_GAS_LIMIT = 1100000;
15
+ export declare const ZAP_GAS_NOTE = "Every Zap step carries gas: send it with that limit. An automatic estimate can fall just under what the call needs, because the vault reserves gas for its capped transfers, and the step then reverts out of gas.";
16
+ /** One routing entry per basket row, index for index; WETH and abandoned rows ignore theirs. */
17
+ export declare function venueDataPerRow(): Promise<`0x${string}`[]>;
18
+ export declare function appendBuilderCode(calldata: string): string;
19
+ export declare function toolResult(payload: unknown): {
20
+ structuredContent?: Record<string, unknown> | undefined;
21
+ content: {
22
+ type: "text";
23
+ text: string;
24
+ }[];
25
+ };
26
+ export declare function toolError(message: string, hint?: string): {
27
+ isError: boolean;
28
+ content: {
29
+ type: "text";
30
+ text: string;
31
+ }[];
32
+ };
33
+ /** JSON.stringify replacer that turns BigInt into string. */
34
+ export declare function jsonReplacer(_key: string, value: unknown): unknown;
35
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,eAAO,MAAM,mBAAmB,+DAA+D,CAAC;AAGhG,eAAO,MAAM,cAAc,eAAkE,CAAC;AAE9F;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,UAAY,CAAC;AACvC,eAAO,MAAM,YAAY,uNAC6L,CAAC;AAEvN,gGAAgG;AAChG,wBAAsB,eAAe,IAAI,OAAO,CAAC,KAAK,MAAM,EAAE,EAAE,CAAC,CAGhE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI1D;AAMD,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO;;;;;;EAgB1C;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;;;;;;EAUvD;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAElE"}
package/dist/shared.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * GBLIN MCP — helpers shared by every tool module: the MCP result envelopes, the builder-code
3
+ * suffix, the routing data the Zap needs, and the gas limit set on Zap steps.
4
+ */
5
+ import { encodeAbiParameters } from "viem";
6
+ import { LENS_ABI } from "./abi.js";
7
+ import { client } from "./client.js";
8
+ import { GBLIN_LENS, GBLIN_VAULT, WETH_USDC_POOL_FEE } from "./config.js";
9
+ // ───────────────────────────────────────────────────────────────────────────
10
+ // ERC-8021 Builder Code attribution (Base Builder Rewards)
11
+ // ───────────────────────────────────────────────────────────────────────────
12
+ export const BUILDER_CODE_SUFFIX = "62635f6762646f33326a300b0080218021802180218021802180218021";
13
+ // Routing data the Zap hands to its swap adapter: the Uniswap V3 fee tier of the pair, ABI-encoded.
14
+ export const VENUE_FEE_DATA = encodeAbiParameters([{ type: "uint24" }], [WETH_USDC_POOL_FEE]);
15
+ /**
16
+ * Gas limit set on every step that goes through the Zap. The vault forwards gas-capped transfers
17
+ * and keeps a reserve for them (the 63/64 rule), so a wallet's automatic estimate can land just
18
+ * under what the call needs and revert out of gas. Measured on a fork of Base: the exit uses about
19
+ * 810,000 and needs a limit above 1,013,000; the investment uses about 720,000 against an estimate
20
+ * of 855,000. On Base the extra limit costs nothing unless it is used.
21
+ */
22
+ export const ZAP_GAS_LIMIT = 1_100_000;
23
+ export const ZAP_GAS_NOTE = "Every Zap step carries gas: send it with that limit. An automatic estimate can fall just under what the call needs, because the vault reserves gas for its capped transfers, and the step then reverts out of gas.";
24
+ /** One routing entry per basket row, index for index; WETH and abandoned rows ignore theirs. */
25
+ export async function venueDataPerRow() {
26
+ const n = await client.readContract({ address: GBLIN_LENS, abi: LENS_ABI, functionName: "basketLength", args: [GBLIN_VAULT] }).catch(() => 3n);
27
+ return Array.from({ length: Number(n) }, () => VENUE_FEE_DATA);
28
+ }
29
+ export function appendBuilderCode(calldata) {
30
+ // Strip 0x if present, append suffix, restore 0x prefix
31
+ const hex = calldata.startsWith("0x") ? calldata.slice(2) : calldata;
32
+ return "0x" + hex + BUILDER_CODE_SUFFIX;
33
+ }
34
+ // ───────────────────────────────────────────────────────────────────────────
35
+ // MCP result envelopes
36
+ // ───────────────────────────────────────────────────────────────────────────
37
+ export function toolResult(payload) {
38
+ // The JSON also travels as `structuredContent`: clients that support it read the object without
39
+ // parsing text, and clients that do not simply ignore the field. Only a plain object qualifies.
40
+ const structured = payload && typeof payload === "object" && !Array.isArray(payload)
41
+ ? JSON.parse(JSON.stringify(payload, jsonReplacer))
42
+ : undefined;
43
+ return {
44
+ content: [
45
+ {
46
+ type: "text",
47
+ text: JSON.stringify(payload, jsonReplacer, 2),
48
+ },
49
+ ],
50
+ ...(structured ? { structuredContent: structured } : {}),
51
+ };
52
+ }
53
+ export function toolError(message, hint) {
54
+ return {
55
+ isError: true,
56
+ content: [
57
+ {
58
+ type: "text",
59
+ text: JSON.stringify({ error: message, hint }, null, 2),
60
+ },
61
+ ],
62
+ };
63
+ }
64
+ /** JSON.stringify replacer that turns BigInt into string. */
65
+ export function jsonReplacer(_key, value) {
66
+ return typeof value === "bigint" ? value.toString() : value;
67
+ }
68
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1E,8EAA8E;AAC9E,2DAA2D;AAC3D,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,4DAA4D,CAAC;AAEhG,oGAAoG;AACpG,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,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