Skip to main content
Glama

@golfgolfgolf200/x402-monetize

Instant x402 V2 monetization SDK for Model Context Protocol (MCP) tools, Hono HTTP APIs, Cloudflare Monetization Gateway, and Base.

@golfgolfgolf200/x402-monetize allows developers to monetize any MCP tool or HTTP API route in a few lines of code. It automatically generates standard x402 V2 HTTP payment challenges, verifies payment signatures, enforces platform fee splits, and prevents signature replay attacks.


Features

  • x402 V2 Compliant: Standardized payment challenge headers (PAYMENT-REQUIRED, PAYMENT-SIGNATURE, PAYMENT-RESPONSE).

  • Base Network Native: Uses USDC on Base mainnet (eip155:8453) by default.

  • Automated Platform Fee Split: Configurable fee split in basis points (e.g. 50 BPS = 0.5%) routed directly during facilitator settlement.

  • MCP Native Decorator: Seamlessly wraps tools written for the Model Context Protocol.

  • Replay Protection: Includes built-in MemoryNonceStore and distributed RedisNonceStore drivers to prevent double-spending or signature reuse.

  • Edge Compatible: Zero Node.js-only API dependencies; runs seamlessly on Cloudflare Workers, Vercel Edge, Node.js (18+), and Deno.


Related MCP server: payclaw

Installation

npm install golfgolfgolf200/x402-monetize

Usage Case 1: Monetizing Hono HTTP APIs

import { Hono } from "hono";
import { monetize } from "@golfgolfgolf200/x402-monetize";

const app = new Hono();

app.use(
  "/api/data",
  monetize({
    price: "0.01", // $0.01 USDC
    payTo: "0xYourMerchantWalletAddress",
    platformWallet: "0xYourPlatformTreasuryWallet",
    platformFeeBps: 50 // 0.5% cut
  })
);

app.get("/api/data", (c) => c.json({ status: "success", content: "Monetized Payload" }));

export default app;

Usage Case 2: Monetizing MCP (Model Context Protocol) Tools

import { createMonetizedMCPTool } from "@golfgolfgolf200/x402-monetize";

const originalTool = {
  name: "web_scraper",
  description: "Extract clean Markdown content from URLs",
  inputSchema: { type: "object", properties: { url: { type: "string" } } },
  handler: async ({ url }: { url: string }) => {
    return { markdown: "# Cleaned Markdown Content" };
  }
};

export const monetizedTool = createMonetizedMCPTool(originalTool, {
  price: "0.02", // $0.02 USDC
  payTo: "0xYourMerchantWalletAddress",
  platformWallet: "0xYourPlatformTreasuryWallet",
  platformFeeBps: 50
});

Usage Case 3: Distributed Nonce Locking with Redis / Upstash

import { Redis } from "@upstash/redis";
import { monetize, RedisNonceStore } from "@golfgolfgolf200/x402-monetize";

const redis = new Redis({
  url: process.env.UPSTASH_REDIS_REST_URL!,
  token: process.env.UPSTASH_REDIS_REST_TOKEN!
});

app.use(
  "/api/v1/compute",
  monetize({
    price: "0.10",
    payTo: "0xYourMerchantWalletAddress",
    platformWallet: "0xYourPlatformTreasuryWallet",
    nonceStore: new RedisNonceStore(redis),
    nonceTtlSeconds: 300
  })
);

License: MIT

F
license - not found
-
quality - not tested
A
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Pay for HTTP APIs and charge for your own: x402 micropayments in USDC on Base.

  • Agent-commerce MCP server for x402/USDC payments and affiliate splits on Base.

  • MCP marketplace: agents pay per call in USDC via x402. Plus Base chain data and a USDC<->bank ramp.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/golfgolfgolf200/x402-monetize'

If you have feedback or need assistance with the MCP directory API, please join our Discord server