DEV Community

Cover image for Your MCP Server Has Users. You Are Paying Their Bill.
0xAllenDev
0xAllenDev

Posted on • Originally published at dev.to

Your MCP Server Has Users. You Are Paying Their Bill.

The Problem

You built an MCP server. People use it. Claude Code calls it. Cursor calls it. LangChain agents call it.

Every call costs you money — proxies, LLM tokens, compute, third-party API fees. AI agents consume your resources for free.

You've considered charging. Here's why the obvious options fail for micropayments:

Solution Fee on a $0.02 call The problem
Stripe $0.31 (2.9% + $0.30) 1,500% fee — they earn more than you
PayPal $0.31 (2.9% + $0.30) Same math, same problem
API keys $0 fees Agents can't self-register; you manage keys
ag402 (Solana USDC) $0.00025 1.25% fee — agents auto-pay, no signup

The core issue: AI agents can't sign up for accounts. They can't fill checkout forms or manage API keys across dozens of services. Payment needs to be programmatic and invisible.


Three Commands

pip install ag402-core
ag402 init                    # Creates Solana wallet + test USDC
ag402 serve \
  --target http://localhost:3000 \
  --price 0.02 \
  --address <YourSolanaAddress>
Enter fullscreen mode Exit fullscreen mode

Your MCP server now charges $0.02 USDC per request. Your code? Untouched.

                    ┌─────────────────────────────┐
Agent request ──→  │  ag402 reverse proxy (:4020) │
                    │  ┌─────────────────────┐    │
                    │  │ 1. Check payment    │    │
                    │  │ 2. If none → 402    │    │
                    │  │ 3. Agent auto-pays  │    │
                    │  │ 4. Verify on Solana │    │
                    │  │ 5. Forward request  │    │
                    │  └─────────────────────┘    │
                    └──────────┬──────────────────┘
                               │
                    ┌──────────▼──────────┐
                    │ Your MCP Server     │
                    │ (unchanged code)    │
                    └─────────────────────┘
Enter fullscreen mode Exit fullscreen mode

ag402 is a reverse proxy. It sits in front of your server and handles everything. (Step-by-step tutorial)


Buyers Don't Notice

On the agent side:

import ag402_core; ag402_core.enable()
Enter fullscreen mode Exit fullscreen mode

Or zero code changes:

ag402 run -- python my_agent.py
Enter fullscreen mode Exit fullscreen mode

Every 402 is intercepted → paid → retried. Works with LangChain, AutoGen, CrewAI, Semantic Kernel — anything on httpx or requests.


Speed

  • Standard: ~0.5s per payment (on-chain Solana USDC)
  • Prepaid mode: ~1ms — one on-chain payment buys HMAC credentials, subsequent calls verify locally with zero gas

Prepaid is indistinguishable from a free API in terms of latency. (Technical deep-dive)


Running on Mainnet

Token RugCheck audits Solana tokens for rug pull risks — live on mainnet with real USDC payments.

  • $0.02/audit · RugCheck.xyz + DexScreener + GoPlus → 3-layer risk report
  • Verified tx: 3QPqd3...hnVPn (verify on Solscan)

Revenue Projections

Hypothetical estimates — actual results depend on your traffic and pricing.

Price/call 100 calls/day 500 calls/day 1,000 calls/day
$0.01 $30/mo $150/mo $300/mo
$0.02 $60/mo $300/mo $600/mo
$0.05 $150/mo $750/mo $1,500/mo

Non-custodial — USDC goes directly to your Solana address. Only fee: ~$0.00025 network fee.


When NOT to Use This

Be honest about the tradeoffs:

  • Your users don't have crypto wallets: ag402 requires buyers to hold Solana USDC. If your audience is non-crypto developers, this is a barrier. (The prepaid system reduces but doesn't eliminate this.)
  • Solana network outages: Solana has had downtime events. Standard payments depend on network availability. (Prepaid mode works offline since it's HMAC-based.)
  • Regulatory uncertainty: USDC is a regulated stablecoin, but crypto payment rules vary by jurisdiction.
  • You need complex billing: Subscriptions, usage tiers, invoices — ag402 handles simple per-request pricing. For complex billing, you may still need Stripe alongside.

Security

Real money means real security:

  • 4 security audits · 24 issues found, 24 fixed
  • 588+ tests · 90%+ coverage
  • 6-layer budget protection · per-tx cap ($5), rate limit, daily cap ($10), circuit breaker, auto-rollback, key redaction
  • Non-custodial · private keys never leave your machine
  • Zero telemetry · no tracking, no analytics

MIT licensed → audit the source


Get Started

pip install ag402-core && ag402 init && ag402 serve --target http://your-mcp:3000 --price 0.02 --address <Addr>
Enter fullscreen mode Exit fullscreen mode

GitHub ⭐ · Live on mainnet · Colab demo · @AetherCoreDev

Open source (MIT). Built on Coinbase x402.

Top comments (0)