@vapi-network/mcp 0.2.2 → 0.3.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 CHANGED
@@ -1,336 +1,14 @@
1
- # vAPI Network
1
+ # `@vapi-network/mcp`
2
2
 
3
- **One wallet, every x402 API.** vAPI Network is an open-source, non-custodial
4
- TypeScript toolkit for discovering and paying x402 services from a CLI, MCP
5
- client, or your own code. Call works today. Tasks and Compute are next.
3
+ The stdio MCP server behind `vapi mcp`: namespaced tools that let an agent
4
+ search the vAPI catalogue, read a listing's request contract, pay an x402 API
5
+ from a local wallet, and read balances and receipts. It never creates, renames,
6
+ removes, backs up or exports a wallet, and no tool of its returns a recovery
7
+ phrase, a private key or a passphrase.
6
8
 
7
- Your key stays encrypted on your machine. vAPI Network applies spend policy
8
- before signing, sends payment directly to the service, and writes receipts to a
9
- local append-only ledger. It does not hold funds, proxy payments, or send
10
- telemetry off the machine by default.
9
+ One entry point, `@vapi-network/mcp`, exporting `createVapiServer`,
10
+ `startStdioServer`, `loadServerConfig`, `WalletSession` and the individual
11
+ `callService`, `inspectService`, `searchMarketplace` and `getWallet` tools.
11
12
 
