x402-proxy 0.11.2 → 0.11.4

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 CHANGED
@@ -1,53 +1,37 @@
1
1
  # x402-proxy
2
2
 
3
- `curl` for [x402](https://www.x402.org/) and [MPP](https://mpp.dev/) paid APIs. Auto-pays HTTP 402 responses with USDC on Base, Solana, and [Tempo](https://tempo.xyz/) - zero crypto code on the buyer side. Supports one-time payments (x402, MPP charge) and pay-per-token streaming (MPP sessions).
3
+ [![npm version](https://img.shields.io/npm/v/x402-proxy.svg?style=flat-square)](https://www.npmjs.com/package/x402-proxy)
4
+ [![license](https://img.shields.io/npm/l/x402-proxy.svg?style=flat-square)](LICENSE)
5
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
6
 
5
- ## Quick Start
7
+ curl for x402 and MPP paid APIs with MCP proxy support. Auto-pays HTTP 402 on Base, Solana, and Tempo.
6
8
 
7
- ```bash
8
- npx x402-proxy https://surf.cascade.fyi/api/v1/twitter/user/openclaw
9
- ```
10
-
11
- That's it. The endpoint returns 402, x402-proxy pays and streams the response.
9
+ Zero crypto code on the buyer side. One mnemonic derives both EVM (Base/Tempo) and Solana keypairs - fund any chain and go. Supports one-time payments (x402, MPP charge) and pay-per-token streaming (MPP sessions). Use it as a CLI, an MCP proxy for AI agents, or as a Node.js library.
12
10
 
13
- No wallet? It'll walk you through setup automatically. One mnemonic derives both EVM (Base/Tempo) and Solana keypairs. Fund any chain and go.
11
+ ## Table of Contents
14
12
 
15
- ## MCP Proxy
13
+ - [Install](#install)
14
+ - [Usage](#usage)
15
+ - [Commands](#commands)
16
+ - [MCP Proxy](#mcp-proxy)
17
+ - [Wallet](#wallet)
18
+ - [Env Vars](#env-vars)
19
+ - [Library Usage](#library-usage)
20
+ - [OpenClaw Plugin](#openclaw-plugin)
21
+ - [Contributing](#contributing)
22
+ - [License](#license)
16
23
 
17
- Let your AI agent consume any paid MCP server.
18
-
19
- ### Quick setup
24
+ ## Install
20
25
 
21
26
  ```bash
22
- npx x402-proxy mcp add surf https://surf.cascade.fyi/mcp
23
- ```
24
-
25
- Auto-detects installed AI clients (Claude Code, Cursor, VS Code, and 16+ others), shows a config preview, and writes it for you. Runs wallet setup if needed.
26
-
27
- ### Manual config
28
-
29
- Or add to your client config directly:
30
-
31
- ```json
32
- {
33
- "mcpServers": {
34
- "surf": {
35
- "command": "npx",
36
- "args": ["-y", "x402-proxy", "mcp", "https://surf.cascade.fyi/mcp"]
37
- }
38
- }
39
- }
27
+ npx x402-proxy https://surf.cascade.fyi/api/v1/twitter/user/openclaw
40
28
  ```
41
29
 
42
- The proxy auto-generates a wallet on first run and uses `~/.config/x402-proxy/wallet.json`. No env vars needed. Your agent never touches crypto.
43
-
44
- For OpenClaw:
30
+ That's it. The endpoint returns 402, x402-proxy pays and streams the response.
45
31
 
46
- ```bash
47
- openclaw mcp set surf '{"command":"npx","args":["-y","x402-proxy","mcp","https://surf.cascade.fyi/mcp"]}'
48
- ```
32
+ No wallet? It'll walk you through setup automatically. One mnemonic derives both EVM (Base/Tempo) and Solana keypairs. Fund any chain and go.
49
33
 
50
- ## HTTP Requests
34
+ ## Usage
51
35
 
52
36
  Works like curl. Response body streams to stdout, payment info goes to stderr.
53
37
 
@@ -97,6 +81,41 @@ $ npx x402-proxy wallet export-key <target> # bare key/mnemonic to stdout (evm|s
97
81
 
98
82
  All commands support `--help` for details. Use `-c <dir>` to override the config directory.
99
83
 
84
+ ## MCP Proxy
85
+
86
+ Let your AI agent consume any paid MCP server.
87
+
88
+ ### Quick setup
89
+
90
+ ```bash
91
+ npx x402-proxy mcp add surf https://surf.cascade.fyi/mcp
92
+ ```
93
+
94
+ Auto-detects installed AI clients (Claude Code, Cursor, VS Code, and 16+ others), shows a config preview, and writes it for you. Runs wallet setup if needed.
95
+
96
+ ### Manual config
97
+
98
+ Or add to your client config directly:
99
+
100
+ ```json
101
+ {
102
+ "mcpServers": {
103
+ "surf": {
104
+ "command": "npx",
105
+ "args": ["-y", "x402-proxy", "mcp", "https://surf.cascade.fyi/mcp"]
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ The proxy auto-generates a wallet on first run and uses `~/.config/x402-proxy/wallet.json`. No env vars needed. Your agent never touches crypto.
112
+
113
+ For OpenClaw:
114
+
115
+ ```bash
116
+ openclaw mcp set surf '{"command":"npx","args":["-y","x402-proxy","mcp","https://surf.cascade.fyi/mcp"]}'
117
+ ```
118
+
100
119
  ## Wallet
101
120
 
102
121
  A single BIP-39 mnemonic derives both chains:
@@ -143,7 +162,7 @@ See the [library API docs](https://github.com/cascade-protocol/x402-proxy/tree/m
143
162
 
144
163
  ## OpenClaw Plugin
145
164
 
146
- The OpenClaw plugin now ships as a separate npm package: `x402-proxy-openclaw`.
165
+ The OpenClaw plugin ships as a separate npm package: `x402-proxy-openclaw`.
147
166
 
148
167
  ```bash
149
168
  openclaw plugins install x402-proxy-openclaw
@@ -155,6 +174,10 @@ By default, the plugin registers a built-in `surf` provider at `/x402-proxy/v1`
155
174
 
156
175
  For MPP-backed inference, make sure the wallet source includes an EVM key as well as Solana. `npx x402-proxy setup` does this automatically.
157
176
 
177
+ ## Contributing
178
+
179
+ PRs welcome. Feel free to [open an issue](https://github.com/cascade-protocol/x402-proxy/issues) for bug reports or feature requests.
180
+
158
181
  ## License
159
182
 
160
- Apache-2.0
183
+ [Apache-2.0](LICENSE) (c) Cascade Protocol
package/dist/bin/cli.js CHANGED
@@ -4,7 +4,7 @@ import { C as run, S as buildRouteMap, _ as base58, a as getDebugLogPath, b as b
4
4
  import { C as warn, S as success, _ as decodePaymentResponseHeader, b as info, c as resolveWallet, d as displayNetwork, f as formatAmount, g as wrapFetchWithPayment, h as readHistory, l as appendHistory, m as formatUsdcValue, n as fetchAllBalances, o as walletInfoCommand, p as formatTxLine, s as buildX402Client, u as calcSpend, v as dim, x as isTTY, y as error } from "../wallet-CUCoLEqs.js";
5
5
  import { i as deserializeSessionReceipt, n as tempo, o as parseUnits, r as parseEvent, t as create } from "../client-DqtxTnu6.js";
6
6
  import { t as privateKeyToAccount } from "../accounts-D9KsVVpJ.js";
7
- import { a as Nt, c as Wt, i as Jt, l as Ct, n as setupCommand, o as R, r as Gt, s as Rt, t as runSetup } from "../setup-q91MbrZT.js";
7
+ import { a as Nt, c as Wt, i as Jt, l as Ct, n as setupCommand, o as R, r as Gt, s as Rt, t as runSetup } from "../setup-C10O8N36.js";
8
8
  import { n as statusCommand } from "../status-DjZdIeES.js";
9
9
  import { dirname, join, normalize, resolve } from "node:path";
10
10
  import { spawn } from "node:child_process";
@@ -17,9 +17,9 @@ import { homedir } from "node:os";
17
17
  const DEFAULT_SURF_PROVIDER_ID = "surf";
18
18
  const DEFAULT_SURF_BASE_URL = "/x402-proxy/v1";
19
19
  const DEFAULT_SURF_UPSTREAM_URL = "https://surf.cascade.fyi/api/v1/inference";
20
- const DEFAULT_SURF_MODELS = [
21
- {
22
- id: "anthropic/claude-opus-4.6",
20
+ /** Known model metadata for cost/capability enrichment. */
21
+ const MODEL_METADATA = {
22
+ "anthropic/claude-opus-4.6": {
23
23
  name: "Claude Opus 4.6",
24
24
  maxTokens: 2e5,
25
25
  reasoning: true,
@@ -32,8 +32,20 @@ const DEFAULT_SURF_MODELS = [
32
32
  },
33
33
  contextWindow: 2e5
34
34
  },
35
- {
36
- id: "anthropic/claude-sonnet-4.6",
35
+ "anthropic/claude-opus-4.5": {
36
+ name: "Claude Opus 4.5",
37
+ maxTokens: 2e5,
38
+ reasoning: true,
39
+ input: ["text", "image"],
40
+ cost: {
41
+ input: .015,
42
+ output: .075,
43
+ cacheRead: .0015,
44
+ cacheWrite: .01875
45
+ },
46
+ contextWindow: 2e5
47
+ },
48
+ "anthropic/claude-sonnet-4.6": {
37
49
  name: "Claude Sonnet 4.6",
38
50
  maxTokens: 2e5,
39
51
  reasoning: true,
@@ -46,8 +58,20 @@ const DEFAULT_SURF_MODELS = [
46
58
  },
47
59
  contextWindow: 2e5
48
60
  },
49
- {
50
- id: "x-ai/grok-4.20-beta",
61
+ "anthropic/claude-sonnet-4.5": {
62
+ name: "Claude Sonnet 4.5",
63
+ maxTokens: 2e5,
64
+ reasoning: true,
65
+ input: ["text", "image"],
66
+ cost: {
67
+ input: .003,
68
+ output: .015,
69
+ cacheRead: 3e-4,
70
+ cacheWrite: .00375
71
+ },
72
+ contextWindow: 2e5
73
+ },
74
+ "x-ai/grok-4.20-beta": {
51
75
  name: "Grok 4.20 Beta",
52
76
  maxTokens: 131072,
53
77
  reasoning: true,
@@ -60,8 +84,33 @@ const DEFAULT_SURF_MODELS = [
60
84
  },
61
85
  contextWindow: 131072
62
86
  },
63
- {
64
- id: "minimax/minimax-m2.5",
87
+ "x-ai/grok-4.1-fast": {
88
+ name: "Grok 4.1 Fast",
89
+ maxTokens: 131072,
90
+ reasoning: false,
91
+ input: ["text"],
92
+ cost: {
93
+ input: .001,
94
+ output: .005,
95
+ cacheRead: 0,
96
+ cacheWrite: 0
97
+ },
98
+ contextWindow: 131072
99
+ },
100
+ "minimax/minimax-m2.7": {
101
+ name: "MiniMax M2.7",
102
+ maxTokens: 1e6,
103
+ reasoning: false,
104
+ input: ["text"],
105
+ cost: {
106
+ input: .001,
107
+ output: .005,
108
+ cacheRead: 0,
109
+ cacheWrite: 0
110
+ },
111
+ contextWindow: 1e6
112
+ },
113
+ "minimax/minimax-m2.5": {
65
114
  name: "MiniMax M2.5",
66
115
  maxTokens: 1e6,
67
116
  reasoning: false,
@@ -74,8 +123,7 @@ const DEFAULT_SURF_MODELS = [
74
123
  },
75
124
  contextWindow: 1e6
76
125
  },
77
- {
78
- id: "moonshotai/kimi-k2.5",
126
+ "moonshotai/kimi-k2.5": {
79
127
  name: "Kimi K2.5",
80
128
  maxTokens: 131072,
81
129
  reasoning: true,
@@ -88,8 +136,7 @@ const DEFAULT_SURF_MODELS = [
88
136
  },
89
137
  contextWindow: 131072
90
138
  },
91
- {
92
- id: "z-ai/glm-5",
139
+ "z-ai/glm-5": {
93
140
  name: "GLM-5",
94
141
  maxTokens: 128e3,
95
142
  reasoning: false,
@@ -101,8 +148,85 @@ const DEFAULT_SURF_MODELS = [
101
148
  cacheWrite: 0
102
149
  },
103
150
  contextWindow: 128e3
151
+ },
152
+ "z-ai/glm-5-turbo": {
153
+ name: "GLM-5 Turbo",
154
+ maxTokens: 128e3,
155
+ reasoning: false,
156
+ input: ["text"],
157
+ cost: {
158
+ input: .001,
159
+ output: .005,
160
+ cacheRead: 0,
161
+ cacheWrite: 0
162
+ },
163
+ contextWindow: 128e3
164
+ },
165
+ "qwen/qwen-2.5-7b-instruct": {
166
+ name: "Qwen 2.5 7B Instruct",
167
+ maxTokens: 32768,
168
+ reasoning: false,
169
+ input: ["text"],
170
+ cost: {
171
+ input: 5e-4,
172
+ output: .002,
173
+ cacheRead: 0,
174
+ cacheWrite: 0
175
+ },
176
+ contextWindow: 131072
177
+ },
178
+ "stepfun/step-3.5-flash": {
179
+ name: "Step 3.5 Flash",
180
+ maxTokens: 131072,
181
+ reasoning: false,
182
+ input: ["text"],
183
+ cost: {
184
+ input: .001,
185
+ output: .005,
186
+ cacheRead: 0,
187
+ cacheWrite: 0
188
+ },
189
+ contextWindow: 131072
190
+ },
191
+ "xiaomi/mimo-v2-pro": {
192
+ name: "MiMo V2 Pro",
193
+ maxTokens: 131072,
194
+ reasoning: true,
195
+ input: ["text"],
196
+ cost: {
197
+ input: .001,
198
+ output: .005,
199
+ cacheRead: 0,
200
+ cacheWrite: 0
201
+ },
202
+ contextWindow: 131072
104
203
  }
105
- ];
204
+ };
205
+ const DEFAULT_CONTEXT_WINDOW = 131072;
206
+ const ZERO_COST = {
207
+ input: 0,
208
+ output: 0,
209
+ cacheRead: 0,
210
+ cacheWrite: 0
211
+ };
212
+ function modelFromId(id) {
213
+ const known = MODEL_METADATA[id];
214
+ if (known) return {
215
+ id,
216
+ ...known
217
+ };
218
+ return {
219
+ id,
220
+ name: (id.split("/").pop() ?? id).replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()),
221
+ maxTokens: DEFAULT_CONTEXT_WINDOW,
222
+ reasoning: false,
223
+ input: ["text"],
224
+ cost: ZERO_COST,
225
+ contextWindow: DEFAULT_CONTEXT_WINDOW
226
+ };
227
+ }
228
+ /** Static fallback models used when upstream fetch fails. */
229
+ const DEFAULT_SURF_MODELS = Object.keys(MODEL_METADATA).map(modelFromId);
106
230
  function resolveProviders(config) {
107
231
  const defaultProtocol = resolveProtocol(config.protocol);
108
232
  const defaultMppSessionBudget = resolveMppSessionBudget(config.mppSessionBudget);
@@ -1184,7 +1308,7 @@ async function resolveWalletForServe(flags) {
1184
1308
  solanaKey: flags.solanaKey
1185
1309
  });
1186
1310
  if (wallet.source !== "none") return wallet;
1187
- const { runSetup } = await import("../setup-DPuLACk7.js");
1311
+ const { runSetup } = await import("../setup-BdSfEdx4.js");
1188
1312
  if (isTTY()) {
1189
1313
  dim(" No wallet found. Let's set one up first.\n");
1190
1314
  await runSetup();
@@ -1825,7 +1949,7 @@ Examples:
1825
1949
  process.exit(1);
1826
1950
  }
1827
1951
  dim(" No wallet found. Let's set one up first.\n");
1828
- const { runSetup } = await import("../setup-DPuLACk7.js");
1952
+ const { runSetup } = await import("../setup-BdSfEdx4.js");
1829
1953
  await runSetup();
1830
1954
  console.log();
1831
1955
  wallet = resolveWallet();
@@ -2258,7 +2382,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2258
2382
  });
2259
2383
  if (wallet.source === "none") {
2260
2384
  dim("No wallet found. Auto-generating...");
2261
- const { runSetup } = await import("../setup-DPuLACk7.js");
2385
+ const { runSetup } = await import("../setup-BdSfEdx4.js");
2262
2386
  await runSetup({ nonInteractive: true });
2263
2387
  const fresh = resolveWallet({
2264
2388
  evmKey: flags.evmKey,
@@ -2279,7 +2403,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2279
2403
  const { SSEClientTransport } = await import("../sse-kba68iqF.js");
2280
2404
  const { StreamableHTTPClientTransport } = await import("../streamableHttp-DRntYTFN.js");
2281
2405
  const { Server } = await import("../server-Dbsk9dql.js");
2282
- const { StdioServerTransport } = await import("../stdio-BCoJJXun.js");
2406
+ const { StdioServerTransport } = await import("../stdio-CdmkLt8r.js");
2283
2407
  const { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ToolListChangedNotificationSchema, ResourceListChangedNotificationSchema } = await import("../types-DH9rDVeP.js");
2284
2408
  async function connectTransport(target) {
2285
2409
  try {
@@ -2321,7 +2445,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2321
2445
  }
2322
2446
  const remoteClient = new Client({
2323
2447
  name: "x402-proxy",
2324
- version: "0.11.2"
2448
+ version: "0.11.4"
2325
2449
  });
2326
2450
  await connectTransport(remoteClient);
2327
2451
  function recordX402Payment(ctx) {
@@ -2352,7 +2476,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2352
2476
  }
2353
2477
  const localServer = new Server({
2354
2478
  name: "x402-proxy",
2355
- version: "0.11.2"
2479
+ version: "0.11.4"
2356
2480
  }, { capabilities: {
2357
2481
  tools: tools.length > 0 ? {} : void 0,
2358
2482
  resources: remoteResources.length > 0 ? {} : void 0
@@ -2425,7 +2549,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2425
2549
  }));
2426
2550
  const remoteClient = new Client({
2427
2551
  name: "x402-proxy",
2428
- version: "0.11.2"
2552
+ version: "0.11.4"
2429
2553
  });
2430
2554
  await connectTransport(remoteClient);
2431
2555
  const mppClient = McpClient.wrap(remoteClient, { methods: wrappedMethods });
@@ -2440,7 +2564,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2440
2564
  }
2441
2565
  const localServer = new Server({
2442
2566
  name: "x402-proxy",
2443
- version: "0.11.2"
2567
+ version: "0.11.4"
2444
2568
  }, { capabilities: {
2445
2569
  tools: tools.length > 0 ? {} : void 0,
2446
2570
  resources: remoteResources.length > 0 ? {} : void 0
@@ -2826,7 +2950,7 @@ const app = buildApplication(buildRouteMap({
2826
2950
  docs: { brief: "curl for x402 paid APIs" }
2827
2951
  }), {
2828
2952
  name: "x402-proxy",
2829
- versionInfo: { currentVersion: "0.11.2" },
2953
+ versionInfo: { currentVersion: "0.11.4" },
2830
2954
  scanner: { caseStyle: "allow-kebab-for-camel" }
2831
2955
  });
2832
2956
  //#endregion
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { t as runSetup } from "./setup-C10O8N36.js";
3
+ export { runSetup };
@@ -4,7 +4,7 @@ import { c as isConfigured, d as saveConfig, g as generateMnemonic, i as getConf
4
4
  import "node:path";
5
5
  import "node:fs";
6
6
  import { stripVTControlCharacters, styleText } from "node:util";
7
- import N, { stdin, stdout } from "node:process";
7
+ import process$1, { stdin, stdout } from "node:process";
8
8
  import "node:readline";
9
9
  import ot from "node:readline";
10
10
  import "node:tty";
@@ -493,7 +493,7 @@ var $t = class extends B {
493
493
  //#endregion
494
494
  //#region node_modules/.pnpm/@clack+prompts@1.1.0/node_modules/@clack/prompts/dist/index.mjs
495
495
  function pt() {
496
- return N.platform !== "win32" ? N.env.TERM !== "linux" : !!N.env.CI || !!N.env.WT_SESSION || !!N.env.TERMINUS_SUBLIME || N.env.ConEmuTask === "{cmd::Cmder}" || N.env.TERM_PROGRAM === "Terminus-Sublime" || N.env.TERM_PROGRAM === "vscode" || N.env.TERM === "xterm-256color" || N.env.TERM === "alacritty" || N.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
496
+ return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
497
497
  }
498
498
  const ee = pt(), I = (e, r) => ee ? e : r, Re = I("◆", "*"), $e = I("■", "x"), de = I("▲", "x"), V = I("◇", "o"), he = I("┌", "T"), h = I("│", "|"), x = I("└", "—");
499
499
  I("┐", "T");
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Z as JSONRPCMessageSchema } from "./types-BQ17ZF7g.js";
3
- import N from "node:process";
3
+ import process from "node:process";
4
4
  //#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
5
5
  /**
6
6
  * Buffers a continuous stdio stream into discrete JSON-RPC messages.
@@ -35,7 +35,7 @@ function serializeMessage(message) {
35
35
  * This transport is only available in Node.js environments.
36
36
  */
37
37
  var StdioServerTransport = class {
38
- constructor(_stdin = N.stdin, _stdout = N.stdout) {
38
+ constructor(_stdin = process.stdin, _stdout = process.stdout) {
39
39
  this._stdin = _stdin;
40
40
  this._stdout = _stdout;
41
41
  this._readBuffer = new ReadBuffer();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x402-proxy",
3
3
  "description": "curl for x402 paid APIs. Auto-pays any endpoint on Base, Solana, and Tempo.",
4
- "version": "0.11.2",
4
+ "version": "0.11.4",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "license": "Apache-2.0",
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { t as runSetup } from "./setup-q91MbrZT.js";
3
- export { runSetup };