z-zero-mcp-server 1.6.1 → 1.8.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.
- package/README.md +75 -4
- package/dist/{wdk_backend.d.ts → base_backend.d.ts} +18 -1
- package/dist/{wdk_backend.js → base_backend.js} +117 -36
- package/dist/failure_taxonomy.d.ts +48 -0
- package/dist/failure_taxonomy.js +130 -0
- package/dist/index.js +323 -114
- package/dist/lib/api-base.d.ts +2 -0
- package/dist/lib/api-base.js +51 -0
- package/dist/lib/key-store.js +1 -1
- package/dist/lib/web3-detector.js +3 -3
- package/dist/types.d.ts +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// api-base.ts
|
|
3
|
+
// One place that decides which host this MCP server talks to.
|
|
4
|
+
//
|
|
5
|
+
// Why this exists: the move to z-zero.xyz left older installs pointing at
|
|
6
|
+
// zzero.xyz, which now answers 308 → https://z-zero.xyz. Node's fetch follows
|
|
7
|
+
// that redirect but DROPS the Authorization header on a cross-origin hop, so
|
|
8
|
+
// the API sees no key and answers 401 "Unauthorized". The result is the worst
|
|
9
|
+
// kind of failure — a perfectly valid Passport Key that looks revoked, on every
|
|
10
|
+
// single tool, with the docs telling the user to go make another one.
|
|
11
|
+
//
|
|
12
|
+
// Rewriting the known legacy hosts here fixes it for every call site at once.
|
|
13
|
+
// We never re-send the key to a redirect target ourselves: that is how a key
|
|
14
|
+
// leaks to whatever host a redirect happens to name.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.resolveApiBaseUrl = resolveApiBaseUrl;
|
|
17
|
+
const CANONICAL = "https://z-zero.xyz";
|
|
18
|
+
// Hosts that 30x to CANONICAL. Same origin in spirit, different origin to fetch.
|
|
19
|
+
// clawcard.store is the pre-rebrand domain and is still in real configs.
|
|
20
|
+
const LEGACY_HOSTS = new Set([
|
|
21
|
+
"zzero.xyz",
|
|
22
|
+
"www.zzero.xyz",
|
|
23
|
+
"www.z-zero.xyz",
|
|
24
|
+
"clawcard.store",
|
|
25
|
+
"www.clawcard.store",
|
|
26
|
+
]);
|
|
27
|
+
let warned = false;
|
|
28
|
+
/** The base URL every request should use, with legacy hosts corrected. */
|
|
29
|
+
function resolveApiBaseUrl() {
|
|
30
|
+
const raw = (process.env.Z_ZERO_API_BASE_URL ||
|
|
31
|
+
process.env.Z_ZERO_API_BASE ||
|
|
32
|
+
CANONICAL).trim();
|
|
33
|
+
let url;
|
|
34
|
+
try {
|
|
35
|
+
url = new URL(raw);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
console.error(`[Z-ZERO MCP] ⚠️ Z_ZERO_API_BASE_URL is not a valid URL ("${raw}") — using ${CANONICAL}.`);
|
|
39
|
+
return CANONICAL;
|
|
40
|
+
}
|
|
41
|
+
if (LEGACY_HOSTS.has(url.hostname)) {
|
|
42
|
+
if (!warned) {
|
|
43
|
+
warned = true;
|
|
44
|
+
console.error(`[Z-ZERO MCP] ⚠️ Z_ZERO_API_BASE_URL points at ${url.hostname}, which redirects to z-zero.xyz. ` +
|
|
45
|
+
`A cross-origin redirect strips the Authorization header, so every call would fail as 401. ` +
|
|
46
|
+
`Using ${CANONICAL} instead — please update your MCP config.`);
|
|
47
|
+
}
|
|
48
|
+
return CANONICAL;
|
|
49
|
+
}
|
|
50
|
+
return raw.replace(/\/$/, "");
|
|
51
|
+
}
|
package/dist/lib/key-store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// key-store.ts
|
|
3
3
|
// Shared, mutable in-memory store for the Passport Key (Z_ZERO_API_KEY).
|
|
4
|
-
// All API backends
|
|
4
|
+
// All API backends import getPassportKey() from here
|
|
5
5
|
// so a single set_api_key MCP tool updates the key for ALL backends at once.
|
|
6
6
|
//
|
|
7
7
|
// v1.5.0: keys are also persisted to ~/.z-zero/credentials (chmod 600).
|
|
@@ -31,14 +31,14 @@ async function detectWeb3Payment(page, checkoutUrl) {
|
|
|
31
31
|
return "8453";
|
|
32
32
|
if (method === "eth_sendTransaction") {
|
|
33
33
|
const tx = params?.[0];
|
|
34
|
-
window["
|
|
34
|
+
window["__zzCapturedTx"] = tx;
|
|
35
35
|
return "0xdeadbeef00000000000000000000000000000000000000000000000000000001";
|
|
36
36
|
}
|
|
37
37
|
if (method === "wallet_switchEthereumChain")
|
|
38
38
|
return null;
|
|
39
39
|
if (method === "eth_getBalance")
|
|
40
40
|
return "0x0";
|
|
41
|
-
window["
|
|
41
|
+
window["__zzUnknownMethod_" + method] = true;
|
|
42
42
|
return null;
|
|
43
43
|
},
|
|
44
44
|
on: (event, handler) => {
|
|
@@ -120,7 +120,7 @@ async function detectWeb3Payment(page, checkoutUrl) {
|
|
|
120
120
|
const start = Date.now();
|
|
121
121
|
while (Date.now() - start < WEB3_DETECT_TIMEOUT_MS) {
|
|
122
122
|
const tx = await page.evaluate(() => {
|
|
123
|
-
return window["
|
|
123
|
+
return window["__zzCapturedTx"] ?? null;
|
|
124
124
|
});
|
|
125
125
|
if (tx) {
|
|
126
126
|
const capturedTx = tx;
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "z-zero-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
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": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"start": "node dist/index.js",
|
|
12
12
|
"dev": "npx tsx src/index.ts",
|
|
13
|
+
"test:mock-checkout": "npm run build && node --experimental-strip-types tests/backtest_mock_checkout_e2e.mts",
|
|
13
14
|
"prepublishOnly": "npm run build"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|