DEV Community

XYG-LUNA
XYG-LUNA

Posted on

Building a Payment-Enabled MCP Server: Let AI Agents Pay for Skills via HTTP 402

Building a Payment-Enabled MCP Server: Let AI Agents Pay for Skills via HTTP 402

The Problem

In the traditional SaaS model, users need to sign up, subscribe, and bind a credit card before they can use an AI tool. This creates high friction.

The answer is HTTP 402 Payment Required — a rarely-used HTTP status code perfect for pay-per-use AI APIs.

What is HTTP 402?

HTTP 402 "Payment Required" is a standard HTTP status code. When a client calls an API without payment, the server returns 402 with payment parameters. After payment, the request is processed.

The Architecture

I built this for CHROMATIC-MCP — an MCP Server exposing 252 AI skills through 12 MCP tools:

Client → API Gateway (Auth + Payment Check) → Skill Router → Skill Server
Enter fullscreen mode Exit fullscreen mode

Key Components

  1. Free Tier: 10 free calls per skill per day, no auth needed
  2. Alipay AI Pay: Auto-debit agreement for seamless payments
  3. MCP Tools: Each skill registered as individual MCP tool

12 MCP Tools

Tool Price Description
discover_skills Free Browse all 252 skills
skill_mbti-deep-analysis ¥0.10 MBTI assessment
skill_bianzhen ¥0.50 Multi-model fact-checking
skill_ad-copywriter ¥0.10 Ad copy generation
skill_zhuojian ¥0.50 5-layer deep analysis
skill_cuilu ¥0.50 Skill forging engine
skill_weekly-report ¥0.10 Weekly report generator
skill_taobao-listing ¥0.10 E-commerce copywriting
skill_contract-guardian ¥0.10 AI contract review
skill_game-audio ¥0.10 Game audio design
skill_shijin ¥0.50 Skill quality testing
get_skill_detail Free Get skill details

Quick Start

Install via npx

npx -y chromatic-mcp-skills@latest
Enter fullscreen mode Exit fullscreen mode

Configure in Claude Desktop / Cursor

{
  "mcpServers": {
    "CHROMATIC-MCP": {
      "command": "npx",
      "args": ["-y", "chromatic-mcp-skills@latest"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Try a Skill (Free)

curl http://124.222.26.218:3000/api/skill/mbti-deep-analysis
Enter fullscreen mode Exit fullscreen mode

Why HTTP 402 Works for AI

  1. Zero friction: No signup, no credit card. First 10 calls free.
  2. Standard protocol: Any HTTP client understands 402.
  3. Agent-friendly: AI agents can detect 402 and handle payment.
  4. Granular pricing: ¥0.10–¥0.50 per call depending on complexity.

Lessons Learned

  • 402 is underutilized but semantically correct for payment walls
  • Free tier removes all friction for evaluation
  • Alipay AI Pay auto-debit means returning users never see payment prompts
  • MCP is the future — any AI agent can discover and use skills

What's Next

  • Multi-model support
  • Volume discounts
  • Third-party skill submissions
  • More payment methods

GitHub: https://github.com/Chromatic0618/alipay-mcp-server
npm: chromatic-mcp-skills
Live API: http://124.222.26.218:3000/api/skills

Built by Chromatic0618. MIT License.

Top comments (0)