@caravo/mcp 0.1.17 → 0.1.19

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 (2) hide show
  1. package/dist/index.js +32 -63
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import { homedir } from "os";
22
22
  import { join } from "path";
23
23
  import { loadOrCreateWallet } from "./wallet.js";
24
24
  import { fetchWithX402 } from "./x402.js";
25
- const API_BASE = process.env.CARAVO_URL ?? "https://caravo.ai";
25
+ const API_BASE = process.env.CARAVO_URL ?? "https://www.caravo.ai";
26
26
  // ─── Shared description blocks (used in both `instructions` and `search_tools`) ─
27
27
  const ABOUT_CARAVO = "Caravo (https://caravo.ai) — the API marketplace for AI agents. 200+ tools at $0.001–$0.05/call.\n" +
28
28
  "Docs & source: https://github.com/Caravo-AI/Caravo-MCP";
@@ -123,8 +123,8 @@ async function apiPost(path, body) {
123
123
  if (!API_KEY)
124
124
  return (await fetchWithX402(url, opts, wallet)).json();
125
125
  const r = await fetch(url, opts);
126
- if (r.status === 401 || r.status === 403) {
127
- process.stderr.write("[caravo] API key auth failed, falling back to x402\n");
126
+ if (r.status === 401 || r.status === 403 || r.status === 402) {
127
+ process.stderr.write(`[caravo] API key request failed (${r.status}), falling back to x402\n`);
128
128
  const x402Opts = {
129
129
  method: "POST",
130
130
  headers: { "Content-Type": "application/json" },
@@ -219,6 +219,32 @@ function formatOutput(output) {
219
219
  }
220
220
  return lines;
221
221
  }
222
+ function buildPaymentRequiredMessage(price) {
223
+ const VALUE_PROP = "Top up once to unlock 200+ tools at $0.001–$0.05/call — generate images & videos, analyze website traffic, research academic papers, pull social media analytics, get real-time financial data, and much more.";
224
+ if (API_KEY) {
225
+ // Logged in but both balance and wallet are empty
226
+ return [
227
+ `Payment required (${price}). Your Caravo balance is insufficient and your wallet has no USDC.`,
228
+ ``,
229
+ `Top up your Caravo balance at https://www.caravo.ai/dashboard`,
230
+ `Or send USDC on Base to ${wallet.address}`,
231
+ ``,
232
+ VALUE_PROP,
233
+ ].join("\n");
234
+ }
235
+ // Not logged in
236
+ return [
237
+ `Payment required (${price}). Two options:`,
238
+ ``,
239
+ `Option A — Caravo balance (recommended):`,
240
+ ` Run the "login" tool to connect your account, then top up at https://www.caravo.ai/dashboard`,
241
+ ``,
242
+ `Option B — USDC wallet (no registration):`,
243
+ ` Send USDC on Base to ${wallet.address}`,
244
+ ``,
245
+ VALUE_PROP,
246
+ ].join("\n");
247
+ }
222
248
  function buildReviewPrompt(execId) {
223
249
  if (!execId)
224
250
  return [];
@@ -247,37 +273,9 @@ function makeFavToolHandler(tool) {
247
273
  };
248
274
  }
249
275
  if (result.x402Version || result.accepts) {
276
+ const price = `$${tool.pricing.price_per_call}`;
250
277
  return {
251
- content: [
252
- {
253
- type: "text",
254
- text: [
255
- `Payment required for ${tool.name} ($${tool.pricing.price_per_call}). Two options:`,
256
- ``,
257
- `Option A — Caravo balance (recommended):`,
258
- ` Run the "login" tool to connect your account, then top up at https://caravo.ai/dashboard`,
259
- ``,
260
- `Option B — USDC wallet (no registration):`,
261
- ` Send USDC on Base to ${wallet.address}`,
262
- ].join("\n"),
263
- },
264
- ],
265
- isError: true,
266
- };
267
- }
268
- if (result.error === "Insufficient balance") {
269
- return {
270
- content: [
271
- {
272
- type: "text",
273
- text: [
274
- `Insufficient Caravo balance (have $${result.balance ?? 0}, need $${result.cost ?? "?"}).`,
275
- ``,
276
- `Top up your balance at https://caravo.ai/dashboard`,
277
- `Or enable auto top-up in your dashboard settings to never run out.`,
278
- ].join("\n"),
279
- },
280
- ],
278
+ content: [{ type: "text", text: buildPaymentRequiredMessage(price) }],
281
279
  isError: true,
282
280
  };
283
281
  }
@@ -438,36 +436,7 @@ function registerAllTools(server) {
438
436
  ? `$${(parseInt(result.accepts[0].amount) / 1e6).toFixed(6)}`
439
437
  : "?";
440
438
  return {
441
- content: [
442
- {
443
- type: "text",
444
- text: [
445
- `Payment required (${price}). Two options:`,
446
- ``,
447
- `Option A — Caravo balance (recommended):`,
448
- ` Run the "login" tool to connect your account, then top up at https://caravo.ai/dashboard`,
449
- ``,
450
- `Option B — USDC wallet (no registration):`,
451
- ` Send USDC on Base to ${wallet.address}`,
452
- ].join("\n"),
453
- },
454
- ],
455
- isError: true,
456
- };
457
- }
458
- if (result.error === "Insufficient balance") {
459
- return {
460
- content: [
461
- {
462
- type: "text",
463
- text: [
464
- `Insufficient Caravo balance (have $${result.balance ?? 0}, need $${result.cost ?? "?"}).`,
465
- ``,
466
- `Top up your balance at https://caravo.ai/dashboard`,
467
- `Or enable auto top-up in your dashboard settings to never run out.`,
468
- ].join("\n"),
469
- },
470
- ],
439
+ content: [{ type: "text", text: buildPaymentRequiredMessage(price) }],
471
440
  isError: true,
472
441
  };
473
442
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caravo/mcp",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "The API marketplace built for autonomous AI agents. Search, execute, and pay for 200+ tools at $0.001–0.05 per call.",
5
5
  "type": "module",
6
6
  "bin": {