npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-pay

v1.0.0

Published

x402 micropayment billing for MCP tools. One wrapper, any tool charges USDC per call. No Stripe. No signups. Agent-native.

Readme

mcp-pay

x402 micropayment billing for MCP tools. One wrapper. Any tool charges USDC per call. No Stripe. No signups. Agent-native.

npm version license zero dependencies

Built by Brennan Zambo — extracted from the zambo.dev production MCP server running 28 tools with live x402 billing.


What it does

mcp-pay wraps any MCP tool handler with on-chain USDC payment verification. Before your tool runs, it verifies that the calling agent paid the required amount on Base mainnet — no Stripe account, no pricing page, no auth system.

An AI agent decides it needs your tool → pays $0.005 USDC on Base → includes the tx hash in the request header → your tool runs. The whole flow is autonomous. No human required.

This is the business model for the open source AI agent economy.


Install

npm install mcp-pay

Zero dependencies. Node.js 18+. Base mainnet only (currently).


Quick start

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { payable } from 'mcp-pay';
import { z } from 'zod';

const server = new McpServer({ name: 'my-server', version: '1.0.0' });

// Wrap any tool handler with payable()
server.tool(
  'analyze_code',
  {
    description: 'AI code security audit',
    inputSchema: z.object({ code: z.string() }),
  },
  payable(
    { usdc: 0.005, wallet: '0xYOUR_WALLET_ADDRESS' },
    async ({ code }) => {
      const result = await runAudit(code);
      return { content: [{ type: 'text', text: result }] };
    }
  )
);

The agent calls the tool like this:

{
  "tool": "analyze_code",
  "arguments": {
    "code": "...",
    "_payment": "0xABC123...TX_HASH"
  }
}

Or via HTTP header: x-payment-hash: 0xABC123...TX_HASH


How payment verification works

  1. Agent sends USDC to your wallet on Base mainnet
  2. Agent includes the tx hash in _payment arg or x-payment-hash header
  3. mcp-pay calls Base RPC nodes (no API key) to fetch the tx receipt
  4. Finds the USDC Transfer log, checks to address and amount
  5. ✅ Passes → runs your handler. ❌ Fails → throws 402 error with payment instructions

Verified tx hashes are cached in-process to allow retry calls without re-verifying.


API

payable(options, handler)

Wraps an MCP tool handler with payment verification.

payable(options: PayableOptions, handler: AsyncFunction): AsyncFunction

Options:

| Field | Type | Default | Description | |-------|------|---------|-------------| | usdc | number | required | Amount in USDC (e.g. 0.005) | | wallet | string | required | Your Base mainnet wallet address | | network | 'base' | 'base' | Network (Base mainnet only currently) | | headerName | string | 'x-payment-hash' | Header carrying the tx hash | | cache | boolean | true | Cache verified hashes to allow retries | | rpcEndpoints | string[] | public endpoints | Override Base RPC nodes |


verifyPayment(txHash, options)

Standalone payment verification. Use when you want to verify outside of an MCP handler.

const result = await verifyPayment('0xabc...', {
  usdc: 1.49,
  wallet: '0xYOUR_WALLET',
});

if (result.verified) {
  console.log(`Received $${result.amount} USDC`);
  console.log(`Block: ${result.blockNumber}`);
}

requirePayment(options)

Express/Fastify middleware for HTTP-level MCP servers.

app.post('/tools/analyze_code',
  requirePayment({ usdc: 0.005, wallet: '0xYOUR_WALLET' }),
  analyzeCodeHandler
);

Returns 402 Payment Required with payment instructions if no valid hash is present.


createPaymentRequest(options)

Generate a payment request object to return to clients.

const req = createPaymentRequest({ usdc: 0.005, wallet: '0x...' });
// {
//   protocol: 'x402',
//   network: 'base',
//   wallet: '0x...',
//   amount: 0.005,
//   currency: 'USDC',
//   headerName: 'x-payment-hash',
//   instructions: '...'
// }

Pricing ideas

| Use case | Suggested price | |----------|----------------| | Code audit | $0.005–$0.01 | | Web search | $0.001–$0.002 | | Data enrichment | $0.002–$0.005 | | Image generation | $0.01–$0.05 | | Complex analysis | $0.01–$0.10 |


USDC on Base


The x402 protocol

mcp-pay implements x402 — the HTTP 402 Payment Required standard for machine-to-machine micropayments. An AI agent can autonomously decide to pay for a tool, execute the payment, and retry — no human in the loop.


Related


License

MIT © Brennan Zambo