x402-monetize
Enables x402 V2 monetization for Cloudflare Monetization Gateway, facilitating payment processing and fee splits for services built on Cloudflare.
Provides a monetize middleware for Hono HTTP APIs, allowing developers to add x402 payment challenges and fee splits to their routes.
Offers a RedisNonceStore for distributed nonce locking, preventing signature replay attacks in payment verification.
Supports distributed nonce locking with Upstash Redis, enabling replay protection and scalable payment verification.
@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
MemoryNonceStoreand distributedRedisNonceStoredrivers 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-monetizeUsage 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
This server cannot be installed
Maintenance
Related MCP Servers
- Alicense-qualityCmaintenanceNon-custodial x402 MCP payment layer for AI agents. Enables autonomous USDC payments on Base via the x402 HTTP payment protocol, with CCTP cross-chain bridge support.Last updated435MIT
- Alicense-qualityBmaintenanceDrop-in x402 payment middleware for MCP servers. Charge AI agents per tool call using USDC on Base chain — Python and JavaScript SDKs, no payment processor, no KYC.Last updatedMIT
- Alicense-qualityBmaintenanceMCP server for Pay – the complete x402 payment stack for AI agents, enabling direct USDC payments on Base, metered tabs, service discovery, and wallet management within any MCP-compatible client.Last updated52MIT
- FlicenseAqualityBmaintenanceMCP server for a live x402 payment gateway on Base (USDC). Lets AI agents discover, preview for free, then pay per call — with prepaid gasless payments, signed receipts, and delta delivery.Last updated7
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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