SerenAI
SerenAI
SerenAI x402 Gateway API and MCP Server for Premium Data Access

Unlock Premium Data for Your AI Agents: Introducing SerenAI x402 Micropayments Gateway and MCP Server

Taariq Lewis
Taariq Lewis
9 min read

SerenAI: Pay-per-query access to premium, real-time databases and APIs for AI agents

The AI agent economy is exploding. Autonomous agents are making decisions, executing trades, and analyzing data at machine speed. But there's a fundamental problem: How do AI agents pay for premium data?

Traditional APIs require expensive subscriptions, credit cards, and human approval workflows. That doesn't work when your AI agent needs to query Nasdaq market data at 3am or pull Yearn Finance vault statistics in the middle of an automated DeFi strategy.

SerenAI solves this with micropayments natively integrated into its SerenDB back-end. Our x402 Gateway and MCP Server enable AI agents to autonomously pay for database queries and API calls using USDC on Base—no subscriptions, no credit cards, no human intervention.

The Problem: AI Agents Are Data-Hungry But Payment-Starved

Every serious AI application needs acccess to premium data. Market researchers need real-time financial data. DeFi protocols need real-time on-chain analytics. Trading bots need historical price feeds. But accessing this data has always meant:

  • Annual subscriptions costing $300-$50,000/year for premium APIs
  • Credit card processing with $0.30+ minimum fees per transaction
  • Human approval for every new data source
  • API rate limits that throttle your agent's capabilities

The math for the current subscription model simply doesn't work for micropayments. If you want to charge $0.001 per API call, credit card fees eat your entire revenue—and then some.

The Solution: x402 Protocol + USDC on Base

SerenAI implements the Coinbase x402 protocol, enabling HTTP 402 "Payment Required" responses with cryptographic micropayments. When your agent requests data:

  1. Request → Agent calls the SerenAI x402 Gateway API endpoint
  2. 402 Response → Gateway returns payment requirements (amount, recipient, network)
  3. Sign → Agent signs an EIP-3009 transferWithAuthorization payload
  4. Pay + Execute → Gateway settles USDC on Base, executes query, returns results

All of this happens in seconds, with transaction costs around $0.001—roughly 300x cheaper than credit card processing.

Real-World Example: Yearn Finance Data Provider

Yearn Finance uses the Kong indexer to track vault performance, APYs, and TVL across their protocol. This data updates every 24 hours. However, Yearn is able to udpate this data every hour for premium users.

Before SerenAI, hosting this data cost approximately $1,000/month in traditional infrastructure. With SerenAI x402:

  • Hosting cost: ~$100/month (90% savings)
  • Revenue potential: Every query from AI agents generates micropayment income
  • Zero intermediaries: Payments settle directly to the provider's wallet

The first Yearn Finance provider is live in our catalog today as a test Database with more data to follow:

typescript
1# Query the catalog
2curl https://x402.serendb.com/api/catalog
3
4# Response includes:
5{
6  "id": "4cb187b9-b814-483c-a180-c24902ca2720",
7  "name": "Yearn Finance Data SerenDB Test",
8  "providerType": "database",
9  "basePricePer1000Rows": "0.010000",
10  "markupMultiplier": "2.50"
11}

At $0.01 per 1,000 rows with a 2.5x markup, a query returning 5,000 rows costs just $0.125 USDC. Compare that to a $99/month API subscription—you'd need to run 800+ queries before the subscription makes economic sense.

Querying the SerenAI x402 Gateway

The SerenAI x402 Gateway is live at https://x402.serendb.com. Here's how to explore available data providers:

List All Providers

curl https://x402.serendb.com/api/catalog

This returns all registered providers with their pricing:

ProviderProvider IDTypePrice
Yearn Finance Data`4cb187b9-b814-483c-a180-c24902ca2720`Database$0.025/1000 rows
Coingecko API`a42f2c7f-c075-488f-a3f9-acfd7304934b`API$0.0005/call
Nasdaq Data Link`e5a8f3b2-1c4d-4e6f-8a9b-0c1d2e3f4a5b`API$0.0005/call
U.S. Treasury Fiscal Data`f6b9c4d3-2e5f-4a7b-9c0d-1e2f3a4b5c6d`API$0.001/call

