z-zero-mcp-server 1.1.2 → 1.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.
Files changed (3) hide show
  1. package/README.md +65 -12
  2. package/dist/index.js +126 -72
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,47 @@
1
1
  # OpenClaw: Z-ZERO AI Agent MCP Server
2
2
 
3
- A Zero-Trust Payment Protocol built specifically for AI Agents using the [Model Context Protocol (MCP)](https://modelcontextprotocol.io). Give your local agents (Claude, Cursor, AntiGravity) the ability to make real-world purchases — securely, without ever seeing a real card number.
3
+ A Zero-Trust Payment Protocol built for AI Agents using the [Model Context Protocol (MCP)](https://modelcontextprotocol.io). Give your agents (Claude, Cursor, Antigravity) the ability to make real-world purchases — securely, without ever seeing a real card number.
4
+
5
+ **What makes it different:**
6
+ - 🔐 **Zero-trust** — AI never sees PAN, CVV, or expiry. Card data exists only in RAM, injected via Playwright, then wiped.
7
+ - 🌐 **Web3 + Fiat** — Auto-detects crypto checkout (EIP-681) and routes to on-chain USDT transfer. Falls back to JIT Visa for fiat.
8
+ - 🧠 **Smart Routing** — Cloud Knowledge Base (`get_merchant_hints`) provides platform-specific checkout playbooks for Shopify, Etsy, WooCommerce, and more.
9
+ - 🔄 **Self-Healing** — Failed checkouts are logged via `report_checkout_fail` for admin review, improving future success rates.
10
+
11
+ ---
4
12
 
5
13
  ## How It Works
6
14
 
7
- Instead of giving your AI direct access to a credit card number, OpenClaw issues **temporary, single-use JIT tokens**. The token is resolved in RAM, Playwright injects the card data directly into the payment form, and the virtual card is burned milliseconds later. Your AI never sees the PAN, CVV, or expiry.
15
+ ```mermaid
16
+ sequenceDiagram
17
+ actor User
18
+ participant AI as AI Agent
19
+ participant MCP as MCP Tools
20
+ participant API as Z-ZERO API
21
+ participant DB as Supabase DB
22
+
23
+ User->>AI: "Buy me this Shopify item"
24
+ Note over AI: Scans available MCP Tools
25
+ AI->>MCP: Reads description of auto_pay_checkout
26
+ MCP-->>AI: "⚠️ MANDATORY: Read mcp://resources/sop first"
27
+ Note over AI: Fetches SOP before proceeding
28
+ AI->>MCP: Fetch resource mcp://resources/sop
29
+ MCP-->>AI: Platform rules + 3-Group payment SOP
30
+ Note over AI: "Shopify = physical goods. Must collect shipping first."
31
+ AI->>MCP: get_merchant_hints("_platform_shopify")
32
+ MCP->>API: GET /api/checkout-hints?domain=_platform_shopify&fields=merchant
33
+ API->>DB: Query checkout_hints table
34
+ DB-->>API: Platform hints data
35
+ API-->>MCP: Returns pre_steps + notes only
36
+ MCP-->>AI: "Fill shipping form first, click Next..."
37
+ Note over AI: Navigates checkout, fills shipping, waits for payment page
38
+ AI->>MCP: request_payment_token(amount, card_alias)
39
+ MCP-->>AI: Token: temp_auth_XYZ (1hr TTL)
40
+ AI->>MCP: execute_payment(token, checkout_url)
41
+ Note over MCP: Playwright auto-fills card form, burns token after use
42
+ MCP-->>AI: Success — payment complete
43
+ AI-->>User: "Done! Your Shopify item has been ordered."
44
+ ```
8
45
 
9
46
  ---
10
47
 
@@ -43,18 +80,34 @@ Get your Passport Key at: **[clawcard.store/dashboard/agents](https://www.clawca
43
80
 
44
81
  ## Available MCP Tools
45
82
 
83
+ ### Group 1 — Wallet Config (Passive)
84
+
85
+ | Tool | Description |
86
+ |------|-------------|
87
+ | `list_cards` | List all virtual card aliases and balances |
88
+ | `check_balance` | Check spendable USD balance for a card alias |
89
+ | `get_deposit_addresses` | Get crypto deposit addresses (EVM + Tron) to top up balance |
90
+ | `set_api_key` | Activate a new Passport Key instantly, no restart needed |
91
+ | `show_api_key_status` | Check if a Passport Key is currently loaded (prefix only) |
92
+
93
+ ### Group 2 — Manual 4-Step Payment (Active)
94
+
46
95
  | Tool | Description |
47
96
  |------|-------------|
48
- | `list_cards` | View your virtual card aliases and balances |
49
- | `check_balance` | Query a specific card's real-time balance |
50
- | `get_deposit_addresses` | Get deposit addresses to top up your balance |
51
- | `request_payment_token` | Generate a JIT auth token for a specific amount |
52
- | `execute_payment` | Auto-fill checkout form and execute payment |
53
- | `cancel_payment_token` | Cancel unused token, refund to wallet |
54
- | `request_human_approval` | Pause and ask human for approval |
55
- | `set_api_key` | **(Hot-Swap)** Update the Passport Key *without restarting Claude* |
56
- | `show_api_key_status` | Check if a Passport Key is currently loaded |
57
- | `check_for_updates` | **(Maintenance)** Check if a new MCP version is available |
97
+ | `request_payment_token` | Issue a JIT single-use Visa token for a specific amount (1hr TTL) |
98
+ | `execute_payment` | Auto-fill checkout form using a payment token via Playwright |
99
+ | `cancel_payment_token` | Cancel an unused token and refund to wallet |
100
+ | `request_human_approval` | Pause and request human confirmation before proceeding |
101
+
102
+ ### Group 3 Smart Autopilot
103
+
104
+ | Tool | Description |
105
+ |------|-------------|
106
+ | `auto_pay_checkout` | Fully autonomous checkout auto-detects Web3 or Fiat and completes payment |
107
+ | `get_merchant_hints` | Fetch platform-specific checkout playbook (pre-steps + selectors) from Knowledge Base |
108
+ | `report_checkout_fail` | Log a failed checkout URL for admin review (self-healing feedback loop) |
109
+
110
+ > 📖 **Note:** Version checking is handled automatically in each API call. No separate tool needed.
58
111
 
59
112
  ---
60
113
 
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ server.tool("list_cards", "List all available virtual card aliases and their bal
115
115
  // ============================================================
116
116
  // TOOL 2: Check card balance (safe)
117
117
  // ============================================================
118
- server.tool("check_balance", "Check the wallet balance (human-level total). This is the spendable USD available for issuing new cards. Cards themselves have 'limits' (set at creation), not 'balances' — use list_cards to see active token limits.", {
118
+ server.tool("check_balance", "Check spendable USD balance for a card alias. For active token limits, use list_cards instead.", {
119
119
  card_alias: zod_1.z
120
120
  .string()
121
121
  .describe("The alias of the card to check, e.g. 'Card_01'"),
@@ -155,7 +155,7 @@ server.tool("check_balance", "Check the wallet balance (human-level total). This
155
155
  // ============================================================
156
156
  // TOOL 2.5: Get deposit addresses (Phase 14 feature)
157
157
  // ============================================================
158
- server.tool("get_deposit_addresses", "Get your unique deposit addresses for EVM networks (Base, BSC, Ethereum) and Tron. Provide these to the human user when they need to add funds to their Z-ZERO balance.", {}, async () => {
158
+ server.tool("get_deposit_addresses", "Get crypto deposit addresses (EVM + Tron) to top up wallet balance.", {}, async () => {
159
159
  const data = await getDepositAddressesRemote();
160
160
  if (data?.error === "AUTH_REQUIRED") {
161
161
  return {
@@ -201,7 +201,7 @@ server.tool("get_deposit_addresses", "Get your unique deposit addresses for EVM
201
201
  // ============================================================
202
202
  // TOOL 3: Request a temporary payment token (issues secure JIT card)
203
203
  // ============================================================
204
- server.tool("request_payment_token", "Request a temporary payment token for a specific amount. A secure single-use virtual card is issued via the Z-ZERO network. The token is valid for 1 hour. Min: $1, Max: $100. Use this token with execute_payment to complete a purchase.", {
204
+ server.tool("request_payment_token", "⚠️ MANDATORY: Read mcp://resources/sop first. Collect shipping info and check get_merchant_hints before calling. Request a JIT virtual card ($1-$100).", {
205
205
  card_alias: zod_1.z
206
206
  .string()
207
207
  .describe("Which card to charge, e.g. 'Card_01'"),
@@ -274,7 +274,7 @@ server.tool("request_payment_token", "Request a temporary payment token for a sp
274
274
  // Agent MUST call this before execute_payment if unsure about a checkout page.
275
275
  // Returns domain-specific selectors and pre-steps from Z-ZERO cloud DB.
276
276
  // ============================================================
277
- server.tool("get_merchant_hints", "Fetch checkout hints for a specific domain from the Z-ZERO Knowledge Base. Call this BEFORE execute_payment when the checkout page is unusual, multi-step, or if a previous execute_payment attempt failed. Returns pre_steps (what to click first) and CSS selectors for card fields.", {
277
+ server.tool("get_merchant_hints", "Get merchant navigation flow for a domain or platform key (e.g. '_platform_etsy'). Returns pre_steps (how to navigate checkout) and platform notes. Call BEFORE starting checkout to understand the multi-step flow.", {
278
278
  domain: zod_1.z
279
279
  .string()
280
280
  .describe("The main domain of the checkout page, e.g. 'amazon.com' or 'shopify.com'. Strip 'www.' prefix."),
@@ -282,7 +282,7 @@ server.tool("get_merchant_hints", "Fetch checkout hints for a specific domain fr
282
282
  const ZZERO_API = process.env.Z_ZERO_API_BASE || "https://www.clawcard.store";
283
283
  const INTERNAL_SECRET = process.env.Z_ZERO_INTERNAL_SECRET || "";
284
284
  try {
285
- const resp = await fetch(`${ZZERO_API}/api/checkout-hints?domain=${encodeURIComponent(domain)}`, {
285
+ const resp = await fetch(`${ZZERO_API}/api/checkout-hints?domain=${encodeURIComponent(domain)}&fields=merchant`, {
286
286
  headers: {
287
287
  "x-internal-secret": INTERNAL_SECRET,
288
288
  "x-mcp-version": version_js_2.CURRENT_MCP_VERSION,
@@ -429,7 +429,7 @@ server.tool("execute_payment", "Execute a payment using a temporary token. This
429
429
  // ============================================================
430
430
  // TOOL 5: Cancel payment token (returns funds to wallet)
431
431
  // ============================================================
432
- server.tool("cancel_payment_token", "Cancel a payment token that has not been used yet. This will cancel the virtual card at the issuing network and refund the full amount back to the wallet. Use this when: (1) checkout price is higher than token amount, (2) purchase is no longer needed, or (3) human requests cancellation. IMPORTANT: Do NOT auto-cancel without human awareness — always inform the human first.", {
432
+ server.tool("cancel_payment_token", "Cancel unused token and refund instantly. Use when user cancels the purchase or to free up a card slot.", {
433
433
  token: zod_1.z
434
434
  .string()
435
435
  .describe("The payment token to cancel"),
@@ -476,7 +476,7 @@ server.tool("cancel_payment_token", "Cancel a payment token that has not been us
476
476
  // ============================================================
477
477
  // TOOL 6: Request human approval (Human-in-the-loop)
478
478
  // ============================================================
479
- server.tool("request_human_approval", "Request human approval before proceeding with an action that requires human judgment. Use this when: (1) checkout price is higher than token amount and you need authorization for a new token, (2) any unusual or irreversible action is required. This PAUSES the bot and waits for human decision.", {
479
+ server.tool("request_human_approval", "Pause and ask the user for approval before risky actions (price mismatch, large amount, unusual request).", {
480
480
  situation: zod_1.z
481
481
  .string()
482
482
  .describe("Clear description of what the bot found, e.g. 'Checkout shows $20 total (includes $3 tax) but current token is only $15'"),
@@ -519,7 +519,7 @@ server.tool("request_human_approval", "Request human approval before proceeding
519
519
  // ============================================================
520
520
  // TOOL 6.5: Set API Key (Hot-Swap Passport Key — NO restart needed)
521
521
  // ============================================================
522
- server.tool("set_api_key", "Update the Z-ZERO Passport Key immediately WITHOUT restarting the AI tool. Call this when the human provides a new key (e.g. 'zk_live_xxxxx'). The key is validated and activated instantly for all subsequent API calls. IMPORTANT: Never ask for the key proactively — only call this when the human explicitly provides it.", {
522
+ server.tool("set_api_key", "Activate a new Passport Key instantly, no restart needed. Only call when user explicitly provides a key.", {
523
523
  api_key: zod_1.z
524
524
  .string()
525
525
  .describe("The new Passport Key to activate. Must start with 'zk_live_' or 'zk_test_'. Get from: https://www.clawcard.store/dashboard/agents"),
@@ -546,7 +546,7 @@ server.tool("set_api_key", "Update the Z-ZERO Passport Key immediately WITHOUT r
546
546
  // ============================================================
547
547
  // TOOL 6.6: Show current API Key status (for debugging)
548
548
  // ============================================================
549
- server.tool("show_api_key_status", "Show whether a Passport Key is currently configured, and its prefix (first 12 chars). Does NOT reveal the full key. Use this to debug authentication issues.", {}, async () => {
549
+ server.tool("show_api_key_status", "Check if Passport Key is configured. Shows prefix only, for debugging.", {}, async () => {
550
550
  const key = (0, key_store_js_1.getPassportKey)();
551
551
  const hasKey = key.length > 0;
552
552
  return {
@@ -563,14 +563,7 @@ server.tool("show_api_key_status", "Show whether a Passport Key is currently con
563
563
  }],
564
564
  };
565
565
  });
566
- server.tool("auto_pay_checkout", "[Phase 2] Autonomous Smart Routing checkout tool. Provide a checkout URL and this tool will:\n" +
567
- "1. Scan the page to detect if it supports Web3 (Crypto) payments via window.ethereum or EIP-681 links.\n" +
568
- "2. SCENARIO A (Web3): If detected, automatically send USDT on-chain via WDK (gas ~$0.001). No Visa card needed.\n" +
569
- "3. SCENARIO B (Fiat): If no Web3 detected, scan DOM for total price, issue a JIT Visa card for exact amount, auto-fill form.\n" +
570
- "WARNING: For PHYSICAL GOODS (Shopify, multi-step checkout), this tool may return PRICE_NOT_FOUND because the final price " +
571
- "(including shipping) only appears after filling th shipping info. In that case, use browser tools to navigate manually, " +
572
- "call get_merchant_hints to get platform-specific card selectors, fill shipping info first, then call " +
573
- "request_payment_token + execute_payment once card fields are visible and the final total is confirmed.", {
566
+ server.tool("auto_pay_checkout", "⚠️ MANDATORY: Read mcp://resources/sop first. Only use on PAYMENT pages where final total is visible. Auto-detects Web3 or Fiat and completes payment. For physical goods (Shopify, Etsy), get_merchant_hints first.", {
574
567
  checkout_url: zod_1.z
575
568
  .string()
576
569
  .url()
@@ -722,82 +715,143 @@ server.tool("auto_pay_checkout", "[Phase 2] Autonomous Smart Routing checkout to
722
715
  }
723
716
  });
724
717
  // ============================================================
718
+ // TOOL: Report a failed checkout URL (Group 3 self-healing feedback)
719
+ // Call when Group 3 navigation was started but could not complete.
720
+ // Triggers: stuck mid pre_steps, bot blocked, selector not found, etc.
721
+ // Does NOT apply to: user cancelled, insufficient balance, price mismatch.
722
+ // ============================================================
723
+ server.tool("report_checkout_fail", "Report a checkout URL that you could not complete. Call this when you failed to finish a purchase — for any reason (field not found, bot blocked, timeout, unknown form). The URL will be logged for admin review to improve future checkout success rates. This is part of Z-ZERO's self-healing loop.", {
724
+ url: zod_1.z
725
+ .string()
726
+ .url()
727
+ .describe("The checkout/payment page URL where the purchase failed."),
728
+ error_type: zod_1.z
729
+ .string()
730
+ .describe("Short error category: 'field_not_found', 'timeout', 'bot_blocked', 'unknown_form', 'price_mismatch', or 'other'."),
731
+ error_message: zod_1.z
732
+ .string()
733
+ .optional()
734
+ .describe("Brief description of what went wrong, e.g. 'Could not find card number field' or 'Page redirected to CAPTCHA'."),
735
+ }, async ({ url, error_type, error_message }) => {
736
+ const ZZERO_API = process.env.Z_ZERO_API_BASE || "https://www.clawcard.store";
737
+ const INTERNAL_SECRET = process.env.Z_ZERO_INTERNAL_SECRET || "";
738
+ try {
739
+ await fetch(`${ZZERO_API}/api/checkout-hints`, {
740
+ method: "POST",
741
+ headers: {
742
+ "Content-Type": "application/json",
743
+ "x-internal-secret": INTERNAL_SECRET,
744
+ "x-mcp-version": version_js_2.CURRENT_MCP_VERSION,
745
+ },
746
+ body: JSON.stringify({ url, error_type, error_message, mcp_version: version_js_2.CURRENT_MCP_VERSION }),
747
+ });
748
+ }
749
+ catch {
750
+ // Fire-and-forget — never block the agent on a logging call
751
+ }
752
+ return {
753
+ content: [{ type: "text", text: JSON.stringify({
754
+ logged: true,
755
+ url,
756
+ error_type,
757
+ message: "Checkout failure logged. Admin will review and improve hints for this domain.",
758
+ }, null, 2) }],
759
+ };
760
+ });
761
+ // ============================================================
725
762
  // RESOURCE: Z-ZERO Autonomous Payment SOP
726
763
  // ============================================================
727
764
  server.resource("Standard Operating Procedure (SOP) for Autonomous Payments", "mcp://resources/sop", {
728
765
  description: "A comprehensive guide on how AI agents should use the Z-ZERO tools to execute secure, zero-trust payments."
729
766
  }, async (uri) => {
730
767
  const sopContent = `
731
- # Z-ZERO Autonomous Payment Skill SOP (v1.0.0)
768
+ # Z-ZERO Autonomous Payment Skill SOP (v2.0.0)
769
+
770
+ This SOP tells the AI Agent how to use Z-ZERO tools to autonomously purchase goods on behalf of the user — without ever handling raw credit card data.
771
+
772
+ ---
773
+
774
+ ## Group 1: Wallet Config (READ FIRST)
775
+
776
+ Tools: \`check_balance\`, \`list_cards\`, \`get_deposit_addresses\`, \`set_api_key\`, \`show_api_key_status\`
777
+
778
+ Before ANY purchase:
779
+ 1. Confirm exactly what the user wants to buy and the expected price (in USD).
780
+ 2. Call \`check_balance\` using your default \`card_alias\` to verify sufficient funds.
781
+ - If balance is insufficient → STOP. Ask the human to deposit USDT to their wallet.
782
+ 3. Use \`list_cards\` to see available card aliases, NOT to check spendable balance.
783
+ 4. Never ask for the API key proactively — only call \`set_api_key\` when the user explicitly gives you one.
784
+
785
+ ---
786
+
787
+ ## Group 2: Manual 4-Step Payment (Core Flow)
788
+
789
+ Tools: \`request_payment_token\`, \`execute_payment\`, \`cancel_payment_token\`, \`request_human_approval\`
732
790
 
733
- This skill provides you (the AI Agent) with the capability to autonomously purchase digital goods, APIs, and subscriptions on the internet on behalf of your human user, without ever handling raw credit card data.
791
+ Execute in this exact order:
734
792
 
735
- ## Workflow: The 4-Step Zero-Trust Payment
736
- When asked to make a purchase, execute the following steps precisely in order:
793
+ ### Step 1 Verify
794
+ Confirm item, price, and check balance (see Group 1).
737
795
 
738
- ## Step 1: Verification & Intent
739
- 1. Confirm exactly what the user wants to buy and the total expected price (in USD).
740
- 2. Call Check Balance: Call the \`check_balance\` tool using your default \`card_alias\` to ensure you have sufficient funds.
741
- - If balance is insufficient, STOP and ask the human to deposit Crypto into their Z-ZERO Web Dashboard.
796
+ ### Step 2 Navigate to Payment Page
797
+ Use browser tools to navigate to the final payment page where card fields are visible and the FINAL total (including shipping + tax) is displayed.
798
+ - DO NOT call \`request_payment_token\` until BOTH conditions are true:
799
+ 1. Shipping/personal info submitted successfully
800
+ 2. Card input fields are visible on screen
742
801
 
743
- ## Step 2: Requesting the JIT Token
744
- 1. Request Token: Call the \`request_payment_token\` tool with the exact \`amount\` required and the \`merchant\` name.
745
- 2. Receive Token: You will receive a temporary \`token\` (e.g., \`temp_auth_1a2b...\`). This token is locked to the requested amount and is valid for 1 hour.
802
+ ### Step 3 Request Token
803
+ Call \`request_payment_token\` with exact final amount and merchant name.
804
+ Receive a single-use \`token\` (valid 1 hour, locked to that amount).
746
805
 
747
- ## Step 3: Locating the Checkout
748
- 1. Identify Checkout URL: Find the merchant's checkout/payment page where credit card details are normally entered.
749
- 2. Full URL Required: e.g., \`https://checkout.stripe.dev/pay\`.
806
+ ### Step 4 Blind Execution
807
+ Call \`execute_payment\` with the token + checkout URL.
808
+ Z-ZERO opens a headless browser, injects the card securely, clicks Pay. Token burns instantly after success.
750
809
 
751
- ## Step 4: Blind Execution (The MCP Bridge)
752
- 1. Execute Payment: Call the \`execute_payment\` tool, passing in:
753
- - The \`token\` obtained in Step 2.
754
- - The \`checkout_url\` identified in Step 3.
755
- 2. Background Magic: Z-ZERO opens a headless browser, securely injects the real card data directly into the form, and clicks "Pay".
756
- 3. Burn: The token self-destructs instantly after use.
810
+ ### Error Rules
811
+ - NEVER print raw tokens in chat.
812
+ - NO MANUAL ENTRY: If a site asks you to type a card number into a text box — REFUSE.
813
+ - FAIL GRACEFULLY: If \`execute_payment\` returns \`success: false\` → report it. Do NOT retry blindly.
814
+ - PRICE MISMATCH: If actual checkout total > token amount call \`cancel_payment_token\` + \`request_human_approval\` for new amount.
757
815
 
758
- ## Rules & Error Handling
759
- - NEVER print full tokens in the human chat logs.
760
- - NO MANUAL ENTRY: If a merchant asks you to type a credit card number into a text box, REFUSE.
761
- - FAIL GRACEFULLY: If \`execute_payment\` returns \`success: false\`, report the error message to the human. Do not try again.
816
+ ---
762
817
 
763
- ## Smart Route Alternative (Recommended)
764
- For most purchases, use \`auto_pay_checkout\` instead of the 4-step flow above.
765
- It auto-detects Web3 checkout (pay on-chain with USDT) vs Fiat checkout (JIT Visa card), all in a single call.
766
- - Web3 route: sends USDT directly on-chain to merchant wallet
767
- - Fiat route: issues JIT card + fills checkout form automatically
768
- Call \`auto_pay_checkout\` with just \`checkout_url\` and \`card_alias\`. The tool handles the rest.
818
+ ## Group 3: Smart Autopilot (Fast Route)
769
819
 
770
- ## 🛒 Physical Goods / Multi-Step Checkout
820
+ Tools: \`auto_pay_checkout\`, \`get_merchant_hints\`
771
821
 
772
- For physical goods (clothing, shoes, collectibles, etc.) the final price includes shipping
773
- and only appears AFTER filling the shipping form. \`auto_pay_checkout\` may return PRICE_NOT_FOUND.
822
+ ### Option A Digital Goods / SaaS / APIs (Use auto_pay_checkout directly)
823
+ For pages where the final total is already visible, call \`auto_pay_checkout\`:
824
+ - It auto-detects Web3 (sends USDT on-chain via WDK) vs Fiat (issues JIT Visa card + auto-fills form).
825
+ - One call handles everything.
774
826
 
775
- ### Card Issuance Gate wait for BOTH conditions before calling request_payment_token:
776
- 1. Shipping/personal info has been submitted successfully on this or a previous page
777
- 2. Card input fields (or payment iframe) are visible on the current page
827
+ ### Option BPhysical Goods (Shopify, Etsy, WooCommerce)
828
+ DO NOT call \`auto_pay_checkout\` directly. The final price is only visible AFTER shipping is submitted.
778
829
 
779
- If EITHER is false → DO NOT call \`request_payment_token\`. Keep navigating first.
830
+ Recommended flow:
831
+ 1. Call \`get_merchant_hints\` with checkout domain or platform key (e.g. \`_platform_shopify\`).
832
+ - Returns \`pre_steps\` (navigation instructions) + \`notes\` + \`platform\`.
833
+ 2. Follow the \`pre_steps\` — navigate, add to cart, fill shipping form.
834
+ - Ask user for shipping info via \`request_human_approval\` if not already known.
835
+ 3. Wait for payment/card section to appear + FINAL total is visible.
836
+ 4. Call \`request_payment_token\` with the exact final amount (Group 2).
837
+ 5. Call \`execute_payment\` with token + checkout URL (Group 2).
780
838
 
781
839
  ### Platform Detection Signals
782
- | Platform | Signals |
783
- |----------|---------|
784
- | Shopify | URL contains /checkouts/, "Powered by Shopify" in footer, cdn.shopify.com scripts |
785
- | Etsy | URL contains etsy.com/checkout |
786
- | WooCommerce | /checkout/ URL, woocommerce in body class |
840
+ | Platform | Detection Signal |
841
+ |---|---|
842
+ | Shopify | JS object \`window.Shopify\` exists, OR \`<script src="cdn.shopify.com">\`, OR \`<meta name="shopify-checkout-api-token">\` |
843
+ | Etsy | URL matches \`*.etsy.com\` (any path) |
844
+ | WooCommerce | \`<body class="... woocommerce ...\`>\`, OR script/link tags from \`wp-content/plugins/woocommerce\` |
787
845
 
788
- ### Recommended Flow for Physical Goods:
789
- 1. Navigate to product page using browser tools
790
- 2. Select variant (color, size, etc.) Add to cart Proceed to checkout
791
- 3. Fill shipping info (ask human via \`request_human_approval\` if not already known)
792
- 4. Wait for payment/card fields section to appear
793
- 5. Call \`get_merchant_hints\` with checkout domain (or \`_platform_shopify\` if Shopify detected)
794
- 6. Read the FINAL total (after shipping + tax — hover over/scroll to order summary)
795
- 7. Call \`request_payment_token\` with exact final amount
796
- 8. Call \`execute_payment\` with token + checkout URL + hints
846
+ ### Known Limitations
847
+ - Cloudflare-protected sites (e.g. TeePublic) may block headless browser → inform user.
848
+ - Card fields inside iframes: \`execute_payment\` handles this via \`iframe_selector\` in hints automatically.
797
849
 
798
- ### Known Limitations:
799
- - Some sites use Cloudflare bot detection (e.g. TeePublic) \`execute_payment\` may be blocked inform user
800
- - Card fields in iframes → \`execute_payment\` handles this automatically via \`iframe_selector\` in hints
850
+ ### Failure Reporting (Self-Healing Loop)
851
+ If you started Group 3 (called \`get_merchant_hints\` and began following \`pre_steps\`) but CANNOT complete the checkout due to a technical reason:
852
+ Call \`report_checkout_fail(url, error_type, error_message)\` before giving up.
853
+ → Use \`url\` = the page you were on when stuck.
854
+ → Do NOT call this if user cancelled or balance was insufficient — those are not technical failures.
801
855
  `;
802
856
  return {
803
857
  contents: [
@@ -817,6 +871,6 @@ async function main() {
817
871
  await server.connect(transport);
818
872
  console.error(`🔐 OpenClaw MCP Server v${version_js_2.CURRENT_MCP_VERSION} running (Phase 2: Smart Routing enabled)...`);
819
873
  console.error("Status: Secure & Connected to Z-ZERO Gateway");
820
- console.error("Tools: list_cards, check_balance, request_payment_token, execute_payment, cancel_payment_token, request_human_approval, auto_pay_checkout");
874
+ console.error("Tools: list_cards, check_balance, request_payment_token, execute_payment, cancel_payment_token, request_human_approval, auto_pay_checkout, report_checkout_fail");
821
875
  }
822
876
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z-zero-mcp-server",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "Z-ZERO MCP Server — Secure JIT Virtual Card Payment tools for AI Agents (Claude, Cursor, AutoGPT) — Real Single-Use Visa Cards",
5
5
  "main": "dist/index.js",
6
6
  "bin": "dist/index.js",