Skip to content

Add x402 monetization - let AI agents pay per API call#43

Open
sam00101011 wants to merge 1 commit into21st-dev:mainfrom
sam00101011:add-x402-monetization
Open

Add x402 monetization - let AI agents pay per API call#43
sam00101011 wants to merge 1 commit into21st-dev:mainfrom
sam00101011:add-x402-monetization

Conversation

@sam00101011
Copy link

What is this?

x402 is an open protocol that lets AI agents pay for API calls using the HTTP 402 status code. Instead of API keys and billing dashboards, agents pay per call in USDC on Base.

This PR adds the foundation for monetizing 21st-dev/magic-mcp's API endpoints. We found 1 endpoint in your README that agents could pay to access.

Why agents would pay for 21st-dev/magic-mcp

Each of these capabilities becomes a pay-per-call endpoint that AI agents discover and pay for automatically:

  • Generate production-ready UI components from natural language descriptions — agents pay per call instead of needing credentials or rate-limited free tiers
  • Access a vast library of modern, customizable, and pre-built UI components — agents pay per call instead of needing credentials or rate-limited free tiers
  • Integrate professional brand assets and logos directly via SVGL — agents pay per call instead of needing credentials or rate-limited free tiers
  • Streamline UI development with real-time component previews in your IDE — agents pay per call instead of needing credentials or rate-limited free tiers
  • Maintain type-safe codebases with full TypeScript support for all components — agents pay per call instead of needing credentials or rate-limited free tiers

With x402, every feature above is instantly monetizable. Agents on Claude, Cursor, and any MCP client can discover and pay for access via 402.bot.

What's included

File Purpose
.well-known/x402.json Declares your endpoints, pricing, and wallet address - agents and routing networks use this for discovery
x402-middleware-example.ts Drop-in generic middleware that returns 402 Payment Required and verifies payments

How it works

Agent -> calls your API
     <- 402 Payment Required (price: $0.01, wallet, network)
Agent -> signs USDC payment on Base
     -> retries with x-payment header
     <- normal API response

Settlement is instant. No intermediary holds funds. Revenue goes directly to your wallet.

What you'd earn

~$150/mo projected (1 endpoint × ~150 agent calls/mo × $0.01)

To activate

  1. Replace YOUR_WALLET_ADDRESS in .well-known/x402.json with your Base wallet
  2. Add the middleware to your server (see x402-middleware-example.ts)
  3. Deploy - your API is now discoverable by every agent on the 402.bot routing network

Your endpoints will automatically appear in Claude, Cursor, and any MCP-compatible agent via the 402.bot MCP server.

Live demo

See how 21st-dev/magic-mcp works on the x402 network ->

Links


This PR was opened by 402.bot. x402 is an open protocol - you keep 100% of revenue. We just route agents to providers. If this isn't relevant, feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant