agentpay-mcp 4.1.1 → 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.
Files changed (34) hide show
  1. package/README.md +262 -2
  2. package/dist/index.js +19 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/tools/otel-budget.d.ts +265 -0
  5. package/dist/tools/otel-budget.d.ts.map +1 -0
  6. package/dist/tools/otel-budget.js +399 -0
  7. package/dist/tools/otel-budget.js.map +1 -0
  8. package/dist/tools/session.d.ts.map +1 -1
  9. package/dist/tools/session.js +2 -0
  10. package/dist/tools/session.js.map +1 -1
  11. package/dist/tools/x402.d.ts.map +1 -1
  12. package/dist/tools/x402.js +58 -0
  13. package/dist/tools/x402.js.map +1 -1
  14. package/dist/utils/client.d.ts.map +1 -1
  15. package/dist/utils/client.js +8 -1
  16. package/dist/utils/client.js.map +1 -1
  17. package/dist/utils/x402-networks.d.ts +12 -0
  18. package/dist/utils/x402-networks.d.ts.map +1 -0
  19. package/dist/utils/x402-networks.js +30 -0
  20. package/dist/utils/x402-networks.js.map +1 -0
  21. package/docs/channel-agent-affiliate-controls.md +142 -0
  22. package/docs/hitl-reference-architecture.md +140 -0
  23. package/docs/security-posture.md +74 -0
  24. package/docs/trust-architecture.md +127 -0
  25. package/docs/vercel-deployment-hardening.md +115 -0
  26. package/docs/whatsapp-smb-agent-controls.md +130 -0
  27. package/docs/x402-batch-settlement-channels.md +199 -0
  28. package/docs/x402-bazaar-observability.md +209 -0
  29. package/docs/x402-chain-drift-compatibility.md +63 -0
  30. package/docs/x402-mcp-funding-ux-benchmark.md +36 -0
  31. package/docs/x402-multi-sdk-batch-settlement-parity.md +167 -0
  32. package/docs/x402-scanner-readiness.md +110 -0
  33. package/docs/x402-tvm-readiness.md +53 -0
  34. package/package.json +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"x402.js","sourceRoot":"","sources":["../../src/tools/x402.ts"],"names":[],"mappings":";;;AAyHA,sCAkLC;A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BAAmB,CAyB7E;AAOD;;;GAGG;AACH,wBAAgB,SAAS,IAAI,cAAc,CAK1C;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,mBAAmB,CAK/C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}
