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-x402-gateway

v0.1.0

Published

Drop-in x402 + Stripe + license-key paywall for any MCP server. Wrap stdio or HTTP MCP and start earning USDC per tool call.

Downloads

18

Readme

mcp-x402-gateway

Drop-in paywall for any MCP server. Wrap stdio or HTTP MCPs with:

  • x402 micropayments — USDC on Base via Coinbase CDP facilitator (zero fee).
  • License keys — HMAC-signed tokens for Pro/Business/Enterprise tiers.
  • Stripe fallback — fiat subscriptions for users who do not want to hold USDC.
  • Per-route pricing — JSON config, no code changes.

Why

Every MCP builder ships tools for free and hopes for stars. The x402 protocol (HTTP 402 revived by Coinbase) makes per-call USDC payments as easy as an HTTP header. This gateway bolts that onto any existing MCP without forking it.

Install

npm install mcp-x402-gateway
# or run directly
npx mcp-x402-gateway

Quick start — wrap a stdio MCP

cp .env.example .env
# edit .env, set X402_PAY_TO_ADDRESS + UPSTREAM_COMMAND

# wrap nanobanana-mcp (Gemini image gen) with pay-per-call
UPSTREAM_COMMAND="npx" \
UPSTREAM_ARGS="-y [email protected]" \
X402_PAY_TO_ADDRESS="0xYourBaseWalletHere" \
GEMINI_API_KEY="..." \
npx mcp-x402-gateway

Quick start — wrap an HTTP MCP

UPSTREAM_URL="http://localhost:3000" \
X402_PAY_TO_ADDRESS="0xYourBaseWalletHere" \
npx mcp-x402-gateway

Pricing config

pricing.json:

{
  "defaultAmountUsd": 0.001,
  "freeTier": { "callsPerDay": 0 },
  "routes": {
    "POST /mcp/generate_image": { "amountUsd": 0.05 },
    "POST /mcp/swarm_init": { "amountUsd": 0.002 }
  }
}

Calling a paywalled route

# First call — gateway returns 402 with payment requirements
curl -X POST http://localhost:8787/mcp/generate_image \
  -H 'content-type: application/json' \
  -d '{"prompt":"astronaut on mars"}'

# Agent signs payment, retries with X-Payment header
curl -X POST http://localhost:8787/mcp/generate_image \
  -H 'content-type: application/json' \
  -H "X-Payment: $(x402-sign ...)" \
  -d '{"prompt":"astronaut on mars"}'

License-key tier bypasses x402 entirely:

curl -X POST http://localhost:8787/mcp/generate_image \
  -H "X-License-Key: $LICENSE_TOKEN" \
  -d '{"prompt":"..."}'

Programmatic use

import { startGateway } from 'mcp-x402-gateway';

const server = await startGateway();
// later:
await server.stop();

License issuance

import { issueLicense } from 'mcp-x402-gateway';

const token = issueLicense(env, {
  sub: 'customer_abc123',
  tier: 'business',
  exp: Math.floor(Date.now() / 1000) + 365 * 24 * 3600,
});

Hand this token to paying customers (Stripe webhook on subscription.created).

Architecture

  agent -> [gateway :8787] -> [upstream MCP: stdio OR http]
              |
              +-> x402 facilitator (Coinbase CDP)
              +-> license verifier (HMAC)
              +-> Stripe webhooks (planned)
  • Request arrives → middleware checks X-License-Key first.
  • If no license, checks X-Payment and verifies via CDP facilitator.
  • If no payment, returns 402 Payment Required with requirements.
  • On verified payment, settles atomically and forwards to upstream.

Roadmap

  • [x] x402 verify + settle via Coinbase CDP
  • [x] HMAC license keys
  • [x] stdio and HTTP upstream
  • [x] per-route pricing JSON
  • [ ] Stripe webhook → auto-issue license
  • [ ] Rate limit per payer address
  • [ ] Usage analytics dashboard
  • [ ] Multi-chain (Solana facilitator)
  • [ ] Self-hosted facilitator option

License

MIT.