agent402-mcp 0.7.1 → 0.8.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/index.js +63 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -44,6 +44,7 @@ Claude Code: `claude mcp add agent402 -- npx -y agent402-mcp`
44
44
  - The other ~1000 tools are reachable via `search_tools` (find by description) + `call_tool` (call by slug) — keeping your context window small.
45
45
  - When a call hits HTTP 402: with `AGENT_KEY` set, the server signs an x402 USDC payment and retries; without a key it solves the tool's proof-of-work challenge (~0.2 s of CPU) on the eligible tools.
46
46
  - `payment_info` tells the model which mode it's in and what a wallet would unlock.
47
+ - `top_x402_sellers` returns the live x402 leaderboard — which sellers are settling the most USDC on Base in the last ~24h, derived from on-chain transfers. Free to call (no payment, no proof-of-work). Useful for agents discovering the wider x402 economy beyond this single service's catalog.
47
48
 
48
49
  ## Workflows (skill packs)
49
50
 
package/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
 
29
29
  const BASE = (process.env.AGENT402_URL || "https://agent402.tools").replace(/\/$/, "");
30
30
  const AGENT_KEY = process.env.AGENT_KEY || "";
31
- const VERSION = "0.6.0";
31
+ const VERSION = "0.8.0";
32
32
 
33
33
  // Spend controls — enforced BEFORE a payment is ever signed, so a confused or
34
34
  // runaway model cannot drain the wallet. Unset = unlimited (back-compat).
@@ -332,6 +332,22 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
332
332
  name: "payment_info",
333
333
  description: "How this MCP server is paying for Agent402 calls (USDC wallet vs proof-of-work), and what that unlocks.",
334
334
  inputSchema: { type: "object", properties: {} },
335
+ },
336
+ // Discovery primitive: who's earning USDC on x402 right now? Proxies the
337
+ // hosted /api/leaderboard (free, unpaywalled) and trims to the same compact
338
+ // shape as the hosted MCP connector so cross-surface agents see the same UX.
339
+ {
340
+ name: "top_x402_sellers",
341
+ description:
342
+ "List the x402 sellers earning the most USDC (or serving the most calls) on Base in the last ~24h, derived from on-chain USDC transfers. Useful for agents discovering the live x402 economy: who's getting paid, which networks, and where to point demand. Free to call (no payment, no proof-of-work). Defaults: top 10, sort by USDC, exclude this service's own wallet.",
343
+ inputSchema: {
344
+ type: "object",
345
+ properties: {
346
+ limit: { type: "number", description: "Max rows to return (default 10, max 50)" },
347
+ sort: { type: "string", enum: ["usd", "calls"], description: "Rank by USDC settled (default) or by call count" },
348
+ include: { type: "string", enum: ["external", "all"], description: "'external' (default) hides this service's own wallet; 'all' includes it" },
349
+ },
350
+ },
335
351
  }
336
352
  );
337
353
  return { tools };
@@ -387,6 +403,52 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
387
403
  note: AGENT_KEY
388
404
  ? "Every tool is available; each call is paid in USDC via x402 from the configured wallet, within the spend controls above."
389
405
  : `No AGENT_KEY configured: ${computePayable} pure-CPU tools are free via proof-of-work; the ${catalog.size - computePayable} network/browser/memory tools need a funded wallet (set AGENT_KEY).`,
406
+ ecosystem: "Call top_x402_sellers to see which x402 sellers (any wallet, not just this host) are settling the most USDC on Base in the last 24h — discovers the live economy beyond this catalog.",
407
+ }, null, 2),
408
+ }],
409
+ };
410
+ }
411
+ if (name === "top_x402_sellers") {
412
+ const limit = Math.min(Math.max(parseInt(args.limit, 10) || 10, 1), 50);
413
+ const sort = args.sort === "calls" ? "calls" : "usd";
414
+ const include = args.include === "all" ? "all" : "external";
415
+ // /api/leaderboard is free + unpaywalled, so this stays free regardless
416
+ // of payment mode. Honor its query params verbatim so the surface is a
417
+ // thin pass-through — single source of truth for ranking + filtering.
418
+ const url = new URL(`${BASE}/api/leaderboard`);
419
+ url.searchParams.set("top", String(limit));
420
+ url.searchParams.set("sort", sort);
421
+ url.searchParams.set("include", include);
422
+ const res = await fetch(url);
423
+ if (!res.ok) {
424
+ return { content: [{ type: "text", text: `Failed to fetch leaderboard from ${BASE}: HTTP ${res.status}` }], isError: true };
425
+ }
426
+ const snap = await res.json();
427
+ // Trim to the same compact row shape the hosted MCP connector returns —
428
+ // cross-surface agents see one mental model. Full row (origins,
429
+ // endpoints, scan metadata) stays accessible at /api/leaderboard.
430
+ const rows = (snap.leaderboard || []).map((r) => ({
431
+ rank: r.rank,
432
+ name: r.name,
433
+ network: r.network,
434
+ wallet: r.wallet,
435
+ homepage: r.homepage || null,
436
+ callsSettled: r.callsSettled || 0,
437
+ totalUsd: Math.round((r.totalUsd || 0) * 10000) / 10000,
438
+ uniqueBuyers: r.uniqueBuyers || 0,
439
+ }));
440
+ return {
441
+ content: [{
442
+ type: "text",
443
+ text: JSON.stringify({
444
+ window: snap.windowLabel || snap.windowServed || "24h",
445
+ asOf: snap.asOf,
446
+ sort: snap.sortServed || sort,
447
+ include: snap.include || include,
448
+ totalSellers: snap.totalSellers ?? (snap.leaderboard || []).length,
449
+ results: rows,
450
+ ...(snap.warming || snap.scanSkipped ? { note: "Cache is warming — results may be partial. Retry in ~60s." } : {}),
451
+ source: `${BASE}/api/leaderboard`,
390
452
  }, null, 2),
391
453
  }],
392
454
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent402-mcp",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "mcpName": "io.github.MikeyPetrillo/agent402",
5
5
  "author": "Mikey Petrillo (https://github.com/MikeyPetrillo)",
6
6
  "homepage": "https://agent402.tools",