DEV Community

GoldBean
GoldBean

Posted on

Build a Chinese AI MCP Server with x402 Micropayments: My Journey Creating GoldBean

The Problem

Building apps that need Chinese AI capabilities — OCR, translation, text-to-speech, image recognition — typically means:

  1. Sign up for Baidu AI Cloud (requires Chinese phone + identity verification)
  2. Get API keys and manage credential rotation
  3. Pre-pay credits in CNY via Alipay/WeChat
  4. Write adapter code to normalize 53 different API formats
  5. Monitor billing across multiple Baidu service accounts

For international developers, step 1 is already a wall. For AI agent builders using MCP (Model Context Protocol), steps 2-4 are friction that kills experimentation.

The Solution: GoldBean MCP Server

GoldBean is an MCP server that wraps 53 Baidu AI endpoints behind a single protocol, with x402 micropayment replacing API keys entirely.

What that means in practice:

npx goldbean-mcp
Enter fullscreen mode Exit fullscreen mode

That one command gives you 53 tools in any MCP-compatible client (Cursor, Claude Desktop, Cline, Codex):

Category Tools Price per call
OCR (19 types) General, Handwriting, Table, ID Card, Business License, License Plate, Train Ticket, Formula, Webpage, Acrobat... $0.01-0.03
Image Recognition (10) Plant, Animal, Car Model, Dish, Landmark, Logo, Currency... $0.02-0.05
ERNIE LLM Text generation, chat completion $0.05-0.08
Translation 28+ language pairs $0.005
TTS / ASR Text to speech, speech to text $0.02
NLP (6 types) Sentiment, keyword extraction, emotion, comment analysis... $0.01
Web Search Instant answers + related topics $0.005
Vision / Detection Face, gesture, body pose, image generation $0.03-0.05

No API keys. No signup. Pay per call with USDC on Base.

Free tier: 50 calls/day per IP — no wallet needed.

How x402 Works (Under the Hood)

x402 is the HTTP 402 Payment Required protocol, built by Coinbase on Base (Ethereum L2). Here's the flow:

  1. Client calls https://goldbean-api.xyz/api/ocr/general (no API key header)
  2. Server responds with HTTP 402 + payment details (amount, wallet address, facilitator URL)
  3. Client pays $0.01 USDC to the server wallet via x402 facilitator (2-second settlement on Base)
  4. Client retries with the payment receipt in the X-Payment header
  5. Server validates payment, processes the request, returns result

The entire payment cycle is ~2 seconds. For MCP clients, the x402 SDK handles this automatically.

Architecture

+-----------------+     +------------------+     +-------------+
|  MCP Client     |---->|  goldbean-mcp    |---->|  Baidu AI   |
| (Cursor/Cline)  |     |  (Node.js)       |     |  Cloud API  |
+-----------------+     +------------------+     +-------------+
                              |
                              | x402 payment
                              v
                        +-----------+
                        |  Base L2  |
                        |  (USDC)   |
                        +-----------+
Enter fullscreen mode Exit fullscreen mode

The MCP server acts as both a protocol adapter (MCP to Baidu REST) and an x402 payment proxy. Each tool call triggers the payment flow, which is invisible to the end user if they have USDC in their wallet.

Getting Started

1. Install as MCP Server

Add to your MCP client config:

{
  "mcpServers": {
    "goldbean": {
      "command": "npx",
      "args": ["goldbean-mcp"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

2. For Free Tier (No Wallet Needed)

Just call any endpoint — 50 free calls per day per IP, no configuration required.

3. For Paid Tier (USDC on Base)

Set up an x402-compatible wallet with USDC on Base mainnet. The x402 SDK auto-detects and handles payment.

4. For Prepaid Credits (PayPal / Alipay)

Visit https://goldbean-api.xyz to purchase credits — no crypto needed.

Real-World Use Cases

OCR Pipeline for Chinese Documents

# Process a Chinese business license
result = mcp_client.call_tool("baidu_ocr_business_license", {
    "image": "https://example.com/license.jpg"
})
# Returns: company name, registered capital, legal representative, scope...
Enter fullscreen mode Exit fullscreen mode

Multi-Language Translation Agent

# Translate Chinese content to 28+ languages in one MCP session
for lang in ["en", "ja", "ko", "fr", "de"]:
    result = mcp_client.call_tool("baidu_translation", {
        "text": "人工智能改变世界",
        "from": "zh",
        "to": lang
    })
Enter fullscreen mode Exit fullscreen mode

ERNIE LLM Integration

# Use Baidu's ERNIE Bot as an MCP tool
result = mcp_client.call_tool("baidu_ernie_text", {
    "prompt": "Write a product description for a smart home device",
    "temperature": 0.7
})
Enter fullscreen mode Exit fullscreen mode

Pricing

Plan Price Calls
Free $0 50/day per IP
Starter $5 one-time 100 calls
Monthly $29.9/mo Unlimited
Quarterly $69/qtr Unlimited
Yearly $269/yr Unlimited

Per-call: $0.01-$0.08 | Payment: x402 USDC (Base), PayPal, Alipay

Why MCP + x402 Matters

The MCP protocol is becoming the standard for AI agent tool access. But every MCP server still needs authentication — API keys, OAuth tokens, or subscription management.

x402 eliminates all of that. Payment replaces authentication. One USDC transaction per call. No key management. No credential rotation. No "your API key has expired" errors.

This is the future of AI agent economics: pay-per-call, no friction, protocol-native.

Links


GoldBean is open-source under MIT license. Contributions welcome — see CONTRIBUTING.md.

Top comments (0)