@@ -48,7 +48,14 @@ function loadConfig() {
48
48
  if (!walletAddress.startsWith('0x') || walletAddress.length !== 42) {
49
49
  throw new Error('AGENT_WALLET_ADDRESS must be a 0x-prefixed 20-byte hex string (42 chars total).');
50
50
  }
51
- const chainId = parseInt(process.env['CHAIN_ID'] ?? '8453', 10);
51
+ const chainIdRaw = process.env['CHAIN_ID'] ?? '8453';
52
+ if (!/^\d+$/.test(chainIdRaw)) {
53
+ throw new Error(`Unsupported CHAIN_ID: "${chainIdRaw}". AgentPay MCP currently supports ` +
54
+ '8453 (Base Mainnet) and 84532 (Base Sepolia) for x402 exact payments. ' +
55
+ 'TVM/TON values such as "tvm:-3" are watch-only and fail closed until ' +
56
+ 'AgentPay adds deliberate TVM signing, gas, jetton, wallet deployment, and settlement support.');
57
+ }
58
+ const chainId = parseInt(chainIdRaw, 10);
52
59
  if (!CHAIN_MAP[chainId]) {
53
60
  throw new Error(`Unsupported CHAIN_ID: ${chainId}. Supported values: 8453 (Base Mainnet), 84532 (Base Sepolia).`);
54
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":";;AAiDA,gCAiDC;AAUD,8CAyBC;AAWD,8BAKC;AAMD,8BAKC;AAKD,4CAGC;AAxKD;;;GAGG;AACH,+BAA0E;AAC1E,4CAAoD;AACpD,wCAAgD;AAChD,qDAA+C;AAE/C,8EAA8E;AAE9E,MAAM,SAAS,GAA0B;IACvC,IAAI,EAAE,aAAI;IACV,KAAK,EAAE,oBAAW;CACnB,CAAC;AAEF,MAAM,cAAc,GAA4C;IAC9D,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,cAAc;CACtB,CAA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AO,GAAG,IAAI,CAAC;AACjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * x402 network support policy for AgentPay MCP.
3
+ *
4
+ * AgentPay MCP currently signs x402 exact payments only on the configured
5
+ * Base network. New x402 networks must be added deliberately because each
6
+ * network can need different wallet deployment, gas, asset, and settlement
7
+ * handling.
8
+ */
9
+ export declare function supportedX402NetworksForChainId(chainId: number): string[];
10
+ export declare function describeSupportedX402Networks(chainId: number): string;
11
+ export declare function isTvmOrTonNetwork(network: string): boolean;
12
+ //# sourceMappingURL=x402-networks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-networks.d.ts","sourceRoot":"","sources":["../../src/utils/x402-networks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAGzE;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG1D"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * x402 network support policy for AgentPay MCP.
4
+ *
5
+ * AgentPay MCP currently signs x402 exact payments only on the configured
6
+ * Base network. New x402 networks must be added deliberately because each
7
+ * network can need different wallet deployment, gas, asset, and settlement
8
+ * handling.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.supportedX402NetworksForChainId = supportedX402NetworksForChainId;
12
+ exports.describeSupportedX402Networks = describeSupportedX402Networks;
13
+ exports.isTvmOrTonNetwork = isTvmOrTonNetwork;
14
+ const X402_NETWORK_BY_CHAIN_ID = {
15
+ 8453: 'base:8453',
16
+ 84532: 'base-sepolia:84532',
17
+ };
18
+ function supportedX402NetworksForChainId(chainId) {
19
+ const network = X402_NETWORK_BY_CHAIN_ID[chainId];
20
+ return network ? [network] : [];
21
+ }
22
+ function describeSupportedX402Networks(chainId) {
23
+ const networks = supportedX402NetworksForChainId(chainId);
24
+ return networks.length > 0 ? networks.join(', ') : `none for CHAIN_ID ${chainId}`;
25
+ }
26
+ function isTvmOrTonNetwork(network) {
27
+ const normalized = network.toLowerCase();
28
+ return normalized.startsWith('tvm:') || normalized.includes('ton');
29
+ }
30
+ //# sourceMappingURL=x402-networks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402-networks.js","sourceRoot":"","sources":["../../src/utils/x402-networks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAOH,0EAGC;AAED,sEAGC;AAED,8CAGC;AAlBD,MAAM,wBAAwB,GAA2B;IACvD,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAgB,+BAA+B,CAAC,OAAe;IAC7D,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAClC,CAAC;AAED,SAAgB,6BAA6B,CAAC,OAAe;IAC3D,MAAM,QAAQ,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,qBAAqB,OAAO,EAAE,CAAC;AACpF,CAAC;AAED,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,OAAO,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,142 @@
1
+ # Channel-agent affiliate payout controls
2
+
3
+ Axon added off-chain affiliate payouts, a builder dashboard, per-contact payout settings, and prepaid-balance debits on Apr 29. That is the right growth loop for WhatsApp and SMB agents, but it creates payout liability fast.
4
+
5
+ AgentPay MCP should sit at the spend and settlement boundary: cap payouts, require per-contact approval, write audit rows, and optionally settle affiliate shares through x402 when a channel platform is ready for on-chain receipts.
6
+
7
+ ## Control model
8
+
9
+ Affiliate payouts need two separate controls:
10
+
11
+ 1. Spend authority for the paid tool call.
12
+ 2. Payout authority for the revenue share created by that call.
13
+
14
+ Do not bind both to one approval. A user approving a paid API call did not automatically approve an uncapped affiliate liability.
15
+
16
+ ## Required policy fields
17
+
18
+ ```json
19
+ {
20
+ "channel": "whatsapp",
21
+ "agent_id": "agent_123",
22
+ "contact_id_hash": "sha256:...",
23
+ "affiliate_program_id": "axon-affiliate-2026-04",
24
+ "referrer_id_hash": "sha256:...",
25
+ "policy_version": "agentpay-affiliate-policy-2026-04-30",
26
+ "per_contact_approval_required": true,
27
+ "per_contact_daily_payout_cap_usdc": "2.00",
28
+ "per_contact_monthly_payout_cap_usdc": "20.00",
29
+ "agent_daily_payout_cap_usdc": "50.00",
30
+ "program_monthly_payout_cap_usdc": "500.00",
31
+ "max_payout_per_paid_call_usdc": "0.25",
32
+ "settlement_mode": "off_chain_ledger",
33
+ "optional_x402_settlement": true
34
+ }
35
+ ```
36
+
37
+ Hash contact and referrer identifiers in operational logs. Store raw identifiers only in the system that needs to contact or pay the user.
38
+
39
+ ## Per-contact approval gate
40
+
41
+ A contact must be approved before affiliate payout accrual starts.
42
+
43
+ Approval record:
44
+
45
+ ```json
46
+ {
47
+ "approval_id": "approval_contact_789",
48
+ "contact_id_hash": "sha256:...",
49
+ "agent_id": "agent_123",
50
+ "affiliate_program_id": "axon-affiliate-2026-04",
51
+ "approved_by": "operator",
52
+ "approved_at": "2026-04-30T05:14:00Z",
53
+ "expires_at": "2026-05-30T05:14:00Z",
54
+ "policy_version": "agentpay-affiliate-policy-2026-04-30"
55
+ }
56
+ ```
57
+
58
+ Rules:
59
+
60
+ - No approval record, no payout accrual.
61
+ - Expired approval, no payout accrual.
62
+ - Policy version mismatch, route to reapproval.
63
+ - Contact-level cap exceeded, stop accrual for that contact and keep the paid tool policy independent.
64
+ - Program-level cap exceeded, stop all affiliate accrual until the operator raises or resets the cap.
65
+
66
+ ## Audit trail
67
+
68
+ Every affiliate payout decision should write a row before money moves.
69
+
70
+ ```json
71
+ {
72
+ "event_type": "channel_affiliate_payout_decision",
73
+ "channel": "whatsapp",
74
+ "agent_id": "agent_123",
75
+ "contact_id_hash": "sha256:...",
76
+ "referrer_id_hash": "sha256:...",
77
+ "paid_tool_call_id": "tool_call_456",
78
+ "approval_id": "approval_contact_789",
79
+ "policy_version": "agentpay-affiliate-policy-2026-04-30",
80
+ "gross_call_revenue_usdc": "1.00",
81
+ "proposed_payout_usdc": "0.10",
82
+ "decision": "approved",
83
+ "decision_reason": "within_per_contact_and_program_caps",
84
+ "ledger_entry_id": "ledger_abc",
85
+ "x402_settlement_tx": null,
86
+ "created_at": "2026-04-30T05:14:00Z"
87
+ }
88
+ ```
89
+
90
+ Decision reasons should be machine-readable:
91
+
92
+ - `approved`
93
+ - `missing_contact_approval`
94
+ - `contact_daily_cap_exceeded`
95
+ - `contact_monthly_cap_exceeded`
96
+ - `agent_daily_cap_exceeded`
97
+ - `program_monthly_cap_exceeded`
98
+ - `policy_version_mismatch`
99
+ - `settlement_failed`
100
+
101
+ ## Optional x402 settlement path
102
+
103
+ The optional x402 settlement path keeps off-chain affiliate ledgers from becoming a dead end.
104
+
105
+ Off-chain ledgers are useful while channel platforms move quickly. They need a clean path to x402 settlement when payout volumes justify it.
106
+
107
+ Settlement flow:
108
+
109
+ 1. Paid MCP tool call completes under the normal AgentPay MCP policy.
110
+ 2. Affiliate payout decision writes an audit row with `decision: approved`.
111
+ 3. The channel ledger records the pending payout.
112
+ 4. At payout time, AgentPay MCP creates an x402 payment request for the affiliate share.
113
+ 5. Operator policy checks caps again at settlement time.
114
+ 6. Settlement writes `x402_settlement_tx`, `network`, `asset`, and reconciled amount.
115
+
116
+ Do not settle a payout if the approval record has expired between accrual and payout. Reapproval is required.
117
+
118
+ ## Runtime placement
119
+
120
+ ```text
121
+ WhatsApp contact message
122
+ to channel agent intent
123
+ to paid MCP tool call
124
+ to AgentPay spend policy approval
125
+ to x402 paid API settlement
126
+ to affiliate payout decision
127
+ to off-chain ledger or optional x402 affiliate settlement
128
+ to audit readback
129
+ ```
130
+
131
+ AgentPay MCP owns the two financial gates: spend approval before the paid tool call and payout approval before affiliate liability accrues.
132
+
133
+ ## Acceptance checklist
134
+
135
+ - [ ] Affiliate payout policy defines per-contact caps.
136
+ - [ ] Affiliate payout policy defines agent-level and program-level caps.
137
+ - [ ] Contact approval exists before payout accrual.
138
+ - [ ] Approval records include `policy_version`, `approved_at`, and `expires_at`.
139
+ - [ ] Audit rows link the paid tool call, approval record, payout decision, and ledger entry.
140
+ - [ ] Optional x402 settlement records transaction hash and network when used.
141
+ - [ ] Logs hash contact and referrer identifiers by default.
142
+ - [ ] Paid tool spend approval and affiliate payout approval are separate decisions.
@@ -0,0 +1,140 @@
1
+ # AgentPay MCP: HITL Reference Architecture for Payment Authorization
2
+
3
+ > The reference implementation for human-in-the-loop payment workflows in MCP-compatible agents.
4
+
5
+ ## Why HITL Matters
6
+
7
+ McKinsey's 2026 AI Trust Maturity Survey found that only **14.4% of enterprises formally approve AI agents before deployment**, while **88% report at least one agent security incident**. For payment operations specifically, just **18% of enterprises are confident in their agent IAM**.
8
+
9
+ The implication is clear: autonomous agent payments without human oversight are a non-starter for enterprise adoption. The question isn't whether HITL is needed — it's how to implement it without destroying the autonomy that makes agents valuable.
10
+
11
+ ## The Pattern: Suggest → Approve → Execute
12
+
13
+ AgentPay MCP implements a three-phase payment authorization pattern:
14
+
15
+ ```
16
+ Phase 1: SUGGEST
17
+ Agent encounters a paid API (HTTP 402)
18
+ AgentPay MCP evaluates spending policy
19
+ If amount > human_approval_threshold:
20
+ → Payment is BLOCKED (not executed)
21
+ → Human receives approval request
22
+
23
+ Phase 2: APPROVE
24
+ Human reviews: merchant, amount, context
25
+ Human decides: approve or reject
26
+ Decision is logged with timestamp
27
+
28
+ Phase 3: EXECUTE
29
+ If approved → payment executes on-chain
30
+ If rejected → agent receives rejection, adapts
31
+ Full audit trail recorded regardless
32
+ ```
33
+
34
+ ### Code Example: Human-Approval Payment Flow
35
+
36
+ ```python
37
+ from smolagents import CodeAgent, InferenceClientModel
38
+ from smolagents.x402_payment_tool import X402PaymentTool, SpendingPolicy, PaymentMode
39
+
40
+ # Configure HITL: auto-approve under $1, require human approval above
41
+ payment_tool = X402PaymentTool(
42
+ spending_policy=SpendingPolicy(
43
+ mode=PaymentMode.LIVE,
44
+ max_per_transaction=10.00,
45
+ rolling_cap=100.00,
46
+ require_human_approval=True,
47
+ human_approval_threshold=1.00,
48
+ merchant_allowlist=["api.example.com", "data.provider.io"],
49
+ )
50
+ )
51
+
52
+ agent = CodeAgent(
53
+ tools=[payment_tool],
54
+ model=InferenceClientModel(),
55
+ )
56
+
57
+ # Agent workflow:
58
+ # 1. Agent calls api.example.com → gets HTTP 402 for $0.50
59
+ # → Auto-approved (under $1 threshold) → paid → data returned
60
+ #
61
+ # 2. Agent calls data.provider.io → gets HTTP 402 for $3.50
62
+ # → BLOCKED → human sees:
63
+ # "Agent wants to pay $3.50 to data.provider.io — approve? [y/n]"
64
+ # → Human approves → paid → data returned
65
+ # → OR human rejects → agent receives error, tries alternative
66
+ ```
67
+
68
+ ### MCP Server Configuration
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "agentpay": {
74
+ "command": "npx",
75
+ "args": ["agentpay-mcp"],
76
+ "env": {
77
+ "AGENT_PRIVATE_KEY": "0x...",
78
+ "AGENT_WALLET_ADDRESS": "0x..."
79
+ }
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ The HITL behavior is configured via `set_spend_policy` tool:
86
+
87
+ ```json
88
+ {
89
+ "tool": "set_spend_policy",
90
+ "arguments": {
91
+ "perTxCapEth": "0.004",
92
+ "dailyLimitEth": "0.04",
93
+ "requireHumanApproval": true,
94
+ "humanApprovalThreshold": "0.0004",
95
+ "allowedRecipients": ["0x..."]
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## Why This Architecture Works
101
+
102
+ ### 1. Graduated Autonomy
103
+
104
+ Not every payment needs human review. The threshold model lets agents handle routine micropayments autonomously while escalating significant transactions. This preserves agent utility without sacrificing oversight.
105
+
106
+ ### 2. On-Chain Enforcement
107
+
108
+ The spending caps aren't in application code — they're in the AgentAccountV2 smart contract. Even if the agent, the MCP server, or the host application is compromised, the on-chain limits hold. The human-approval gate is the last line of defense, not the only one.
109
+
110
+ ### 3. Audit Trail for Compliance
111
+
112
+ Every payment attempt (approved, rejected, or auto-approved) is logged with:
113
+ - Merchant/recipient address
114
+ - Amount requested
115
+ - Policy evaluation result
116
+ - Human decision (if applicable)
117
+ - On-chain transaction hash (if executed)
118
+
119
+ This gives compliance teams the artifact trail they need for SOC 2, financial audits, and regulatory reporting.
120
+
121
+ ## MCP 2026 Roadmap Alignment
122
+
123
+ The MCP specification is evolving toward mandatory security controls for financial operations:
124
+
125
+ - **CoSAI T9 (Financial Fraud):** AgentPay MCP's HITL pattern directly addresses this threat category
126
+ - **OAuth 2.1 + PKCE:** Enterprise authentication for MCP server access (see [security-posture.md](security-posture.md))
127
+ - **Standardized approval UX:** The `queue_approval` tool provides a consistent interface that MCP clients (Claude Desktop, Cursor, etc.) can render as native approval dialogs
128
+
129
+ ## Production Reference
130
+
131
+ This HITL payment architecture is already in production:
132
+
133
+ - **[NVIDIA NeMo Agent Toolkit Examples PR #17](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17)** — x402 payment tool merged into NVIDIA's official agent toolkit catalog
134
+ - **[smolagents PR #2123](https://github.com/huggingface/smolagents/pull/2123)** — Native x402 payment tool with HITL support, addressing community request [#2112](https://github.com/huggingface/smolagents/issues/2112) for human-in-the-loop payment authorization
135
+
136
+ ## Related Documentation
137
+
138
+ - [Security Posture](security-posture.md) — CoSAI alignment and OAuth 2.1 compliance
139
+ - [README](../README.md) — Full AgentPay MCP documentation
140
+ - [SECURITY.md](../SECURITY.md) — Responsible disclosure process
@@ -0,0 +1,74 @@
1
+ # AgentPay MCP — Security Posture
2
+
3
+ > Last updated: 2026-03-26
4
+
5
+ This document maps AgentPay MCP's security controls to the CoSAI (Coalition for Secure AI) threat taxonomy and MCP 2026 authentication requirements. It is intended for enterprise security teams evaluating MCP servers for production deployment.
6
+
7
+ ## CoSAI Threat Alignment
8
+
9
+ ### T9 — Financial Fraud
10
+
11
+ **Threat:** An AI agent is manipulated (via prompt injection, tool poisoning, or logic error) into making unauthorized payments.
12
+
13
+ **Mitigations in AgentPay MCP:**
14
+
15
+ | Control | Implementation | Bypass Resistance |
16
+ |---------|---------------|-------------------|
17
+ | Per-transaction spending cap | `set_spend_policy` enforced by AgentAccountV2 smart contract | On-chain — cannot be overridden by application code or the agent |
18
+ | Rolling period limits | Daily/weekly caps enforced on-chain | Same — smart contract enforcement |
19
+ | Merchant allowlist | Only pre-approved recipient addresses can receive funds | On-chain enforcement |
20
+ | Human-approval gate | Transactions above configurable threshold queue for human review | Cannot be bypassed — `queue_approval` requires explicit human action |
21
+ | Fail-closed policy engine | Any error in policy evaluation → transaction rejected | Default-deny; no silent pass-through |
22
+ | Full audit trail | Every payment attempt logged: merchant, amount, timestamp, approval status, tx hash | Immutable on-chain record |
23
+
24
+ ### T10 — Identity Spoofing
25
+
26
+ **Threat:** A malicious agent impersonates a legitimate agent to gain access to payment infrastructure or services.
27
+
28
+ **Mitigations in AgentPay MCP:**
29
+
30
+ | Control | Implementation |
31
+ |---------|---------------|
32
+ | ERC-8004 identity verification | `verify_agent_identity` tool validates on-chain agent identity NFTs |
33
+ | Non-custodial key management | Agent private key stored locally; never transmitted to any server |
34
+ | On-chain reputation | `get_reputation` provides verifiable transaction history and trust score |
35
+ | Session token verification | x402 session tokens are ECDSA-signed; any verifier can independently validate |
36
+
37
+ ## OAuth 2.1 + PKCE Compliance
38
+
39
+ MCP 2026 roadmap requires OAuth 2.1 with PKCE for server authentication in enterprise environments.
40
+
41
+ **Current status:**
42
+
43
+ - AgentPay MCP supports configuration via environment variables (`AGENT_PRIVATE_KEY`, `AGENT_WALLET_ADDRESS`) for direct deployment
44
+ - For enterprise SSO: Azure AD and Okta can broker OAuth 2.1 tokens that gate access to the MCP server process
45
+ - PKCE flow: supported when deployed behind an OAuth 2.1-compliant reverse proxy (e.g., Azure API Management, Auth0)
46
+ - The MCP server itself authenticates agents via their on-chain identity (ERC-8004) and wallet signature, which provides cryptographic authentication independent of OAuth
47
+
48
+ **Roadmap:**
49
+
50
+ - Native OAuth 2.1 token validation in the MCP server transport layer (aligned with MCP spec evolution)
51
+ - Mutual TLS option for server-to-server deployments
52
+
53
+ ## MCP Audit Logging
54
+
55
+ Every tool invocation is logged with:
56
+
57
+ - Timestamp (ISO 8601)
58
+ - Tool name and parameters
59
+ - Outcome (success/failure/queued)
60
+ - Transaction hash (for on-chain operations)
61
+ - Policy evaluation result (approved/rejected/queued with reason)
62
+
63
+ Logs are available via `get_transaction_history` tool and can be exported to enterprise SIEM systems.
64
+
65
+ ## Dependency Security
66
+
67
+ - **Zero LiteLLM dependency** — no exposure to the March 2026 PyPI supply chain compromise
68
+ - **Minimal npm dependency tree** — `viem`, `@modelcontextprotocol/sdk`, and auditable packages only
69
+ - **No Python runtime required** — eliminates PyPI supply chain attack surface entirely
70
+ - **NVIDIA-validated** — security posture reviewed as part of [NVIDIA NeMo Agent Toolkit Examples PR #17](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17) merge process
71
+
72
+ ## Contact
73
+
74
+ Security issues: see [SECURITY.md](../SECURITY.md) for responsible disclosure process.
@@ -0,0 +1,127 @@
1
+ # AgentPay MCP Trust Architecture
2
+
3
+ **Simulation Mode · Spend Caps · Human-in-the-Loop · Transaction Explainability**
4
+
5
+ ---
6
+
7
+ ## The Problem: Agent Autonomy Without Trust Infrastructure
8
+
9
+ Autonomous agents that handle money need more than API keys and wallet addresses. They need a trust architecture — a layered system of controls that lets operators grant autonomy incrementally, verify behavior continuously, and intervene instantly when something goes wrong.
10
+
11
+ Enterprise solutions like Visa's Visa Intelligent Commerce (VIC) platform address this for traditional payment flows: pre-authorization, fraud scoring, velocity checks, chargeback handling. But VIC is built for card networks and merchant acquirers. It doesn't speak MCP. It doesn't run locally. It doesn't give developers control over the trust model.
12
+
13
+ AgentPay MCP provides the same trust primitives — simulation, spend controls, human approval, and explainability — in an open-source, developer-native package that runs wherever your agent runs.
14
+
15
+ ---
16
+
17
+ ## Trust Layers
18
+
19
+ ### Layer 1: Simulation Mode
20
+
21
+ Before any real funds move, agents can dry-run a transaction to preview:
22
+
23
+ - **Recipient address** and whether it's on the allowlist
24
+ - **Estimated cost** in the payment token (USDC, ETH)
25
+ - **Gas estimate** for the target chain
26
+ - **Policy evaluation result** — would this transaction be auto-approved, queued, or rejected?
27
+
28
+ Simulation mode gives operators confidence before enabling auto-approve. It's also the right tool for testing new integrations: point your agent at a paid API, see what it would cost, and decide whether to add it to the allowlist — all without spending a cent.
29
+
30
+ **Comparison:** Visa VIC performs pre-authorization checks server-side through the card network. AgentPay performs simulation locally, with results visible to the agent and operator before any network call.
31
+
32
+ ### Layer 2: Per-Call Spend Caps
33
+
34
+ Every transaction is evaluated against on-chain spending policy before execution:
35
+
36
+ - **Per-transaction maximum** — no single call can exceed this amount, regardless of what the agent requests
37
+ - **Enforced by smart contract** — the AgentAccountV2 contract rejects over-cap transactions at the EVM level. Application-layer bugs or agent prompt injection cannot bypass this.
38
+
39
+ This is the most critical trust boundary. Even if an agent is compromised, jailbroken, or simply wrong about what it's buying, the per-call cap limits blast radius to a known, acceptable amount.
40
+
41
+ **Comparison:** Visa VIC enforces transaction limits through issuer-configured velocity rules in the card network. AgentPay enforces them on-chain — no intermediary required, publicly auditable, and immutable once set.
42
+
43
+ ### Layer 3: Daily Aggregate Caps
44
+
45
+ Per-call caps prevent single large losses. Daily caps prevent death by a thousand cuts:
46
+
47
+ - **Rolling daily limit** — total spend across all transactions resets on a configurable period
48
+ - **On-chain enforcement** — same smart contract, same immutability guarantees
49
+ - **Budget visibility** — agents can call `check_budget` to see remaining allowance before starting expensive workflows
50
+
51
+ An agent running a 50-item enrichment loop at $0.10 each hits $5.00 total. If the daily cap is $10, the agent knows it has $5 left. If the loop was supposed to be 500 items due to a bug, the cap stops it at 100.
52
+
53
+ **Comparison:** VIC uses velocity checks (transaction count and amount per time window) configured at the issuer level. AgentPay's daily caps serve the same function, configured by the wallet owner.
54
+
55
+ ### Layer 4: Human-in-the-Loop Approval
56
+
57
+ Not every transaction should be automatic. AgentPay's HITL system queues transactions that exceed the auto-approve threshold:
58
+
59
+ - **Threshold-based routing** — under threshold: auto-approved and executed. Over threshold: queued for human review.
60
+ - **Queue inspection** — operators see pending transactions with full context (merchant, amount, tool that triggered it, agent reasoning)
61
+ - **Approve or reject** — explicit human decision. Rejection returns a structured error to the agent, which can adapt (use cached data, try a cheaper source, ask the user).
62
+ - **Fail-closed** — if the approval system errors, the default is rejection. Never approval.
63
+
64
+ HITL is the default mode. Operators opt *into* automation by raising thresholds, not opt *out* of oversight by lowering them. Trust is earned incrementally.
65
+
66
+ **Comparison:** Visa VIC routes high-risk transactions to manual review queues via issuer fraud teams. AgentPay routes them to the operator directly — no intermediary, no SLA dependency on a third-party fraud team.
67
+
68
+ ### Layer 5: Transaction Explainability
69
+
70
+ Every transaction — approved, rejected, queued, or simulated — produces a structured audit record:
71
+
72
+ - **Timestamp** (block time + local time)
73
+ - **Merchant/recipient** address and resolved name (if available)
74
+ - **Amount** in payment token and USD equivalent
75
+ - **Policy evaluation** — which rule triggered (auto-approve, cap exceeded, allowlist miss)
76
+ - **Approval path** — auto-approved, human-approved, or rejected (with reason)
77
+ - **On-chain transaction hash** — independently verifiable on any block explorer
78
+
79
+ This isn't just logging. It's the artifact that security teams, compliance officers, and auditors need to answer: "What did this agent spend money on, why, and who approved it?"
80
+
81
+ **Comparison:** Visa VIC generates transaction records through the card network's settlement process. AgentPay generates them on-chain — immutable, publicly verifiable, and available in real-time (not T+1 or T+2 settlement).
82
+
83
+ ---
84
+
85
+ ## Trust Model Comparison
86
+
87
+ | Trust Primitive | Visa VIC (Enterprise) | AgentPay MCP (Open Source) |
88
+ |---|---|---|
89
+ | Pre-transaction simulation | Pre-authorization via card network | Local simulation mode, no network call |
90
+ | Per-transaction limits | Issuer-configured velocity rules | On-chain smart contract enforcement |
91
+ | Aggregate spend caps | Velocity checks per time window | On-chain daily caps, agent-queryable |
92
+ | Human review routing | Issuer fraud team queues | Direct operator HITL, fail-closed |
93
+ | Transaction audit trail | Card network settlement records (T+1/T+2) | On-chain, real-time, publicly verifiable |
94
+ | Integration model | Enterprise API + card network onboarding | `npm install` + MCP config |
95
+ | Source availability | Proprietary | MIT open source |
96
+ | Protocol native | Card networks (ISO 8583) | MCP + x402 (HTTP 402) |
97
+ | Agent-native controls | No (designed for human cardholders) | Yes (agents query budget, adapt to rejections) |
98
+
99
+ ---
100
+
101
+ ## Deployment Progression
102
+
103
+ Trust should be granted incrementally. Here's the recommended progression:
104
+
105
+ 1. **Simulation only** — Agent runs, simulates all payments, logs what it would spend. Zero risk.
106
+ 2. **HITL with low threshold** — Auto-approve micro-payments ($0.10), queue everything else. Operator reviews daily.
107
+ 3. **HITL with raised threshold** — After reviewing transaction patterns, raise auto-approve to $1-$5. Queue large transactions.
108
+ 4. **Full auto with daily cap** — High-confidence workflows get full auto-approve with a daily ceiling. Operator reviews weekly.
109
+ 5. **Multi-agent with per-agent caps** — Each agent gets its own wallet with independent caps. Blast radius is isolated per agent.
110
+
111
+ At no point does the operator lose the ability to intervene. Every stage is reversible by lowering thresholds or enabling simulation mode.
112
+
113
+ ---
114
+
115
+ ## For Enterprise Security Teams
116
+
117
+ If you're evaluating agent payment infrastructure:
118
+
119
+ - **Smart contract source** is verified and auditable on-chain
120
+ - **Dependency tree** is minimal — zero LiteLLM, zero Python runtime, auditable with `npm ls`
121
+ - **NVIDIA validation** — integrated into [NVIDIA NeMo Agent Toolkit Examples](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17) (PR #17, merged)
122
+ - **CoSAI alignment** — addresses T9 (Financial Fraud) and T10 (Identity Spoofing) threat categories
123
+ - **Security posture doc** — see [`security-posture.md`](security-posture.md) for the full compliance matrix
124
+
125
+ ---
126
+
127
+ *AgentPay MCP is MIT licensed. Built by [AI Agent Economy](https://ai-agent-economy.com).*