12
- ## 60-second quickstart
13
-
14
- Install once, then every command is `vapi …`:
15
-
16
- ```bash
17
- npm i -g vapi-network
18
- vapi init # encrypted wallet + config under ~/.vapi (or $VAPI_HOME), prints the address
19
- ```
20
-
21
- Fund that address with `vapi fund` (card or Apple Pay via Coinbase Onramp) or by
22
- sending USDC on Base to it. Then:
23
-
24
- ```bash
25
- vapi fund # hosted onramp link, or direct-transfer instructions
26
- vapi search "weather" # every catalog, merged, with provenance
27
- vapi inspect <listing-ref> # request contract and the live 402 quote, before paying
28
- vapi pay <listing-ref> --max 0.02
29
- vapi balance
30
- vapi accounts # balances plus network-specific deposit guidance
31
- vapi receipts # one line per paid call: quote, settlement, latency
32
- ```
33
-
34
- `vapi search` tags each listing with its group — `[vapi]`, `[added]`,
35
- `[partner]`, or `[external]` — and prints the network fee already inside the
36
- price: vAPI and added APIs carry a 5% network fee inside the quoted price, while
37
- partner and external listings carry none. `vapi inspect` and `--json` return the
38
- same `group` and `fee` fields.
39
-
40
- No install? Prefix any command with `npx vapi-network`, for example `npx vapi-network init`.
41
- (`npx vapi` cannot work: the bare `vapi` name on npm belongs to an unrelated package.)
42
-
43
- ### Use it from an agent (MCP)
44
-
45
- Add this to Claude Desktop, Claude Code, or Cursor. The passphrase unlocks the local keystore; it never leaves the machine.
46
-
47
- ```json
48
- {
49
- "mcpServers": {
50
- "vapi": {
51
- "command": "npx",
52
- "args": ["-y", "vapi-network", "mcp"],
53
- "env": { "VAPI_KEYSTORE_PASSWORD": "your-passphrase" }
54
- }
55
- }
56
- }
57
- ```
58
-
59
- Tools: `call.search`, `call.inspect`, `call.pay`, `wallet.address`, `wallet.balance`,
60
- `wallet.accounts`, `wallet.fund`, `receipts.list`, `receipts.stats`, `support.report`. Spend caps
61
- default to $0.10 per call and $1.00 per day; the wallet checks both before it signs a payment.
62
-
63
- ## Sign-in with X
64
-
65
- x402 v2 services can require Sign-In-With-X (SIWX) before returning a price. When `call.pay` or
66
- `vapi pay` receives that challenge, vAPI checks that both the challenge domain and URI match the
67
- final resource origin, signs the canonical EIP-4361 message locally with EVM `personal_sign`, and
68
- retries once with `SIGN-IN-WITH-X`. The proof is never sent to a redirect or a different host.
69
-
70
- If the retry returns a normal 402 quote, the usual spend-policy and payment flow continues. If the
71
- resource is free after sign-in, the result has `outcome: "signed_in"` and the local receipt records
72
- `amountAtomic: "0"`.
73
-
74
- ## Fund the wallet
75
-
76
- ```bash
77
- vapi fund # ask the registry for a hosted onramp session
78
- vapi fund --amount 25 # prefill a US dollar amount
79
- vapi fund --json # stable machine-readable shape
80
- ```
81
-
82
- `vapi fund` POSTs `{ address, network: "base", asset: "USDC", fiatAmount }` to
83
- `<registry>/api/wallet/onramp-session` through the same guarded network client as
84
- every other command, prints the returned URL, and opens it in your default
85
- browser when you are on a terminal. The onramp is **Coinbase's**: Coinbase takes
86
- the card or Apple Pay payment and sends USDC straight to your local address.
87
- **vAPI never holds your funds**, never proxies the payment, and never sees your
88
- card details or your private key.
89
-
90
- When the registry replies `503 onramp_unavailable` — or cannot be reached at all
91
- — the command stays useful instead of failing: it prints your address and
92
-
93
- ```text
94
- Send USDC on Base (eip155:8453) to this address; add a little ETH for gas if you plan to sweep.
95
- ```
96
-
97
- Either way it finishes by printing the current balance. MCP clients can use the
98
- `wallet.fund` tool, which returns the same `{ url }` or the same fallback text.
99
-
100
- ## Accounts and deposits
101
-
102
- `vapi accounts` lists one deposit account for every configured network, including its CAIP-2 ID,
103
- network name, address, atomic and formatted USDC balance, gas-token balance, and deposit guidance.
104
- Use `--json` for the stable `{ "accounts": [...] }` shape. `vapi init` prints the same account list
105
- after creating the encrypted keystore and configuration. MCP clients can use `wallet.accounts`.
106
-
107
- Base uses the wallet's EVM address and tells you to send USDC on Base. For Arc testnet, add the
108
- faucet URL or instructions to that network's `config.json` entry:
109
-
110
- ```json
111
- {
112
- "depositUrl": "https://your-arc-faucet.example",
113
- "depositInstructions": "Use the configured Arc testnet faucet, then send USDC to this address."
114
- }
115
- ```
116
-
117
- Account lookup dispatches by CAIP namespace: the EVM and Solana adapters use their corresponding
118
- local address and guarded RPC balance calls without coupling one wallet family to the other.
119
-
120
- ## Reporting a bug
121
-
122
- ```bash
123
- vapi report "the provider returned 402 twice"
124
- vapi report "the provider returned 402 twice" --include-addresses
125
- vapi report "the provider returned 402 twice" --send
126
- ```
127
-
128
- The command first writes `$VAPI_HOME/reports/<timestamp>.json`, then prints that path and a prefilled
129
- GitHub issue URL. Reports contain the message, client version, OS/Node information, and only the
130
- newest five receipt IDs. Wallet and payee addresses are included only with `--include-addresses`;
131
- amounts are never included. No report is uploaded unless `--send` is explicit. With `--send`, vAPI
132
- uses the guarded network client to POST the same JSON to the configured registry and prints the HTTP
133
- response code, including non-success responses such as 404. MCP clients can use `support.report`
134
- with the corresponding `includeAddresses` and `send` booleans.
135
-
136
- ## Networks
137
-
138
- | Network | x402 identifier | USDC | Gas / RPC notes |
139
- | -------------- | ----------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------ |
140
- | Base mainnet | `eip155:8453` | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | ETH; defaults to `https://mainnet.base.org` |
141
- | Arc testnet | `eip155:5042002` | `0x3600000000000000000000000000000000000000` | USDC is also the gas token; set `ARC_TESTNET_RPC_URL` |
142
- | Solana mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | SOL; defaults to `https://api.mainnet-beta.solana.com` |
143
-
144
- The x402 reference packages shorten the Solana CAIP-2 reference to
145
- `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`; vAPI accepts that identifier as an
146
- alias while persisting the full genesis hash above. Arc mainnet is not enabled:
147
- **not yet — placeholder only.** Arc and the x402 packages do not publish a
148
- mainnet RPC plus canonical USDC, so the client deliberately carries only a
149
- non-routable code placeholder instead of guessing a production configuration.
150
-
151
- Create both local accounts during initialization:
152
-
153
- ```bash
154
- vapi init --networks base,solana
155
- ```
156
-
157
- Or add an Ed25519 account to an existing encrypted keystore:
158
-
159
- ```bash
160
- vapi accounts --enable solana
161
- ```
162
-
163
- Fund the printed Solana address with SPL USDC. Exact x402 payments use the
164
- facilitator advertised in the challenge as fee payer, so they do not consume the
165
- local SOL balance. `vapi sweep <solana-address> --network
166
- solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d` is a separate transaction
167
- and requires a small amount of SOL locally for fees and, when necessary,
168
- creation of the destination token account. The default public Solana RPC is
169
- rate-limited and has no availability guarantee; set `SOLANA_RPC_URL` to a
170
- trusted dedicated endpoint for regular use.
171
-
172
- ## Discovery sources
173
-
174
- Discovery is a plugin interface. The client can merge listings from multiple
175
- sources, de-duplicate them by resource URL, and retain each listing's
176
- provenance:
177
-
178
- - **vAPI Registry** is enabled by the default distribution, using
179
- `https://api.vapinetwork.ai/api/call/discovery` for discovery and
180
- `https://api.vapinetwork.ai/api/call/services` for service details. If the
181
- primary returns HTTP 404 or cannot be resolved, the client logs one notice
182
- and tries the configured fallback at `https://console.vapinetwork.ai`, using
183
- the same canonical paths. The registry's historical `/api/marketplace/discovery`
184
- and `/api/network/services` paths still answer for one release and reply with
185
- `Deprecation: true` plus a `Link` header naming the successor; a base URL
186
- supplied on either of them is normalized to the canonical pair.
187
- - **Coinbase Bazaar** reads the public x402 v2
188
- `/discovery/resources` catalog exposed by a facilitator.
189
- - **Local file** reads a JSON array of listings for private or development
190
- catalogs.
191
- - **x402scan** is a deliberate stub for now. The source research documents its
192
- discovery convention, but not a stable public read API that this client can
193
- safely target.
194
-
195
- Use `@vapi-network/sources` to compose only the catalogs you trust. Network
196
- access is guarded against local and private destinations before a request is
197
- made.
198
-
199
- Set `VAPI_REGISTRY_URL` to replace the registry base; the client derives
200
- `/api/call/discovery` and `/api/call/services` beneath it. The existing
201
- `VAPI_MARKETPLACE_DISCOVERY_URL` and `VAPI_DISCOVERY_URL` variables can still
202
- override either full endpoint separately. Registry fallbacks are stored in
203
- `config.json` under `registryFallbacks`.
204
-
205
- ## Packages
206
-
207
- | Package | Purpose |
208
- | ----------------------- | ------------------------------------------------------------------------ |
209
- | `@vapi-network/core` | x402 protocol, wallet, spend policy, discovery merge, and receipts |
210
- | `@vapi-network/sources` | vAPI Registry, Coinbase Bazaar, local-file, and x402scan source adapters |
211
- | `@vapi-network/mcp` | stdio MCP server with namespaced payment tools |
212
- | `@vapi-network/cli` | `init`, discovery, payment, wallet, receipt, and MCP commands |
213
- | `vapi-network` | zero-dependency distribution with the `vapi` binary and defaults |
214
-
215
- Every npm tarball is bundled and has zero runtime dependencies. The scoped
216
- packages are useful for embedding; most users should start with
217
- `vapi-network`.
218
-
219
- ## SDK
220
-
221
- The core and source packages can be used without the CLI or MCP layer. See the
222
- runnable [SDK example](./examples/pay-with-sdk.ts) for discovery, policy
223
- validation, local signing, and direct x402 payment construction.
224
-
225
- Run it after initialization with `pnpm example:pay -- weather`.
226
-
227
- ## Local state and migration
228
-
229
- By default, local state lives in `~/.vapi/`:
230
-
231
- ```text
232
- config.json
233
- keystore.json
234
- receipts.jsonl
235
- spend-ledger.json
236
- reports/
237
- ```
238
-
239
- Set `VAPI_HOME` to use a different directory. On first use of the default home,
240
- the client copies an existing `~/.vapi/agent-cash/` configuration into
241
- `~/.vapi/` when it can do so without overwriting files, prints a migration
242
- notice, and leaves the old directory untouched.
243
-
244
- ## Metrics
245
-
246
- vAPI measures call and discovery health locally. Call receipts can include the
247
- listing name and provider host, policy decision, retry count, client version,
248
- outcome, total latency, and discovery, quote, signing, request, and settlement
249
- phase timings. Policy declines are recorded with the quoted amount but without
250
- a payer or transaction, so blocked spend remains visible without creating a
251
- payment authorization. Search events record the query, sources tried,
252
- per-source latency and result count, merged result count, and timestamp.
253
-
254
- Call receipts are appended to `$VAPI_HOME/receipts.jsonl`; search events are
255
- appended to `$VAPI_HOME/searches.jsonl`. Nothing in either ledger is uploaded,
256
- and vAPI sends no telemetry off the machine by default. The vAPI website can
257
- show public on-chain usage for a wallet address directly from the chain; that
258
- view does not require uploading these local files.
259
-
260
- Use `vapi stats --range 24h|7d|30d` for a human-readable summary or add `--json`
261
- for the stable `{ range, generatedAt, totals, outcomes, latency, topServices,
262
- search }` shape. `receipts.stats` exposes the same shape through MCP. Export raw
263
- receipts for spreadsheets and dashboards with:
264
-
265
- ```sh
266
- vapi receipts export --format json --range 30d
267
- vapi receipts export --format csv --range 30d
268
- ```
269
-
270
- ## Roadmap
271
-
272
- - A local gateway daemon (`vapi serve`) with per-key budgets
273
- - OpenTelemetry traces and metrics, with exporters enabled only by the user
274
- - `task.*` tools for posting, funding, delivering, and reviewing work
275
- - `compute.*` tools for discovering models and paying for inference
276
-
277
- Until the gateway lands, `vapi serve` and the provider-side `vapi publish`
278
- command exit with a preview message. Payments remain direct from the local
279
- wallet to each service.
280
-
281
- ## Development
282
-
283
- This is a pnpm workspace for Node.js 22 and pnpm 10.
284
-
285
- ```sh
286
- pnpm install
287
- pnpm lint
288
- pnpm typecheck
289
- pnpm test
290
- pnpm build
291
- pnpm pack:check
292
- ```
293
-
294
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development workflow,
295
- [CHANGELOG.md](./CHANGELOG.md) for what shipped in each release, and
296
- [SECURITY.md](./SECURITY.md) for private vulnerability reports.
297
-
298
- CLI commands exit `0` on success, `1` on an operational failure, and `2` for
299
- invalid usage or an announced preview-only command. `--json` sends both success
300
- values and errors to stdout as one JSON value; `mcp --json` is accepted as a
301
- no-op because the stdio transport is already JSON-RPC.
302
-
303
- ## Publishing
304
-
305
- All five packages share one version and are published together. npm reads a
306
- package manifest before lifecycle hooks run, so the release is made from the
307
- generated `publish/` directories, never from the workspace package roots.
308
-
309
- First update every package to the same version and verify the exact tarballs:
310
-
311
- ```sh
312
- pnpm install --frozen-lockfile
313
- pnpm pack:check
314
- ```
315
-
316
- After reviewing the output, a maintainer with npm access runs these commands
317
- manually:
318
-
319
- ```sh
320
- npm login
321
- pnpm --dir packages/core publish:npm
322
- pnpm --dir packages/sources publish:npm
323
- pnpm --dir packages/mcp publish:npm
324
- pnpm --dir packages/cli publish:npm
325
- pnpm --dir packages/vapi-network publish:npm
326
- ```
327
-
328
- Each package's `publish:npm` script publishes its staged `./publish` directory
329
- to the `latest` npm tag. Every package also has a `publish:npm:next` script that
330
- publishes the same tarball to `next` instead, for preview builds. The manual
331
- release workflow verifies and prints these commands; it never receives npm
332
- credentials or publishes automatically.
333
-
334
- ## License
335
-
336
- Apache-2.0. See [LICENSE](./LICENSE).
13
+ See the [root README](https://github.com/vAPI-Network/vapi-network#readme) for
14
+ the editor configuration, the full tool table and the deprecated aliases.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { callService, createVapiServer, loadServerConfig, startStdioServer, type CallToolInput, type CallToolResult, type VapiServerOptions, } from "./server.js";
2
2
  export { inspectService, type InspectToolInput, type InspectToolResult } from "./tools/inspect.js";
3
3
  export { resolveServiceEndpoint, resolveServiceListing, searchMarketplace, type MarketplaceSearchInput, } from "./tools/search.js";
4
- export { getWallet, type WalletBalance } from "./tools/wallet.js";
4
+ export { getWallet, type WalletAddresses, type WalletBalance } from "./tools/wallet.js";
5
+ export { WalletSession, type SessionWallet, type SessionWalletInfo, type WalletSessionOptions, } from "./wallet-session.js";
5
6
  export { buildSIWxProof, parseSIWxResponse } from "./siwx.js";