@hpp-io/x402-mcp-bridge 0.0.3 → 0.1.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 +53 -28
- package/dist/a2a.js +11 -3
- package/dist/a2a.js.map +1 -1
- package/dist/autoTopup.d.ts +2 -0
- package/dist/autoTopup.js +4 -0
- package/dist/autoTopup.js.map +1 -1
- package/dist/cli/hpp-x402.js +3 -1
- package/dist/cli/hpp-x402.js.map +1 -1
- package/dist/cli/serve.d.ts +1 -0
- package/dist/cli/serve.js +128 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/config.d.ts +31 -14
- package/dist/config.js +27 -5
- package/dist/config.js.map +1 -1
- package/dist/funds/direct-balance.d.ts +1 -0
- package/dist/funds/direct-balance.js +5 -2
- package/dist/funds/direct-balance.js.map +1 -1
- package/dist/funds.d.ts +6 -0
- package/dist/httpX402.js +7 -0
- package/dist/httpX402.js.map +1 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/sellerTools.d.ts +247 -0
- package/dist/sellerTools.js +202 -0
- package/dist/sellerTools.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +138 -3
- package/dist/server.js.map +1 -1
- package/dist/spendGuard.d.ts +24 -0
- package/dist/spendGuard.js +124 -0
- package/dist/spendGuard.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seller building-block tools (A2 Phase 1) — let an agent that already receives
|
|
3
|
+
* requests (its own HTTP/A2A server) charge for them over x402.
|
|
4
|
+
*
|
|
5
|
+
* Five stateless tools mirroring Polygon's seller set, but covering all three
|
|
6
|
+
* HPP schemes (exact / upto / batch-settlement), not just exact:
|
|
7
|
+
* - seller_create_requirements build a PaymentRequirements (local)
|
|
8
|
+
* - seller_generate_402 build the HTTP 402 body from accepts[] (local)
|
|
9
|
+
* - seller_decode_payment decode the X-PAYMENT header + payer (local)
|
|
10
|
+
* - seller_verify facilitator /verify (does the buyer's sig hold?)
|
|
11
|
+
* - seller_settle facilitator /settle (move the funds on-chain)
|
|
12
|
+
*
|
|
13
|
+
* verify/settle are thin wrappers over the same HTTPFacilitatorClient the
|
|
14
|
+
* resource server uses; the tools never hold funds or keys. The agent's own
|
|
15
|
+
* server orchestrates: 402 → decode → verify → do the work → settle.
|
|
16
|
+
*/
|
|
17
|
+
import { HTTPFacilitatorClient } from "@x402/core/server";
|
|
18
|
+
import { log } from "./log.js";
|
|
19
|
+
function decodeHeader(header) {
|
|
20
|
+
try {
|
|
21
|
+
const json = Buffer.from(header, "base64").toString("utf-8");
|
|
22
|
+
const parsed = JSON.parse(json);
|
|
23
|
+
if (!parsed || !parsed.payload)
|
|
24
|
+
return null;
|
|
25
|
+
const payer = parsed.payload.authorization?.from ??
|
|
26
|
+
parsed.payload.channelConfig?.payer ??
|
|
27
|
+
parsed.payload.permit2Authorization?.from ??
|
|
28
|
+
null;
|
|
29
|
+
return { payload: parsed, payer };
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function ok(obj) {
|
|
36
|
+
return { content: [{ type: "text", text: JSON.stringify(obj) }] };
|
|
37
|
+
}
|
|
38
|
+
function err(text) {
|
|
39
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
40
|
+
}
|
|
41
|
+
// ── tool defs ───────────────────────────────────────────────────────────
|
|
42
|
+
export const SELLER_CREATE_REQUIREMENTS_TOOL = {
|
|
43
|
+
name: "seller_create_requirements",
|
|
44
|
+
description: "Build an x402 PaymentRequirements object for a resource you sell. Returns " +
|
|
45
|
+
"the requirements to advertise in a 402 (see seller_generate_402). Scheme " +
|
|
46
|
+
"defaults to 'exact'; use 'upto' or 'batch-settlement' with scheme-specific " +
|
|
47
|
+
"fields in `extra`.",
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
amount: { type: "string", description: "Price in atomic units (e.g. '10000' = 0.01 USDC.e)." },
|
|
52
|
+
payTo: { type: "string", description: "Your wallet address (receives payment)." },
|
|
53
|
+
asset: { type: "string", description: "Token address (USDC.e on HPP)." },
|
|
54
|
+
network: { type: "string", description: "CAIP-2 network; defaults to the bridge network." },
|
|
55
|
+
scheme: { type: "string", enum: ["exact", "upto", "batch-settlement"], description: "Payment scheme (default exact)." },
|
|
56
|
+
maxTimeoutSeconds: { type: "number", description: "Payment validity window (default 600)." },
|
|
57
|
+
extra: { type: "object", description: "Scheme-specific extras (EIP-712 domain, Permit2 proxy, channel info)." },
|
|
58
|
+
},
|
|
59
|
+
required: ["amount", "payTo", "asset"],
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const SELLER_GENERATE_402_TOOL = {
|
|
64
|
+
name: "seller_generate_402",
|
|
65
|
+
description: "Build the HTTP 402 Payment Required response body from one or more " +
|
|
66
|
+
"PaymentRequirements (from seller_create_requirements). Return this when a " +
|
|
67
|
+
"request arrives with no payment header.",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
accepts: { type: "array", description: "PaymentRequirements[] the buyer may choose from.", items: { type: "object" } },
|
|
72
|
+
resource: { type: "string", description: "The resource URL being protected." },
|
|
73
|
+
error: { type: "string", description: "Optional human-readable reason." },
|
|
74
|
+
},
|
|
75
|
+
required: ["accepts"],
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export const SELLER_DECODE_PAYMENT_TOOL = {
|
|
80
|
+
name: "seller_decode_payment",
|
|
81
|
+
description: "Decode a buyer's base64 X-PAYMENT / Payment-Signature header locally (no " +
|
|
82
|
+
"facilitator call) to inspect the payload and extract the payer address. " +
|
|
83
|
+
"Supports exact / upto / batch-settlement.",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: { paymentHeader: { type: "string", description: "The base64 X-PAYMENT header value." } },
|
|
87
|
+
required: ["paymentHeader"],
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
export const SELLER_VERIFY_TOOL = {
|
|
92
|
+
name: "seller_verify",
|
|
93
|
+
description: "Verify a buyer's payment against the facilitator BEFORE doing the work. " +
|
|
94
|
+
"Pass the X-PAYMENT header + the PaymentRequirements you advertised. Returns " +
|
|
95
|
+
"{ isValid, payer, invalidReason }.",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
paymentHeader: { type: "string", description: "The base64 X-PAYMENT header." },
|
|
100
|
+
paymentRequirements: { type: "object", description: "The requirements you advertised for this resource." },
|
|
101
|
+
},
|
|
102
|
+
required: ["paymentHeader", "paymentRequirements"],
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
export const SELLER_SETTLE_TOOL = {
|
|
107
|
+
name: "seller_settle",
|
|
108
|
+
description: "Settle a verified payment on-chain AFTER the work succeeded (serve-then-" +
|
|
109
|
+
"settle). Pass the same X-PAYMENT header + PaymentRequirements. Returns " +
|
|
110
|
+
"{ success, transaction }.",
|
|
111
|
+
inputSchema: {
|
|
112
|
+
type: "object",
|
|
113
|
+
properties: {
|
|
114
|
+
paymentHeader: { type: "string", description: "The base64 X-PAYMENT header." },
|
|
115
|
+
paymentRequirements: { type: "object", description: "The requirements you advertised for this resource." },
|
|
116
|
+
},
|
|
117
|
+
required: ["paymentHeader", "paymentRequirements"],
|
|
118
|
+
additionalProperties: false,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
export const SELLER_TOOLS = [
|
|
122
|
+
SELLER_CREATE_REQUIREMENTS_TOOL,
|
|
123
|
+
SELLER_GENERATE_402_TOOL,
|
|
124
|
+
SELLER_DECODE_PAYMENT_TOOL,
|
|
125
|
+
SELLER_VERIFY_TOOL,
|
|
126
|
+
SELLER_SETTLE_TOOL,
|
|
127
|
+
];
|
|
128
|
+
// ── handlers ──────────────────────────────────────────────────────────────
|
|
129
|
+
export function sellerCreateRequirements(deps, a) {
|
|
130
|
+
if (!a.amount || !a.payTo || !a.asset)
|
|
131
|
+
return err("amount, payTo, asset are required");
|
|
132
|
+
const req = {
|
|
133
|
+
scheme: a.scheme ?? "exact",
|
|
134
|
+
network: (a.network ?? deps.network),
|
|
135
|
+
asset: a.asset,
|
|
136
|
+
amount: String(a.amount),
|
|
137
|
+
payTo: a.payTo,
|
|
138
|
+
maxTimeoutSeconds: a.maxTimeoutSeconds ?? 600,
|
|
139
|
+
extra: a.extra ?? {},
|
|
140
|
+
};
|
|
141
|
+
return ok({ requirements: req });
|
|
142
|
+
}
|
|
143
|
+
export function sellerGenerate402(a) {
|
|
144
|
+
const accepts = a.accepts;
|
|
145
|
+
if (!Array.isArray(accepts) || accepts.length === 0)
|
|
146
|
+
return err("accepts[] required");
|
|
147
|
+
const body = {
|
|
148
|
+
x402Version: 2,
|
|
149
|
+
error: a.error ?? "payment required",
|
|
150
|
+
...(a.resource ? { resource: a.resource } : {}),
|
|
151
|
+
accepts,
|
|
152
|
+
};
|
|
153
|
+
return ok({
|
|
154
|
+
response: { statusCode: 402, headers: { "Content-Type": "application/json" }, body },
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
export function sellerDecodePayment(a) {
|
|
158
|
+
const header = a.paymentHeader;
|
|
159
|
+
if (!header || typeof header !== "string")
|
|
160
|
+
return err("paymentHeader required");
|
|
161
|
+
const decoded = decodeHeader(header);
|
|
162
|
+
if (!decoded)
|
|
163
|
+
return err("could not decode payment header (base64 JSON expected)");
|
|
164
|
+
return ok({ scheme: decoded.payload.scheme, payer: decoded.payer, payload: decoded.payload });
|
|
165
|
+
}
|
|
166
|
+
export async function sellerVerify(deps, a) {
|
|
167
|
+
const header = a.paymentHeader;
|
|
168
|
+
const requirements = a.paymentRequirements;
|
|
169
|
+
if (!header || !requirements)
|
|
170
|
+
return err("paymentHeader and paymentRequirements required");
|
|
171
|
+
const decoded = decodeHeader(header);
|
|
172
|
+
if (!decoded)
|
|
173
|
+
return err("could not decode payment header");
|
|
174
|
+
try {
|
|
175
|
+
const client = new HTTPFacilitatorClient({ url: deps.facilitatorUrl });
|
|
176
|
+
const res = await client.verify(decoded.payload, requirements);
|
|
177
|
+
log.info("seller_verify", { isValid: res.isValid, payer: res.payer });
|
|
178
|
+
return ok({ isValid: res.isValid, payer: res.payer, invalidReason: res.invalidReason });
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
return err(`verify failed: ${e.message}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
export async function sellerSettle(deps, a) {
|
|
185
|
+
const header = a.paymentHeader;
|
|
186
|
+
const requirements = a.paymentRequirements;
|
|
187
|
+
if (!header || !requirements)
|
|
188
|
+
return err("paymentHeader and paymentRequirements required");
|
|
189
|
+
const decoded = decodeHeader(header);
|
|
190
|
+
if (!decoded)
|
|
191
|
+
return err("could not decode payment header");
|
|
192
|
+
try {
|
|
193
|
+
const client = new HTTPFacilitatorClient({ url: deps.facilitatorUrl });
|
|
194
|
+
const res = await client.settle(decoded.payload, requirements);
|
|
195
|
+
log.info("seller_settle", { success: res.success, tx: res.transaction });
|
|
196
|
+
return ok({ success: res.success, transaction: res.transaction });
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
return err(`settle failed: ${e.message}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=sellerTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sellerTools.js","sourceRoot":"","sources":["../src/sellerTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI1D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAoB/B,SAAS,YAAY,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AAC;IAClG,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,GAAG,CAAC,kBAAmB,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UpstreamClient } from "./client.js";
|
|
2
2
|
import type { DiscoveryClient } from "./discovery.js";
|
|
3
|
+
import { type SellerDeps } from "./sellerTools.js";
|
|
3
4
|
import type { RawEoaSigner } from "./signers/raw-eoa.js";
|
|
4
5
|
import type { Funds } from "./funds.js";
|
|
5
6
|
import type { Network } from "@x402/core/types";
|
|
@@ -14,6 +15,8 @@ export interface BridgeServerOptions {
|
|
|
14
15
|
funds?: Funds;
|
|
15
16
|
/** Curated-discovery client. Present = register hpp_discover / hpp_call. */
|
|
16
17
|
discovery?: DiscoveryClient;
|
|
18
|
+
/** Seller deps. Present = register seller_* tools. */
|
|
19
|
+
seller?: SellerDeps;
|
|
17
20
|
/**
|
|
18
21
|
* Per-request timeout for the A2A JSON-RPC calls in `pay_a2a_agent`.
|
|
19
22
|
* Surfaced via env `HPP_X402_A2A_RPC_TIMEOUT_MS` (set at CLI entry);
|
package/dist/server.js
CHANGED
|
@@ -17,15 +17,58 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextpro
|
|
|
17
17
|
import { PAY_A2A_TOOL, payA2aAgent } from "./a2a.js";
|
|
18
18
|
import { X402_HTTP_TOOL, x402HttpCall } from "./httpX402.js";
|
|
19
19
|
import { HPP_DISCOVER_TOOL, HPP_CALL_TOOL, hppDiscover, hppCall, } from "./discoveryTools.js";
|
|
20
|
+
import { SELLER_TOOLS, SELLER_CREATE_REQUIREMENTS_TOOL, SELLER_GENERATE_402_TOOL, SELLER_DECODE_PAYMENT_TOOL, SELLER_VERIFY_TOOL, SELLER_SETTLE_TOOL, sellerCreateRequirements, sellerGenerate402, sellerDecodePayment, sellerVerify, sellerSettle, } from "./sellerTools.js";
|
|
21
|
+
import { walletSpendStatus, setWalletLimits } from "./spendGuard.js";
|
|
20
22
|
import { log } from "./log.js";
|
|
23
|
+
const WALLET_GET_LIMITS_TOOL = {
|
|
24
|
+
name: "wallet_get_limits",
|
|
25
|
+
description: "Show the wallet's spend limits (per-call + per-day in atomic USDC.e units) " +
|
|
26
|
+
"and how much has been spent today. Empty limits = uncapped.",
|
|
27
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
28
|
+
};
|
|
29
|
+
const WALLET_SET_LIMIT_TOOL = {
|
|
30
|
+
name: "wallet_set_limit",
|
|
31
|
+
description: "Set the wallet's spend guard: a per-call cap and/or a per-day cap in atomic " +
|
|
32
|
+
"USDC.e units (e.g. '10000' = 0.01 USDC.e). These bind across ALL payment " +
|
|
33
|
+
"tools and are enforced locally before signing (complements the Safe's " +
|
|
34
|
+
"on-chain cap). Omit a field to leave it unchanged.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
maxPerCallAtomic: { type: "string", description: "Max atomic units per single payment." },
|
|
39
|
+
maxPerDayAtomic: { type: "string", description: "Max atomic units per UTC day (all tools combined)." },
|
|
40
|
+
},
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const WALLET_BALANCE_TOOL = {
|
|
45
|
+
name: "wallet_balance",
|
|
46
|
+
description: "Show the wallet's current USDC.e balance — what it can spend right now. In " +
|
|
47
|
+
"Safe mode this is the delegate's immediately-spendable balance (the Safe " +
|
|
48
|
+
"tops up more on demand).",
|
|
49
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
50
|
+
};
|
|
51
|
+
const WALLET_ADDRESS_TOOL = {
|
|
52
|
+
name: "wallet_address",
|
|
53
|
+
description: "Return this agent's own wallet address (to receive/fund USDC.e) and its " +
|
|
54
|
+
"network. Use when the user asks 'what's my address' or where to send funds.",
|
|
55
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
56
|
+
};
|
|
21
57
|
export async function startBridgeServer(opts) {
|
|
22
58
|
const server = new Server({ name: opts.name, version: opts.version }, { capabilities: { tools: {} } });
|
|
23
59
|
// ---- listTools — upstream tools (if any) + local tools --------------
|
|
24
60
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
25
61
|
const upstreamTools = opts.upstream ? await opts.upstream.base.listTools() : { tools: [] };
|
|
26
|
-
const localTools =
|
|
27
|
-
|
|
28
|
-
|
|
62
|
+
const localTools = [
|
|
63
|
+
WALLET_ADDRESS_TOOL,
|
|
64
|
+
WALLET_BALANCE_TOOL,
|
|
65
|
+
WALLET_GET_LIMITS_TOOL,
|
|
66
|
+
WALLET_SET_LIMIT_TOOL,
|
|
67
|
+
PAY_A2A_TOOL,
|
|
68
|
+
X402_HTTP_TOOL,
|
|
69
|
+
...(opts.discovery ? [HPP_DISCOVER_TOOL, HPP_CALL_TOOL] : []),
|
|
70
|
+
...(opts.seller ? SELLER_TOOLS : []),
|
|
71
|
+
];
|
|
29
72
|
log.debug("listTools", { count: upstreamTools.tools.length + localTools.length });
|
|
30
73
|
return { tools: [...upstreamTools.tools, ...localTools] };
|
|
31
74
|
});
|
|
@@ -46,6 +89,74 @@ export async function startBridgeServer(opts) {
|
|
|
46
89
|
server.setRequestHandler(CallToolRequestSchema, async (req, extra) => {
|
|
47
90
|
const { name, arguments: args } = req.params;
|
|
48
91
|
log.info("callTool.start", { name });
|
|
92
|
+
// Local tool: report our own wallet address (for funding).
|
|
93
|
+
if (name === WALLET_ADDRESS_TOOL.name) {
|
|
94
|
+
const address = opts.signer.address;
|
|
95
|
+
return {
|
|
96
|
+
content: [
|
|
97
|
+
{
|
|
98
|
+
type: "text",
|
|
99
|
+
text: JSON.stringify({
|
|
100
|
+
address,
|
|
101
|
+
network: opts.network,
|
|
102
|
+
fund: `Send USDC.e to ${address} on ${opts.network} — no native gas needed (gasless settlement).`,
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Local tool: read the wallet's current USDC.e balance.
|
|
109
|
+
if (name === WALLET_BALANCE_TOOL.name) {
|
|
110
|
+
if (!opts.funds) {
|
|
111
|
+
return { content: [{ type: "text", text: "no funds source configured" }], isError: true };
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const atomic = await opts.funds.balance();
|
|
115
|
+
const s = atomic.toString().padStart(7, "0");
|
|
116
|
+
const usdce = `${s.slice(0, -6)}.${s.slice(-6)}`;
|
|
117
|
+
return {
|
|
118
|
+
content: [
|
|
119
|
+
{
|
|
120
|
+
type: "text",
|
|
121
|
+
text: JSON.stringify({
|
|
122
|
+
address: opts.signer.address,
|
|
123
|
+
balanceAtomic: atomic.toString(),
|
|
124
|
+
balanceUsdce: usdce,
|
|
125
|
+
network: opts.network,
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
133
|
+
return { content: [{ type: "text", text: `wallet_balance error: ${msg}` }], isError: true };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Local tool: read the wallet's spend limits + today's usage.
|
|
137
|
+
if (name === WALLET_GET_LIMITS_TOOL.name) {
|
|
138
|
+
return { content: [{ type: "text", text: JSON.stringify(walletSpendStatus()) }] };
|
|
139
|
+
}
|
|
140
|
+
// Local tool: set the wallet's per-call / per-day spend caps.
|
|
141
|
+
if (name === WALLET_SET_LIMIT_TOOL.name) {
|
|
142
|
+
const a = (args ?? {});
|
|
143
|
+
const DIGITS = /^\d+$/;
|
|
144
|
+
const next = {};
|
|
145
|
+
for (const k of ["maxPerCallAtomic", "maxPerDayAtomic"]) {
|
|
146
|
+
const v = a[k];
|
|
147
|
+
if (v === undefined)
|
|
148
|
+
continue;
|
|
149
|
+
if (typeof v !== "string" || !DIGITS.test(v)) {
|
|
150
|
+
return { content: [{ type: "text", text: `${k} must be a decimal atomic-units string` }], isError: true };
|
|
151
|
+
}
|
|
152
|
+
next[k] = v;
|
|
153
|
+
}
|
|
154
|
+
if (next.maxPerCallAtomic === undefined && next.maxPerDayAtomic === undefined) {
|
|
155
|
+
return { content: [{ type: "text", text: "provide maxPerCallAtomic and/or maxPerDayAtomic" }], isError: true };
|
|
156
|
+
}
|
|
157
|
+
setWalletLimits(next);
|
|
158
|
+
return { content: [{ type: "text", text: JSON.stringify({ updated: true, ...walletSpendStatus() }) }] };
|
|
159
|
+
}
|
|
49
160
|
// Local tool: pay an external A2A agent (not an upstream MCP tool).
|
|
50
161
|
if (name === PAY_A2A_TOOL.name) {
|
|
51
162
|
try {
|
|
@@ -101,6 +212,30 @@ export async function startBridgeServer(opts) {
|
|
|
101
212
|
return { content: [{ type: "text", text: `hpp_call error: ${msg}` }], isError: true };
|
|
102
213
|
}
|
|
103
214
|
}
|
|
215
|
+
// Local tools: seller building blocks (charge others over x402).
|
|
216
|
+
if (opts.seller && name.startsWith("seller_")) {
|
|
217
|
+
const s = opts.seller;
|
|
218
|
+
const a = (args ?? {});
|
|
219
|
+
try {
|
|
220
|
+
switch (name) {
|
|
221
|
+
case SELLER_CREATE_REQUIREMENTS_TOOL.name:
|
|
222
|
+
return sellerCreateRequirements(s, a);
|
|
223
|
+
case SELLER_GENERATE_402_TOOL.name:
|
|
224
|
+
return sellerGenerate402(a);
|
|
225
|
+
case SELLER_DECODE_PAYMENT_TOOL.name:
|
|
226
|
+
return sellerDecodePayment(a);
|
|
227
|
+
case SELLER_VERIFY_TOOL.name:
|
|
228
|
+
return await sellerVerify(s, a);
|
|
229
|
+
case SELLER_SETTLE_TOOL.name:
|
|
230
|
+
return await sellerSettle(s, a);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
235
|
+
log.error(`${name}.failed`, { err: msg });
|
|
236
|
+
return { content: [{ type: "text", text: `${name} error: ${msg}` }], isError: true };
|
|
237
|
+
}
|
|
238
|
+
}
|
|
104
239
|
// Beyond the local tools above, everything is an upstream resource-server
|
|
105
240
|
// tool. In local-tools-only mode there's no upstream to forward to.
|
|
106
241
|
if (!opts.upstream) {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AAChF,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,OAAO,GAGR,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAqB/B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAyB;IAC/D,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAC1C,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAChC,CAAC;IAEF,wEAAwE;IACxE,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EA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/**
|
|
4
|
+
* Returns a human-readable deny reason if paying `amount` would breach the
|
|
5
|
+
* wallet-wide per-call or per-day cap, else null. No-op (null) when no caps set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkWalletSpend(amount: bigint): string | null;
|
|
8
|
+
/** Record a *successful* payment against today's wallet-wide total. */
|
|
9
|
+
export declare function recordWalletSpend(amount: bigint): void;
|
|
10
|
+
/**
|
|
11
|
+
* Set the wallet-wide spend limits (persisted to policy._defaults.limits), so
|
|
12
|
+
* the guard enforces them. Omitted fields are left unchanged. Atomic strings.
|
|
13
|
+
*/
|
|
14
|
+
export declare function setWalletLimits(next: {
|
|
15
|
+
maxPerCallAtomic?: string;
|
|
16
|
+
maxPerDayAtomic?: string;
|
|
17
|
+
}): void;
|
|
18
|
+
/** Current limits + today's usage, for `wallet_get_limits` / `status`. */
|
|
19
|
+
export declare function walletSpendStatus(): {
|
|
20
|
+
spentTodayAtomic: string;
|
|
21
|
+
maxPerCallAtomic?: string;
|
|
22
|
+
maxPerDayAtomic?: string;
|
|
23
|
+
remainingTodayAtomic?: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet-wide spend guard — the runaway-agent brake.
|
|
3
|
+
*
|
|
4
|
+
* Enforces two caps *uniformly across every payment path* (x402_http_call,
|
|
5
|
+
* hpp_call, pay_a2a_agent), so no single tool can bypass them:
|
|
6
|
+
* - per-call: a single payment may not exceed `maxPerCallAtomic`
|
|
7
|
+
* - per-day: the wallet's total spend in a UTC day may not exceed
|
|
8
|
+
* `maxPerDayAtomic` (this is the daily "ledger" that policy.ts
|
|
9
|
+
* declared as a follow-up — now implemented)
|
|
10
|
+
*
|
|
11
|
+
* Limits are read from `policy._defaults.limits` (wallet-wide). When unset the
|
|
12
|
+
* guard is a no-op, so existing setups are unaffected — the caps only bite once
|
|
13
|
+
* a user sets them (via `wallet_set_limit` / `hpp-x402 policy defaults`).
|
|
14
|
+
*
|
|
15
|
+
* This is a *soft* guard the bridge enforces before signing: it protects
|
|
16
|
+
* against the agent overspending (misbehaviour / prompt injection), NOT against
|
|
17
|
+
* an attacker with machine access (that's the Safe's on-chain cap). Two
|
|
18
|
+
* complementary layers.
|
|
19
|
+
*
|
|
20
|
+
* The daily ledger lives at `${HPP_X402_HOME|~/.hpp-x402}/ledger.json` and only
|
|
21
|
+
* keeps today + yesterday (rolling).
|
|
22
|
+
*/
|
|
23
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
24
|
+
import { homedir } from "node:os";
|
|
25
|
+
import { resolve as pathResolve } from "node:path";
|
|
26
|
+
import { loadPolicy, savePolicy } from "./policy.js";
|
|
27
|
+
import { log } from "./log.js";
|
|
28
|
+
function home() {
|
|
29
|
+
return process.env.HPP_X402_HOME ?? pathResolve(homedir(), ".hpp-x402");
|
|
30
|
+
}
|
|
31
|
+
function ledgerPath() {
|
|
32
|
+
return pathResolve(home(), "ledger.json");
|
|
33
|
+
}
|
|
34
|
+
function dayKey(offsetDays = 0) {
|
|
35
|
+
const d = new Date();
|
|
36
|
+
d.setUTCDate(d.getUTCDate() + offsetDays);
|
|
37
|
+
return d.toISOString().slice(0, 10); // UTC yyyy-mm-dd
|
|
38
|
+
}
|
|
39
|
+
function loadLedger() {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(readFileSync(ledgerPath(), "utf-8"));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function saveLedger(l) {
|
|
48
|
+
const keep = new Set([dayKey(0), dayKey(-1)]);
|
|
49
|
+
for (const k of Object.keys(l))
|
|
50
|
+
if (!keep.has(k))
|
|
51
|
+
delete l[k];
|
|
52
|
+
try {
|
|
53
|
+
mkdirSync(home(), { recursive: true });
|
|
54
|
+
writeFileSync(ledgerPath(), JSON.stringify(l), { mode: 0o600 });
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
log.debug("spendGuard.saveFailed", { err: err.message });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function walletLimits() {
|
|
61
|
+
const d = loadPolicy()._defaults?.limits ?? {};
|
|
62
|
+
return {
|
|
63
|
+
maxPerCall: d.maxPerCallAtomic != null ? BigInt(d.maxPerCallAtomic) : undefined,
|
|
64
|
+
maxPerDay: d.maxPerDayAtomic != null ? BigInt(d.maxPerDayAtomic) : undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Wallet-wide atomic units spent so far today (UTC). */
|
|
68
|
+
export function spentToday() {
|
|
69
|
+
return BigInt(loadLedger()[dayKey(0)] ?? "0");
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns a human-readable deny reason if paying `amount` would breach the
|
|
73
|
+
* wallet-wide per-call or per-day cap, else null. No-op (null) when no caps set.
|
|
74
|
+
*/
|
|
75
|
+
export function checkWalletSpend(amount) {
|
|
76
|
+
const { maxPerCall, maxPerDay } = walletLimits();
|
|
77
|
+
if (maxPerCall != null && amount > maxPerCall) {
|
|
78
|
+
return `wallet per-call cap exceeded: ${amount} > ${maxPerCall} atomic. Raise it with wallet_set_limit (or hpp-x402 policy defaults --max-per-call).`;
|
|
79
|
+
}
|
|
80
|
+
if (maxPerDay != null) {
|
|
81
|
+
const after = spentToday() + amount;
|
|
82
|
+
if (after > maxPerDay) {
|
|
83
|
+
return `wallet daily cap exceeded: ${spentToday()} spent + ${amount} = ${after} > ${maxPerDay} atomic today. Resets at UTC midnight; raise with wallet_set_limit.`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
/** Record a *successful* payment against today's wallet-wide total. */
|
|
89
|
+
export function recordWalletSpend(amount) {
|
|
90
|
+
if (amount <= 0n)
|
|
91
|
+
return;
|
|
92
|
+
const l = loadLedger();
|
|
93
|
+
l[dayKey(0)] = (BigInt(l[dayKey(0)] ?? "0") + amount).toString();
|
|
94
|
+
saveLedger(l);
|
|
95
|
+
log.debug("spendGuard.recorded", { amount: amount.toString(), spentToday: l[dayKey(0)] });
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Set the wallet-wide spend limits (persisted to policy._defaults.limits), so
|
|
99
|
+
* the guard enforces them. Omitted fields are left unchanged. Atomic strings.
|
|
100
|
+
*/
|
|
101
|
+
export function setWalletLimits(next) {
|
|
102
|
+
const policy = loadPolicy();
|
|
103
|
+
const defaults = policy._defaults ?? {};
|
|
104
|
+
const limits = { ...(defaults.limits ?? {}) };
|
|
105
|
+
if (next.maxPerCallAtomic !== undefined)
|
|
106
|
+
limits.maxPerCallAtomic = next.maxPerCallAtomic;
|
|
107
|
+
if (next.maxPerDayAtomic !== undefined)
|
|
108
|
+
limits.maxPerDayAtomic = next.maxPerDayAtomic;
|
|
109
|
+
policy._defaults = { ...defaults, limits };
|
|
110
|
+
savePolicy(policy);
|
|
111
|
+
log.info("spendGuard.limitsUpdated", { ...limits });
|
|
112
|
+
}
|
|
113
|
+
/** Current limits + today's usage, for `wallet_get_limits` / `status`. */
|
|
114
|
+
export function walletSpendStatus() {
|
|
115
|
+
const { maxPerCall, maxPerDay } = walletLimits();
|
|
116
|
+
const spent = spentToday();
|
|
117
|
+
return {
|
|
118
|
+
spentTodayAtomic: spent.toString(),
|
|
119
|
+
maxPerCallAtomic: maxPerCall?.toString(),
|
|
120
|
+
maxPerDayAtomic: maxPerDay?.toString(),
|
|
121
|
+
remainingTodayAtomic: maxPerDay != null ? (maxPerDay > spent ? (maxPerDay - spent).toString() : "0") : undefined,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=spendGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spendGuard.js","sourceRoot":"","sources":["../src/spendGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,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AS,GAAG,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC3C,UAAU,CAAC,MAAM,CAAC,CAAC;IACnB,GAAG,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,iBAAiB;IAM/B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAAC;IACjD,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAC3B,OAAO;QACL,gBAAgB,EAAE,KAAK,CAAC,QAAQ,EAAE;QAClC,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE;QACxC,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE;QACtC,oBAAoB,EAClB,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;KAC7F,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpp-io/x402-mcp-bridge",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "MCP stdio bridge that lets Claude Desktop / OpenClaw / other MCP hosts make x402 payments on HPP — autoTopup from a Safe via AllowanceModule, signs EIP-3009 with a delegate EOA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsc",
|
|
25
25
|
"dev": "tsx src/index.ts",
|
|
26
|
+
"test": "vitest run",
|
|
26
27
|
"typecheck": "tsc --noEmit",
|
|
27
28
|
"postinstall": "patch-package || true",
|
|
28
29
|
"prepublishOnly": "npm run typecheck && npm run build"
|
|
@@ -35,15 +36,19 @@
|
|
|
35
36
|
"@napi-rs/keyring": "^1.3.0",
|
|
36
37
|
"@x402/core": "^2.14.0",
|
|
37
38
|
"@x402/evm": "^2.14.0",
|
|
39
|
+
"@x402/express": "^2.17.0",
|
|
38
40
|
"@x402/mcp": "^2.14.0",
|
|
39
41
|
"commander": "^12.1.0",
|
|
42
|
+
"express": "^4.22.2",
|
|
40
43
|
"viem": "^2.21.54",
|
|
41
44
|
"zod": "^3.23.8"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
47
|
+
"@types/express": "^4.17.25",
|
|
44
48
|
"@types/node": "^20.0.0",
|
|
45
49
|
"patch-package": "^8.0.1",
|
|
46
50
|
"tsx": "^4.0.0",
|
|
47
|
-
"typescript": "^5.4.0"
|
|
51
|
+
"typescript": "^5.4.0",
|
|
52
|
+
"vitest": "^4.1.10"
|
|
48
53
|
}
|
|
49
54
|
}
|