agentpay-mcp 4.1.0 → 4.1.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 +299 -2
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/otel-budget.d.ts +265 -0
- package/dist/tools/otel-budget.d.ts.map +1 -0
- package/dist/tools/otel-budget.js +399 -0
- package/dist/tools/otel-budget.js.map +1 -0
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +2 -0
- package/dist/tools/session.js.map +1 -1
- package/dist/tools/x402.d.ts.map +1 -1
- package/dist/tools/x402.js +58 -0
- package/dist/tools/x402.js.map +1 -1
- package/dist/utils/client.d.ts.map +1 -1
- package/dist/utils/client.js +8 -1
- package/dist/utils/client.js.map +1 -1
- package/dist/utils/x402-networks.d.ts +12 -0
- package/dist/utils/x402-networks.d.ts.map +1 -0
- package/dist/utils/x402-networks.js +30 -0
- package/dist/utils/x402-networks.js.map +1 -0
- package/docs/channel-agent-affiliate-controls.md +142 -0
- package/docs/hitl-reference-architecture.md +140 -0
- package/docs/security-posture.md +74 -0
- package/docs/trust-architecture.md +127 -0
- package/docs/vercel-deployment-hardening.md +115 -0
- package/docs/whatsapp-smb-agent-controls.md +130 -0
- package/docs/x402-batch-settlement-channels.md +199 -0
- package/docs/x402-bazaar-observability.md +209 -0
- package/docs/x402-chain-drift-compatibility.md +63 -0
- package/docs/x402-mcp-funding-ux-benchmark.md +36 -0
- package/docs/x402-multi-sdk-batch-settlement-parity.md +167 -0
- package/docs/x402-scanner-readiness.md +110 -0
- package/docs/x402-tvm-readiness.md +53 -0
- package/package.json +6 -5
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# x402 scanner-readiness recipe for AgentPay MCP
|
|
2
|
+
|
|
3
|
+
External scanners now need a cheap way to answer one question before they spend engineering time on a paid endpoint: does this service speak x402, and where is the protected endpoint?
|
|
4
|
+
|
|
5
|
+
This recipe makes that answer machine-readable without giving agents unlimited spending authority.
|
|
6
|
+
|
|
7
|
+
## What to expose
|
|
8
|
+
|
|
9
|
+
A scanner-ready AgentPay MCP demo should expose a dedicated, clean 402 probe route first:
|
|
10
|
+
|
|
11
|
+
1. `/api/x402/demo` returns `402 Payment Required` with `PAYMENT-REQUIRED` and x402 payment metadata. This is the scanner target.
|
|
12
|
+
2. `X-X402-Supported: true` on the service home page or docs landing page points humans and crawlers to x402 support.
|
|
13
|
+
3. A `sitemap.xml`, docs page, or `Link` header lists `/api/x402/demo` so crawlers do not have to guess paths.
|
|
14
|
+
|
|
15
|
+
Do not rely on headers, sitemap entries, or Link headers alone. The x402 Foundation scanner path changed after `/protected`, sitemap discovery, `Link` headers, and `X-X402-Supported` did not give isitagentready.com a stable pass. A clean API-style 402 route is now the recommended readiness signal.
|
|
16
|
+
|
|
17
|
+
The scanner route is not the payment control. It is a discovery layer. AgentPay MCP still owns approval, policy checks, spend caps, wallet signing, settlement audit rows, and fail-closed behavior.
|
|
18
|
+
|
|
19
|
+
## Minimal HTTP pattern
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import http from "node:http";
|
|
23
|
+
|
|
24
|
+
const demoUrl = "https://agentpay.example.com/api/x402/demo";
|
|
25
|
+
|
|
26
|
+
http.createServer((request, response) => {
|
|
27
|
+
response.setHeader("X-X402-Supported", "true");
|
|
28
|
+
|
|
29
|
+
if (request.url === "/sitemap.xml") {
|
|
30
|
+
response.setHeader("Content-Type", "application/xml");
|
|
31
|
+
response.end(`<?xml version="1.0" encoding="UTF-8"?>
|
|
32
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
33
|
+
<url><loc>${demoUrl}</loc></url>
|
|
34
|
+
</urlset>`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (request.url === "/api/x402/demo") {
|
|
39
|
+
response.writeHead(402, {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
"X-X402-Supported": "true",
|
|
42
|
+
});
|
|
43
|
+
response.end(JSON.stringify({
|
|
44
|
+
error: "Payment Required",
|
|
45
|
+
x402Version: "2",
|
|
46
|
+
accepts: [{
|
|
47
|
+
scheme: "exact",
|
|
48
|
+
network: "base",
|
|
49
|
+
amount: "10000",
|
|
50
|
+
asset: "USDC",
|
|
51
|
+
resource: demoUrl,
|
|
52
|
+
}],
|
|
53
|
+
}));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
response.writeHead(200, { "Content-Type": "text/plain" });
|
|
58
|
+
response.end("AgentPay MCP demo. See /sitemap.xml and /api/x402/demo.\n");
|
|
59
|
+
}).listen(8787);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Runnable demo
|
|
63
|
+
|
|
64
|
+
A minimal Node route lives at `examples/x402-clean-demo/server.mjs`. It is intentionally small so teams can copy the scanner contract without copying wallet logic into the demo endpoint.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
node examples/x402-clean-demo/server.mjs
|
|
68
|
+
curl -si http://127.0.0.1:8787/api/x402/demo | head -n 12
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Expected result: HTTP `402`, `PAYMENT-REQUIRED: true`, `X-X402-Supported: true`, and a JSON body with x402 payment metadata.
|
|
72
|
+
|
|
73
|
+
## AgentPay MCP payment flow
|
|
74
|
+
|
|
75
|
+
1. Scanner calls `/api/x402/demo` and receives `402 Payment Required` plus x402 payment metadata.
|
|
76
|
+
2. Human readers and crawlers can also see `X-X402-Supported: true` on `/`.
|
|
77
|
+
3. Sitemap or `Link` metadata can point to `/api/x402/demo`, but the clean 402 route is the source of truth.
|
|
78
|
+
4. The agent calls AgentPay MCP `x402_pay` with the protected URL.
|
|
79
|
+
5. AgentPay MCP checks policy before signing: daily cap, task cap, recipient allowlist, approval mode, and kill switch.
|
|
80
|
+
6. Only after approval does AgentPay MCP sign and retry the request.
|
|
81
|
+
7. The transaction history records URL, amount, chain, token, approval status, and settlement reference.
|
|
82
|
+
|
|
83
|
+
## Curl verification checklist
|
|
84
|
+
|
|
85
|
+
Run these commands against the demo or deployment:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
$ curl -si https://agentpay.example.com/ | grep -i '^x-x402-supported:'
|
|
89
|
+
X-X402-Supported: true
|
|
90
|
+
|
|
91
|
+
$ curl -s https://agentpay.example.com/sitemap.xml | grep '/api/x402/demo'
|
|
92
|
+
<url><loc>https://agentpay.example.com/api/x402/demo</loc></url>
|
|
93
|
+
|
|
94
|
+
$ curl -si https://agentpay.example.com/api/x402/demo | head -n 8
|
|
95
|
+
HTTP/2 402
|
|
96
|
+
content-type: application/json
|
|
97
|
+
x-x402-supported: true
|
|
98
|
+
payment-required: true
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
A scanner pass means discovery works. A production pass means discovery plus AgentPay MCP policy gates both work.
|
|
102
|
+
|
|
103
|
+
## Acceptance criteria
|
|
104
|
+
|
|
105
|
+
- `/api/x402/demo` returns HTTP 402 before payment.
|
|
106
|
+
- The 402 response includes `PAYMENT-REQUIRED` and x402 payment metadata.
|
|
107
|
+
- Home or docs route returns `X-X402-Supported: true`.
|
|
108
|
+
- Sitemap, docs, or `Link` metadata points to `/api/x402/demo`, but verification does not depend on metadata alone.
|
|
109
|
+
- `x402_pay` cannot sign until AgentPay MCP policy approves the request.
|
|
110
|
+
- Audit output includes resource URL, amount, chain, approval decision, and settlement reference.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# x402 TVM exact-payment readiness
|
|
2
|
+
|
|
3
|
+
x402 Foundation PR #1944 is adding Python exact-payment support for TVM and TON-style flows. AgentPay MCP treats that as a watch signal, not as production support.
|
|
4
|
+
|
|
5
|
+
AgentPay MCP currently signs x402 exact payments only on the configured Base network. If a paid endpoint returns a TVM requirement such as `network: "tvm:-3"`, AgentPay MCP fails closed. It does not coerce the payment to Base, it does not attempt a best-effort jetton transfer, and it returns guidance that TVM support must be added deliberately before signing.
|
|
6
|
+
|
|
7
|
+
## Support matrix
|
|
8
|
+
|
|
9
|
+
| Rail | AgentPay MCP status | Current behavior |
|
|
10
|
+
|------|---------------------|------------------|
|
|
11
|
+
| Base EVM exact payment | Supported | `x402_pay` signs only the configured Base network, applies per-call caps, and records payment details. |
|
|
12
|
+
| Base Sepolia exact payment | Supported for test flows | Same signing path as Base mainnet when `CHAIN_ID=84532`. |
|
|
13
|
+
| Other EVM x402 networks | Watch state | The SDK baseline can see more chains, but AgentPay MCP restricts signing to the configured Base network until each chain has explicit wallet, asset, and audit support. |
|
|
14
|
+
| Solana x402 | Watch state | No AgentPay signing path is enabled. Requests must fail closed until a Solana wallet, token, receipt, and spend-policy path exists. |
|
|
15
|
+
| x402 batch settlement | Documentation and audit recipe | Batch deposit, voucher, refund, claim, recovery, and multi-SDK parity requirements are documented in `x402-batch-settlement-channels.md` and `x402-multi-sdk-batch-settlement-parity.md`. |
|
|
16
|
+
| TVM/TON exact payment | Watch state | Unsupported TVM requirements fail closed with guidance. No TVM signing, account deployment, faucet, gas, jetton, or facilitator settlement path is enabled. |
|
|
17
|
+
|
|
18
|
+
## Fail-closed invariant
|
|
19
|
+
|
|
20
|
+
AgentPay MCP must never silently treat an unsupported x402 network as compatible.
|
|
21
|
+
|
|
22
|
+
Required behavior:
|
|
23
|
+
|
|
24
|
+
1. Restrict `createX402Client` to the configured AgentPay network instead of accepting the SDK default network list.
|
|
25
|
+
2. Return an error when a `402 Payment Required` response has only unsupported payment options.
|
|
26
|
+
3. Include the offered network list and the supported AgentPay network list in the error.
|
|
27
|
+
4. For TVM/TON offers, say that TVM is watch-only until signing, account deployment, gas, jettons, settlement, and audit rows are implemented.
|
|
28
|
+
5. Do not call wallet signing or token transfer code for unsupported networks.
|
|
29
|
+
|
|
30
|
+
## Current implementation proof
|
|
31
|
+
|
|
32
|
+
The `x402_pay` tool now passes `supportedNetworks` to the x402 client based on `CHAIN_ID`:
|
|
33
|
+
|
|
34
|
+
- `CHAIN_ID=8453` allows only `base:8453`.
|
|
35
|
+
- `CHAIN_ID=84532` allows only `base-sepolia:84532`.
|
|
36
|
+
- `CHAIN_ID=tvm:-3` is rejected during config load with TVM-specific fail-closed guidance.
|
|
37
|
+
|
|
38
|
+
If a server returns HTTP 402 with only `tvm:-3`, the tool returns `Unsupported x402 Payment Requirement - Failed Closed` and includes the offered network.
|
|
39
|
+
|
|
40
|
+
## What must ship before TVM support turns on
|
|
41
|
+
|
|
42
|
+
TVM support should not be enabled by adding a string to a network list. It needs a complete payment path:
|
|
43
|
+
|
|
44
|
+
- TVM signer support with local key handling.
|
|
45
|
+
- Account deployment and funding checks.
|
|
46
|
+
- Gas and faucet handling for test networks.
|
|
47
|
+
- Jetton asset mapping and decimals.
|
|
48
|
+
- Facilitator verification and settlement-cache handling.
|
|
49
|
+
- Spend-policy checks before signing.
|
|
50
|
+
- Audit rows that record network, asset, amount, payee, facilitator, settlement result, and receipt.
|
|
51
|
+
- Tests for accept, decline, cap exceeded, bad asset, bad payee, settlement failure, and retry behavior.
|
|
52
|
+
|
|
53
|
+
Until those exist, TVM exact-payment requests stay blocked by design.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentpay-mcp",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"mcpName": "io.github.up2itnow0822/agentpay",
|
|
5
|
-
"description": "AgentPay MCP Server
|
|
5
|
+
"description": "AgentPay MCP Server - Non-custodial x402 payment layer for AI agents. Multi-chain wallets, spending limits, and machine-to-machine payments. Patent Pending.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"dist",
|
|
13
13
|
"README.md",
|
|
14
14
|
"claude_desktop_config.json",
|
|
15
|
-
".env.example"
|
|
15
|
+
".env.example",
|
|
16
|
+
"docs/*.md"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
18
19
|
"build": "tsc",
|
|
@@ -54,11 +55,11 @@
|
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
56
57
|
"agentwallet-sdk": "^6.1.0",
|
|
57
|
-
"viem": "2.
|
|
58
|
+
"viem": "^2.47.12",
|
|
58
59
|
"zod": "^3.22.4"
|
|
59
60
|
},
|
|
60
61
|
"overrides": {
|
|
61
|
-
"viem": "2.
|
|
62
|
+
"viem": "^2.47.12"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@types/node": "^20.11.0",
|