Get Provider Details

typescript
1# Get details for Coingecko API provider
2curl https://x402.serendb.com/api/catalog/a42f2c7f-c075-488f-a3f9-acfd7304934b

Execute a Paid Query

For database providers:

typescript
1# Query Yearn Finance Data (database provider)
2curl -X POST https://x402.serendb.com/api/query \
3  -H "Content-Type: application/json" \
4  -d '{
5 "sql": "SELECT * FROM vaults WHERE apy > 5 LIMIT 100",
6 "agentWallet": "0xYourWallet",
7 "providerId": "4cb187b9-b814-483c-a180-c24902ca2720"
8 }'

For API providers:

typescript
1# Query Coingecko API (API provider)
2curl -X POST https://x402.serendb.com/api/proxy \
3  -H "Content-Type: application/json" \
4  -d '{
5 "providerId": "a42f2c7f-c075-488f-a3f9-acfd7304934b",
6 "agentWallet": "0xYourWallet",
7 "request": {
8 "method": "GET",
9 "path": "/coins/bitcoin"
10 }
11 }'

Without a payment header, you'll receive a 402 Payment Required response with the exact USDC amount needed. Sign the authorization, attach it as X-PAYMENT, and resend—your query executes instantly.

For Data Providers: Monetize Your Database And Data That Has Agentic Demand

Have valuable data sitting in PostgreSQL, MySQL, MongoDB, or SQLite? SerenAI's database replicator lets you replicate your data to SerenDB and start earning micropayments from AI agents.

Supported Source Databases

  • PostgreSQL (continuous sync via logical replication)
  • MySQL/MariaDB (periodic refresh)
  • MongoDB (periodic refresh)
  • SQLite (one-time replication)

Get Started in 3 Steps

Step 1: Sign up at console.serendb.com

Use code serenai2025 for early access and free hosting.

Step 2: Create a project and get your connection string

A connection string is the URL your application uses to connect to your database. It contains the username, password, host, port, and database name in a single string.

After creating a project in the SerenDB console:

  1. Navigate to your project's Connection Details page
  2. Copy the PostgreSQL connection string—it looks like:
bash
1postgresql://serendb_owner:YOUR_PASSWORD@ep-your-db.serendb.com:5432/serendb?sslmode=require


  1. Go to API Keys in the console and generate a SerenAI API Key—you'll need this for database replication with the database-replicator tool

The API key authenticates your replication jobs when syncing data from your source database (PostgreSQL, MySQL, MongoDB, or SQLite) to SerenDB.

Step 3: Register as a provider

typescript
1curl -X POST https://x402.serendb.com/api/providers/register \
2  -H "Content-Type: application/json" \
3  -d '{
4 "name": "My Financial Data",
5 "email": "provider@example.com",
6 "walletAddress": "0xYourWalletOnBase",
7 "connectionString": "postgresql://serendb_owner:PASSWORD@ep-your-db.serendb.com/serendb?sslmode=require"
8 }'

Then configure your pricing:

typescript
1# Pricing example: ~$0.005 per typical query (200 rows)
2# basePricePer1000Rows × (rows/1000) × markupMultiplier = cost
3# $0.0125 × 0.2 × 2.0 = $0.005 per query
4curl -X POST https://x402.serendb.com/api/providers/{providerId}/pricing \
5  -H "Authorization: Bearer YOUR_API_KEY" \
6  -H "Content-Type: application/json" \
7  -d '{
8 "basePricePer1000Rows": 0.0125,
9 "markupMultiplier": 2.0
10 }'

This pricing is comparable to premium API subscriptions (~$0.005/query) but without the monthly commitment. Adjust basePricePer1000Rows and markupMultiplier based on your data's value and typical query sizes.

That's it. Every AI agent query against your data now generates revenue deposited directly to your wallet. There is no limit to the number of Data Providers you can register in SerenDB, allowing you to host multiple databases and APIs.

