@vapi-network/mcp 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 ADDED
@@ -0,0 +1,176 @@
1
+ # Agent Cash (`@vapi-network/mcp`)
2
+
3
+ Agent Cash gives Claude, Cursor, and other MCP clients a small local wallet that
4
+ can discover and pay x402 APIs directly.
5
+
6
+ For the Call launch, this buyer-local client is the npm-distributed payment path
7
+ for native and external Bazaar listings. The browser-wallet flow is also
8
+ available where a provider permits a direct browser request. Legacy wrapped
9
+ rows remain hidden and non-callable while the optional Wrap gateway is disabled.
10
+ The hosted Go MCP remains free (`echo` and `search`).
11
+
12
+ The private key is generated locally and stored only in the Agent Cash home
13
+ (default `~/.vapi/agent-cash`, overridden by `VAPI_AGENT_CASH_HOME`), encrypted
14
+ with scrypt (`N=2^15`) and AES-256-GCM. Your MCP client signs each exact
15
+ EIP-3009 payment locally. vAPI supplies public discovery metadata; it never
16
+ receives the private key and cannot spend the wallet balance. Fund this like
17
+ pocket money, not a treasury.
18
+
19
+ Direct x402 calls need no vAPI account or API key: the agent pays the selected
20
+ API directly from the buyer-controlled wallet.
21
+
22
+ ## Install and run
23
+
24
+ Create the encrypted local wallet:
25
+
26
+ ```sh
27
+ npx -y @vapi-network/mcp init
28
+ ```
29
+
30
+ Running `npx -y @vapi-network/mcp` with no command starts the MCP stdio server.
31
+
32
+ Fund the printed address with a small amount of canonical Base-mainnet USDC
33
+ (`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`). Agent Cash does not need ETH to
34
+ authorize ordinary x402 calls; send a little Base ETH only if you want it to
35
+ sweep USDC back to another wallet later.
36
+
37
+ Configure an MCP client to launch the package through npm:
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "agent-cash": {
43
+ "command": "npx",
44
+ "args": ["-y", "@vapi-network/mcp", "serve"],
45
+ "env": {
46
+ "VAPI_KEYSTORE_PASSWORD": "replace-with-your-keystore-passphrase"
47
+ }
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ `VAPI_AGENT_CASH_HOME` optionally moves the wallet directory from
54
+ `~/.vapi/agent-cash`. Desktop MCP hosts normally need
55
+ `VAPI_KEYSTORE_PASSWORD` in the process environment because they cannot answer
56
+ an interactive passphrase prompt. Protect that configuration with the same
57
+ care as the pocket-money wallet.
58
+
59
+ For a workspace-only development run, build from the repository root and keep
60
+ the test wallet isolated under the gitignored `.context` directory:
61
+
62
+ ```sh
63
+ pnpm --filter @vapi-network/mcp build
64
+ VAPI_AGENT_CASH_HOME="$PWD/.context/agent-cash" \
65
+ pnpm --filter @vapi-network/mcp exec node dist/cli.js init
66
+ ```
67
+
68
+ For the first staging test, send a small amount of Base USDC to the printed
69
+ address. Also send a little Base ETH only if you intend to test sweep-back.
70
+
71
+ Then point the MCP client at the built CLI. Replace both absolute paths with
72
+ this checkout's paths:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "agent-cash": {
78
+ "command": "node",
79
+ "args": ["/absolute/path/to/vapi-app/packages/vapi-mcp/dist/cli.js", "serve"],
80
+ "env": {
81
+ "VAPI_AGENT_CASH_HOME": "/absolute/path/to/vapi-app/.context/agent-cash",
82
+ "VAPI_KEYSTORE_PASSWORD": "replace-with-your-keystore-passphrase"
83
+ }
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ Base uses its public RPC by default. Leave `ARC_TESTNET_RPC_URL` unset for the
90
+ Base-only staging slice.
91
+
92
+ Restart the MCP client. The agent can now:
93
+
94
+ - `search {query?, kinds?, network?, limit?, cursor?}` across the public
95
+ marketplace. API results are callable; other results carry their canonical
96
+ vAPI web action.
97
+ - `call {id|url, method?, body?, maxPriceUsd?, network?}` and pay an x402
98
+ `exact` challenge directly over HTTPS. An `id` must be an API ref returned by
99
+ `search` in the current Agent Cash process; an explicit published `url` may be
100
+ called directly. Set `network` to require a specific configured CAIP-2
101
+ network before Agent Cash signs.
102
+ - `wallet {}` to inspect the address and USDC balance on each network.
103
+
104
+ `tools/list` exposes exactly these three tools: `search`, `call`, and `wallet`.
105
+
106
+ ## Spend caps
107
+
108
+ The Agent Cash home's `config.json` contains atomic-USDC caps (USDC has 6 decimals):
109
+
110
+ ```json
111
+ {
112
+ "spendCaps": {
113
+ "perCallAtomic": "100000",
114
+ "perDayAtomic": "1000000"
115
+ }
116
+ }
117
+ ```
118
+
119
+ Those defaults are $0.10 per call and $1.00 per UTC day. Agent Cash checks both caps and reserves the quote in its atomic local daily ledger **before signing**. `maxPriceUsd` can set a still-lower ceiling for one tool call. The ledger is `spend-ledger.json` in the same Agent Cash home and rolls over when the UTC date changes.
120
+
121
+ The `call` tool requires HTTPS and blocks private, loopback, and link-local destinations by default. It validates every redirect before carrying a method or body forward. For local development only, setting `"allowPrivateNetwork": true` in `~/.vapi/agent-cash/config.json` permits an unpaid HTTP `localhost`, `*.localhost`, or loopback request; it does not permit HTTP calls to remote hosts, and Agent Cash still refuses to send a signed payment over HTTP.
122
+
123
+ `discoveryUrl` remains the Calls compatibility endpoint used to resolve a
124
+ searched native vAPI ref into its payable endpoint. `marketplaceDiscoveryUrl`
125
+ is the unified search route. Override them independently with
126
+ `VAPI_DISCOVERY_URL` and `VAPI_MARKETPLACE_DISCOVERY_URL`. Agent Cash rejects an
127
+ uncached or evicted `id` because its source and marketplace kind are no longer
128
+ known; run `search` again or use the result's explicit published URL. It never
129
+ attempts to call a service offer or open request; those actions continue in the
130
+ web marketplace.
131
+
132
+ ## Paid-call receipts
133
+
134
+ The `call` result keeps both payment receipt surfaces under `payment`:
135
+
136
+ - `settlement` is the decoded x402 `Payment-Response` (or compatible `X-Payment-Response`) header.
137
+ - `proof` is normally `null` for launch-approved native endpoints. Agent Cash
138
+ preserves an `X-VAPI-Payment-Proof` value if a future reviewed Wrap endpoint
139
+ returns one.
140
+
141
+ A proof value alone is not verification. A future Wrap consumer must pin and
142
+ verify its signer and fields and enforce replay protection.
143
+
144
+ ## Balances and sweep-back
145
+
146
+ ```sh
147
+ VAPI_AGENT_CASH_HOME="$PWD/.context/agent-cash" pnpm --filter @vapi-network/mcp exec node dist/cli.js balance
148
+ VAPI_AGENT_CASH_HOME="$PWD/.context/agent-cash" pnpm --filter @vapi-network/mcp exec node dist/cli.js sweep-back 0xYourMainWallet
149
+ VAPI_AGENT_CASH_HOME="$PWD/.context/agent-cash" pnpm --filter @vapi-network/mcp exec node dist/cli.js sweep-back 0xYourMainWallet --network eip155:8453
150
+ ```
151
+
152
+ Without `--network`, sweep-back attempts every configured network. Base transfers the full USDC balance because gas is paid in ETH. Arc gas is paid in USDC, so Agent Cash keeps 0.05 USDC by default instead of stranding the sweep transaction. Configure that reserve with `VAPI_ARC_GAS_HEADROOM_USDC` (for example, `0.10`).
153
+
154
+ ## Networks
155
+
156
+ | Network | CAIP-2 | Chain ID | USDC | Gas token | RPC |
157
+ | ------------ | ---------------- | -------: | -------------------------------------------- | --------- | ------------------------------------------------------ |
158
+ | Base mainnet | `eip155:8453` | 8453 | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | ETH | `BASE_RPC_URL`, defaults to `https://mainnet.base.org` |
159
+ | Arc testnet | `eip155:5042002` | 5042002 | `0x3600000000000000000000000000000000000000` | USDC | `ARC_TESTNET_RPC_URL` is required |
160
+
161
+ Agent Cash configures Base only by default. For the staging test, first run
162
+ `search {"query":"<capability>","kinds":["api"],"network":"eip155:8453"}`.
163
+ In the same Agent Cash process, call the returned ref with
164
+ `call {"id":"<search-result-ref>","network":"eip155:8453","maxPriceUsd":"0.02"}`.
165
+ Arc remains opt-in: set a nonblank `ARC_TESTNET_RPC_URL` to add it. The same
166
+ exact-scheme EIP-3009 code path handles both CAIP-2 networks. You can also edit
167
+ the `networks` map in `~/.vapi/agent-cash/config.json`; entries with blank RPC
168
+ URLs are ignored and cannot be selected for payment. A custom token/network
169
+ entry must pin its EIP-712 domain as `"eip712Domain": { "name": "…", "version":
170
+ "…" }`; provider-supplied domain text is never trusted on its own.
171
+
172
+ ## Custody and recovery
173
+
174
+ This package is self-custodied software: the encrypted payment key and spend ledger live on your machine. vAPI is discovery only in this lane. Vendors receive only narrowly scoped EIP-3009 authorizations for the exact quoted amount, recipient, token, chain, nonce, and validity window. A stolen unlocked key or passphrase can still drain the wallet, so keep only a small working balance and sweep unused funds back.
175
+
176
+ Back up the encrypted keystore if you need recovery. Losing both the keystore and its backup permanently loses access to its funds; losing the passphrase does too. Never share the decrypted private key.