z-zero-mcp-server 1.10.1 β 1.10.3
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 +3 -3
- package/dist/index.js +27 -17
- package/dist/lib/browser.d.ts +19 -0
- package/dist/lib/browser.js +79 -0
- package/dist/playwright_bridge.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npx z-zero-mcp-server
|
|
|
14
14
|
|
|
15
15
|
**What makes it different:**
|
|
16
16
|
- π **Zero-trust by design** β the AI never sees PAN, CVV, or expiry. Card data exists only in RAM, injected via Playwright at the last step, then wiped.
|
|
17
|
-
- β½ **Gasless USDC on Base** β auto-detects crypto checkout (EIP-681) and settles as a gasless USDC transfer sponsored by Coinbase Paymaster. The agent holds only USDC β no ETH, no gas UX.
|
|
17
|
+
- β½ **Gasless USDC on Base** β auto-detects crypto checkout (EIP-681) and settles as a gasless USDC transfer sponsored by Coinbase Paymaster. The agent holds only USDC β no ETH, no gas UX. **Opt-in:** off unless you set `Z_ZERO_ENABLE_WEB3_PAY=1`, because an on-chain send to an address read off a web page cannot be reversed.
|
|
18
18
|
- π³ **JIT single-use virtual cards** β amount-locked, 1-hour TTL, burned after a single use. Fiat fallback for the rest of the web.
|
|
19
19
|
- π§ **Smart Routing + checkout intelligence** β `get_merchant_hints` serves platform-specific checkout playbooks (Shopify, Etsy, WooCommerceβ¦).
|
|
20
20
|
- βοΈ **Linked purpose + outcome** β the server signs the criteria the agent records at issuance. Before checkout, `execute_payment` hands those criteria back and requires a second call with `go` or `pause`; a confirmed purchase seals the answer into the signed receipt. The record is inspectable without pretending the platform judged whether the agent told the truth.
|
|
@@ -71,7 +71,7 @@ npx z-zero-mcp-server
|
|
|
71
71
|
|
|
72
72
|
*The AI agent never touches card data β it only handles single-use tokens. Real card details are injected by Playwright at the last step and wiped from RAM.*
|
|
73
73
|
|
|
74
|
-
> **Crypto checkout branch:** when `auto_pay_checkout` detects a crypto-native checkout (EIP-681), it skips the card flow entirely and settles as a **gasless USDC transfer on Base** β see above.
|
|
74
|
+
> **Crypto checkout branch:** when `auto_pay_checkout` detects a crypto-native checkout (EIP-681), it skips the card flow entirely and settles as a **gasless USDC transfer on Base** β see above. Off by default; enable with `Z_ZERO_ENABLE_WEB3_PAY=1`.
|
|
75
75
|
|
|
76
76
|
---
|
|
77
77
|
|
|
@@ -162,7 +162,7 @@ Older self-hosted backends without the rotate endpoint keep working β the past
|
|
|
162
162
|
|
|
163
163
|
| Tool | Description |
|
|
164
164
|
|------|-------------|
|
|
165
|
-
| `auto_pay_checkout` | Fully autonomous checkout β
|
|
165
|
+
| `auto_pay_checkout` | Fully autonomous checkout β issues a JIT card and completes payment (crypto checkout only with `Z_ZERO_ENABLE_WEB3_PAY=1`) |
|
|
166
166
|
| `get_merchant_hints` | Fetch platform-specific checkout playbook (pre-steps + selectors) from Knowledge Base |
|
|
167
167
|
| `report_checkout_fail` | Report a failed checkout with a **structured `failure_class`** (14-class enum) β feeds the self-healing loop |
|
|
168
168
|
| `verify_receipt` | Verify a signed receipt by id β prove a purchase happened instead of claiming it |
|
package/dist/index.js
CHANGED
|
@@ -58,13 +58,13 @@ const getBalanceRemote = activeBackend.getBalanceRemote;
|
|
|
58
58
|
const listCardsRemote = activeBackend.listCardsRemote;
|
|
59
59
|
const getDepositAddressesRemote = activeBackend.getDepositAddressesRemote;
|
|
60
60
|
const getTokenPurposeRemote = activeBackend.getTokenPurposeRemote;
|
|
61
|
-
console.error(`[Z-ZERO MCP] π Base + USDC (
|
|
61
|
+
console.error(`[Z-ZERO MCP] π Base + USDC (gasless)`);
|
|
62
62
|
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
63
63
|
const playwright_bridge_js_1 = require("./playwright_bridge.js");
|
|
64
64
|
const ucp_bridge_js_1 = require("./ucp_bridge.js");
|
|
65
65
|
const web3_detector_js_1 = require("./lib/web3-detector.js");
|
|
66
66
|
const extract_total_price_js_1 = require("./lib/extract-total-price.js");
|
|
67
|
-
const
|
|
67
|
+
const browser_js_1 = require("./lib/browser.js");
|
|
68
68
|
const key_store_js_1 = require("./lib/key-store.js"); // β
Hot-Swap + rotate-on-connect
|
|
69
69
|
const url_guard_js_1 = require("./lib/url-guard.js");
|
|
70
70
|
const api_base_js_1 = require("./lib/api-base.js");
|
|
@@ -283,7 +283,7 @@ server.registerTool("get_deposit_addresses", {
|
|
|
283
283
|
// ============================================================
|
|
284
284
|
server.registerTool("request_payment_token", {
|
|
285
285
|
title: "Issue JIT Card (spends $0.10 fee)",
|
|
286
|
-
description: "Request a single-use JIT virtual card ($1β$
|
|
286
|
+
description: "Request a single-use JIT virtual card ($1β$50) locked to one amount + merchant. β οΈ Read mcp://resources/sop first. Only call once the FINAL total is visible β for physical goods that is AFTER shipping is submitted (use get_merchant_hints to navigate there). For digital goods with the price already visible, prefer auto_pay_checkout instead. " +
|
|
287
287
|
"BEFORE requesting: look at the checkout page one more time and compare it against what the user actually asked for β same items, same quantity, same variant, same destination? If anything differs, do NOT request a token; fix the cart or check with the user first. A mismatch you catch here costs nothing; after this point it costs a card. If you pass `cart`, the server signs your declared intent and binds the card to it β the user gets cryptographic proof of what this card was authorized for. Pass `criteria` too: the few things the owner actually cared about, which this purchase gets scored against at payment time.",
|
|
288
288
|
inputSchema: {
|
|
289
289
|
card_alias: zod_1.z
|
|
@@ -292,8 +292,8 @@ server.registerTool("request_payment_token", {
|
|
|
292
292
|
amount: zod_1.z
|
|
293
293
|
.number()
|
|
294
294
|
.min(1, "Minimum amount is $1.00")
|
|
295
|
-
.max(
|
|
296
|
-
.describe("Amount in USD to authorize (min: $1, max: $
|
|
295
|
+
.max(50, "Maximum amount is $50.00")
|
|
296
|
+
.describe("Amount in USD to authorize (min: $1, max: $50)"),
|
|
297
297
|
merchant: zod_1.z
|
|
298
298
|
.string()
|
|
299
299
|
.describe("Name or URL of the merchant/service being purchased"),
|
|
@@ -373,7 +373,7 @@ server.registerTool("request_payment_token", {
|
|
|
373
373
|
{
|
|
374
374
|
type: "text",
|
|
375
375
|
text: balance !== undefined
|
|
376
|
-
? `Insufficient balance. Card "${card_alias}" has $${balance} but you requested $${amount}. Or amount is outside the $1-$
|
|
376
|
+
? `Insufficient balance. Card "${card_alias}" has $${balance} but you requested $${amount}. Or amount is outside the $1-$50 limit.`
|
|
377
377
|
: `Card "${card_alias}" not found, API key is invalid, or amount limit exceeded.`,
|
|
378
378
|
},
|
|
379
379
|
],
|
|
@@ -1102,7 +1102,7 @@ server.registerTool("show_api_key_status", {
|
|
|
1102
1102
|
});
|
|
1103
1103
|
server.registerTool("auto_pay_checkout", {
|
|
1104
1104
|
title: "Auto-Pay Checkout (charges the card)",
|
|
1105
|
-
description: "β οΈ MANDATORY: Read mcp://resources/sop first. Only use on PAYMENT pages where final total is visible.
|
|
1105
|
+
description: "β οΈ MANDATORY: Read mcp://resources/sop first. Only use on PAYMENT pages where final total is visible. Issues a JIT card and completes the payment (paying a crypto address found on the page is OFF unless the owner set Z_ZERO_ENABLE_WEB3_PAY=1). For physical goods (Shopify, Etsy), get_merchant_hints first.",
|
|
1106
1106
|
inputSchema: {
|
|
1107
1107
|
checkout_url: zod_1.z
|
|
1108
1108
|
.string()
|
|
@@ -1126,7 +1126,7 @@ server.registerTool("auto_pay_checkout", {
|
|
|
1126
1126
|
// no human-authorized token to cross-check against β this range IS the only amount guard.
|
|
1127
1127
|
// It bounds the blast radius if price extraction or a payment link is wrong/malicious.
|
|
1128
1128
|
const AUTO_PAY_MIN_USD = 1;
|
|
1129
|
-
const AUTO_PAY_MAX_USD =
|
|
1129
|
+
const AUTO_PAY_MAX_USD = 50;
|
|
1130
1130
|
if (!API_KEY) {
|
|
1131
1131
|
return {
|
|
1132
1132
|
content: [{ type: "text", text: JSON.stringify({
|
|
@@ -1139,14 +1139,23 @@ server.registerTool("auto_pay_checkout", {
|
|
|
1139
1139
|
// ββ SSRF guard (shared helper) βββββββββββββββββββββββββββββββ
|
|
1140
1140
|
(0, url_guard_js_1.assertSafeCheckoutUrl)(checkout_url);
|
|
1141
1141
|
// ββ Single Browser Instance for efficiency ββββββββββββββββββ
|
|
1142
|
-
const browser = await
|
|
1142
|
+
const browser = await (0, browser_js_1.launchBrowser)();
|
|
1143
1143
|
const context = await browser.newContext();
|
|
1144
1144
|
const page = await context.newPage();
|
|
1145
1145
|
try {
|
|
1146
|
-
// STEP 1: Web3 Detection
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1146
|
+
// STEP 1: Web3 Detection β OFF unless the machine's owner opts in.
|
|
1147
|
+
// The recipient is read off the page (any visible "ethereum:0xβ¦" text
|
|
1148
|
+
// matches, a review or comment included) and an on-chain send cannot be
|
|
1149
|
+
// reversed, so paying it stays shut by default (decision 23/10/2026).
|
|
1150
|
+
let web3Result = null;
|
|
1151
|
+
if (process.env.Z_ZERO_ENABLE_WEB3_PAY === "1") {
|
|
1152
|
+
console.error(`[SMART ROUTE] Scanning ${checkout_url} for Web3...`);
|
|
1153
|
+
web3Result = await (0, web3_detector_js_1.detectWeb3Payment)(page, checkout_url);
|
|
1154
|
+
}
|
|
1155
|
+
else {
|
|
1156
|
+
await page.goto(checkout_url, { waitUntil: "domcontentloaded", timeout: 20_000 });
|
|
1157
|
+
}
|
|
1158
|
+
if (web3Result?.detected && web3Result.params) {
|
|
1150
1159
|
const { to, eip681_amount, data } = web3Result.params;
|
|
1151
1160
|
let amount = eip681_amount ?? 0;
|
|
1152
1161
|
if (!amount && data && data.length >= 138) {
|
|
@@ -1174,7 +1183,7 @@ server.registerTool("auto_pay_checkout", {
|
|
|
1174
1183
|
}
|
|
1175
1184
|
const resp = await fetch(`${ZZERO_API}/api/wallet/transfer`, {
|
|
1176
1185
|
method: "POST",
|
|
1177
|
-
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${API_KEY}
|
|
1186
|
+
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${API_KEY}`, "x-mcp-version": version_js_2.CURRENT_MCP_VERSION },
|
|
1178
1187
|
body: JSON.stringify({ to, amount, card_alias }),
|
|
1179
1188
|
});
|
|
1180
1189
|
const txResult = await resp.json();
|
|
@@ -1470,9 +1479,9 @@ Tools: \`check_balance\`, \`list_cards\`, \`get_deposit_addresses\`, \`set_api_k
|
|
|
1470
1479
|
## PATH A β Digital goods / SaaS / API (price already visible)
|
|
1471
1480
|
|
|
1472
1481
|
Call \`auto_pay_checkout(checkout_url, card_alias)\` β one call:
|
|
1473
|
-
-
|
|
1474
|
-
|
|
1475
|
-
- Amount is read from the page and capped to $1β$
|
|
1482
|
+
- Issues a JIT card + fills the form. (Paying on-chain to an address found on the page is OFF by
|
|
1483
|
+
default β the owner must set Z_ZERO_ENABLE_WEB3_PAY=1. Without it, a crypto-only page is not paid.)
|
|
1484
|
+
- Amount is read from the page and capped to $1β$50.
|
|
1476
1485
|
- Read the returned \`status\` β see **PAYMENT OUTCOMES** below.
|
|
1477
1486
|
|
|
1478
1487
|
---
|
|
@@ -1623,6 +1632,7 @@ server.prompt("wallet_status", "Summarize the Z-ZERO wallet: card aliases, spend
|
|
|
1623
1632
|
async function main() {
|
|
1624
1633
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
1625
1634
|
await server.connect(transport);
|
|
1635
|
+
(0, browser_js_1.warmUpBrowser)();
|
|
1626
1636
|
console.error(`π Z-Zero MCP Server v${version_js_2.CURRENT_MCP_VERSION} running (Base + USDC, gasless via Coinbase Paymaster)...`);
|
|
1627
1637
|
console.error("Status: Secure & Connected to Z-ZERO Gateway");
|
|
1628
1638
|
console.error("Tools: list_cards, check_balance, get_deposit_addresses, request_payment_token, get_merchant_hints, execute_payment, auto_pay_checkout, cancel_payment_token, request_human_approval, report_checkout_fail, ucp_probe_checkout, verify_receipt, set_api_key, show_api_key_status");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/browser.ts
|
|
3
|
+
* Launches the headless Chromium the "Invisible Hand" fills checkouts with.
|
|
4
|
+
*
|
|
5
|
+
* `playwright` ships no install script (and we keep none β Socket score), so a
|
|
6
|
+
* fresh `npx` install has NO browser: the first purchase used to die with
|
|
7
|
+
* "Executable doesn't exist". Launch order now:
|
|
8
|
+
* 1. Playwright's headless shell, if already downloaded
|
|
9
|
+
* 2. the user's installed Google Chrome (no download needed)
|
|
10
|
+
* 3. one-time download of the headless shell into Playwright's cache, then retry
|
|
11
|
+
* `warmUpBrowser()` starts that download in the background at server start, so
|
|
12
|
+
* it is normally finished long before the first checkout.
|
|
13
|
+
*/
|
|
14
|
+
import { type Browser } from "playwright";
|
|
15
|
+
/** Runs `playwright install --only-shell chromium`. Idempotent (~0.3s when already installed). */
|
|
16
|
+
export declare function ensureBrowserInstalled(): Promise<void>;
|
|
17
|
+
/** Background pre-download at server start. Never throws. */
|
|
18
|
+
export declare function warmUpBrowser(): void;
|
|
19
|
+
export declare function launchBrowser(): Promise<Browser>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* lib/browser.ts
|
|
4
|
+
* Launches the headless Chromium the "Invisible Hand" fills checkouts with.
|
|
5
|
+
*
|
|
6
|
+
* `playwright` ships no install script (and we keep none β Socket score), so a
|
|
7
|
+
* fresh `npx` install has NO browser: the first purchase used to die with
|
|
8
|
+
* "Executable doesn't exist". Launch order now:
|
|
9
|
+
* 1. Playwright's headless shell, if already downloaded
|
|
10
|
+
* 2. the user's installed Google Chrome (no download needed)
|
|
11
|
+
* 3. one-time download of the headless shell into Playwright's cache, then retry
|
|
12
|
+
* `warmUpBrowser()` starts that download in the background at server start, so
|
|
13
|
+
* it is normally finished long before the first checkout.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ensureBrowserInstalled = ensureBrowserInstalled;
|
|
17
|
+
exports.warmUpBrowser = warmUpBrowser;
|
|
18
|
+
exports.launchBrowser = launchBrowser;
|
|
19
|
+
const playwright_1 = require("playwright");
|
|
20
|
+
const node_child_process_1 = require("node:child_process");
|
|
21
|
+
const node_path_1 = require("node:path");
|
|
22
|
+
const INSTALL_TIMEOUT_MS = 5 * 60_000; // ~100MB download on a slow line
|
|
23
|
+
let installing = null;
|
|
24
|
+
function isMissingBrowser(err) {
|
|
25
|
+
return err instanceof Error && /Executable doesn't exist|browserType\.launch: .*not found/i.test(err.message);
|
|
26
|
+
}
|
|
27
|
+
/** Runs `playwright install --only-shell chromium`. Idempotent (~0.3s when already installed). */
|
|
28
|
+
function ensureBrowserInstalled() {
|
|
29
|
+
if (installing)
|
|
30
|
+
return installing;
|
|
31
|
+
installing = new Promise((resolve, reject) => {
|
|
32
|
+
const cli = (0, node_path_1.join)((0, node_path_1.dirname)(require.resolve("playwright/package.json")), "cli.js");
|
|
33
|
+
// stdout must stay clean β it carries the MCP JSON-RPC stream.
|
|
34
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [cli, "install", "--only-shell", "chromium"], {
|
|
35
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36
|
+
});
|
|
37
|
+
let tail = "";
|
|
38
|
+
const keep = (chunk) => { tail = (tail + chunk.toString()).slice(-2000); };
|
|
39
|
+
child.stdout.on("data", keep);
|
|
40
|
+
child.stderr.on("data", keep);
|
|
41
|
+
const timer = setTimeout(() => child.kill(), INSTALL_TIMEOUT_MS);
|
|
42
|
+
child.on("error", (err) => { clearTimeout(timer); reject(err); });
|
|
43
|
+
child.on("close", (code) => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
if (code === 0)
|
|
46
|
+
resolve();
|
|
47
|
+
else
|
|
48
|
+
reject(new Error(`Browser download failed (exit ${code}): ${tail.trim().split("\n").slice(-3).join(" | ")}`));
|
|
49
|
+
});
|
|
50
|
+
}).catch((err) => {
|
|
51
|
+
installing = null; // let the next call retry
|
|
52
|
+
throw err;
|
|
53
|
+
});
|
|
54
|
+
return installing;
|
|
55
|
+
}
|
|
56
|
+
/** Background pre-download at server start. Never throws. */
|
|
57
|
+
function warmUpBrowser() {
|
|
58
|
+
ensureBrowserInstalled()
|
|
59
|
+
.then(() => console.error("[BROWSER] Checkout browser ready"))
|
|
60
|
+
.catch((err) => console.error(`[BROWSER] β οΈ Pre-download failed, will retry at checkout: ${err.message}`));
|
|
61
|
+
}
|
|
62
|
+
async function launchBrowser() {
|
|
63
|
+
try {
|
|
64
|
+
return await playwright_1.chromium.launch({ headless: true });
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
if (!isMissingBrowser(err))
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
return await playwright_1.chromium.launch({ headless: true, channel: "chrome" });
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// no system Chrome either β fall through to the download
|
|
75
|
+
}
|
|
76
|
+
console.error("[BROWSER] No browser found β downloading headless Chromium (one-time, ~100MB)...");
|
|
77
|
+
await ensureBrowserInstalled();
|
|
78
|
+
return playwright_1.chromium.launch({ headless: true });
|
|
79
|
+
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// Securely injects card data into checkout forms without exposing it to AI
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.fillCheckoutForm = fillCheckoutForm;
|
|
6
|
-
const playwright_1 = require("playwright");
|
|
7
6
|
const with_timeout_js_1 = require("./lib/with-timeout.js");
|
|
7
|
+
const browser_js_1 = require("./lib/browser.js");
|
|
8
8
|
const CHECKOUT_HARD_TIMEOUT_MS = 60_000; // 60s absolute cap β prevents slow-loris attacks
|
|
9
9
|
/**
|
|
10
10
|
* Detects and fills credit card form fields on a checkout page.
|
|
@@ -18,7 +18,7 @@ async function fillCheckoutForm(checkoutUrl, cardData, existingPage, hints) {
|
|
|
18
18
|
page = existingPage;
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
browser = await
|
|
21
|
+
browser = await (0, browser_js_1.launchBrowser)();
|
|
22
22
|
const context = await browser.newContext();
|
|
23
23
|
page = await context.newPage();
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "z-zero-mcp-server",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "Z-ZERO MCP Server β Secure JIT Virtual Card Payment tools for AI Agents (Claude, Cursor, AutoGPT) β Real Single-Use Virtual Cards, settled in USDC on Base",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|