For Developers: The SerenAI MCP Server

The Model Context Protocol (MCP) lets AI assistants like Claude interact with external tools. Our x402 MCP Server enables Claude Desktop, Cursor, and other MCP-compatible clients to query paid APIs autonomously.

Installation

bash
1npm install @serendb/x402-mcp-server

Claude Desktop Configuration

Add to claude_desktop_config.json:

json
1{
2  "mcpServers": {
3    "x402": {
4      "command": "npx",
5      "args": ["@serendb/x402-mcp-server"],
6      "env": {
7        "X402_GATEWAY_URL": "https://x402.serendb.com",
8        "WALLET_PRIVATE_KEY": "0xYourPrivateKey",
9        "BASE_RPC_URL": "https://mainnet.base.org"
10      }
11    }
12  }
13}

Available Tools

Once configured, Claude can use these tools:

  • list_providers - Browse available data providers by category
  • get_provider_details - Get pricing and capabilities for a provider
  • pay_for_query - Execute a paid query with automatic USDC settlement

Getting USDC on Base

To use the MCP server, your wallet needs USDC on Base network. If you need help acquiring USDC, join our community on Discord for help: https://discord.gg/qEw9MMqZrc

Zero-Fee Settlements: A Game Changer

Here's where blockchain payments fundamentally change the economics.

Traditional credit card processing charges 2.9% + $0.30 per transaction. For a $0.01 micropayment, that's a 3,000% fee—obviously impossible.

With SerenAI x402 on Base:

  • Transaction cost: ~$0.001 (paid by SerenAI)
  • Provider receives: 100% of the payment amount
  • Settlement time: Seconds, not days
  • Chargebacks: Impossible (cryptographic authorization)

We cover all gas fees on Base. Providers receive payments directly to their wallet with zero transaction costs. Compare this to Stripe's 2.9% + $0.30, and the math is transformative:

Payment AmountCredit Card FeeBlockchain Fee
$0.01$0.30 (3000%)$0.001 (10%)
$0.10$0.30 (300%)$0.001 (1%)
$1.00$0.33 (33%)$0.001 (0.1%)

This isn't incremental improvement—it's a phase change that makes micropayments economically viable for the first time.

Conclusion: Build Smarter AI with Premium Data Access

The SerenAI x402 Gateway opens a new paradigm for AI development:

For AI Developers: Access real-time financial data, blockchain analytics, and premium APIs without subscription overhead. Pay only for what you query. Make your LLMs smarter with access to non-public, premium data that competitors can't reach.

For Data Providers: Transform your database from a cost center into a revenue stream. Any developer can convert their back-end data into a pay-per-query endpoint for AI agents and AI developers.

For the Ecosystem: Cryptographic micropayments eliminate fraud, chargebacks, and the $0.30 minimum that kills traditional micropayment models.

The future of AI is autonomous agents with autonomous payments. SerenAI is building the infrastructure to make that future real.

Get Started Today

  • Explore the Catalog: curl https://x402.serendb.com/api/catalog
  • Sign Up as Provider: console.serendb.com (code: serenai2025)
  • Install MCP Server: npm install @serendb/x402-mcp-server
  • Questions?: Join our Discord Community for SerenAI.

About SerenAI

SerenAI is building infrastructure for AI agent data access. We believe AI agents will pay for the data they consume—and we're creating the payment rails to make it happen.

Our platform includes:

  • SerenDB: Managed PostgreSQL optimized for AI agent queries
  • x402 Gateway: HTTP micropayment protocol for databases and APIs
  • MCP Server: Claude and AI assistant integration
  • Database Replicator: Universal replication from any database to SerenDB

We're backed by experienced builders from enterprise databases and security systems. Our mission: make premium data accessible to every AI agent through secure, instant micropayments.

Contact: Discord Community | serendb.com | @serendb

Share:
Taariq Lewis

About Taariq Lewis

Exploring how to make developers faster and more productive with AI agents

Related Posts