Skip to main content
Glama

πŸ›°οΈ M2MCent SDK β€” x402 Payment Wrapper for AI Agents

npm version License: MIT Base Mainnet

Ultra-lightweight x402 payment interceptor for AI Agents and MCP Servers. Monetize any API in 3 lines of code.

πŸš€ Quick Start

npm install m2mcent-sdk
import { X402Handler } from 'm2mcent-sdk';

const x402 = new X402Handler({
  rpcUrl: 'https://mainnet.base.org',
  privateKey: process.env.RELAYER_PRIVATE_KEY!,
  recipient: process.env.TREASURY_ADDRESS!
});

// Protect any Express endpoint with a USDC paywall
app.post('/api/analyze', x402.requirePayment("100000"), (req, res) => {
  res.json({ result: "Premium analysis complete", receipt: req.paymentTx });
});

Related MCP server: Warppay402 Gateway

πŸ“ How It Works

M2MCent implements the x402 Payment Protocol β€” a machine-native payment standard inspired by HTTP 402:

  1. Agent requests a protected endpoint

  2. Server responds with 402 Payment Required + payment metadata (Base64 encoded)

  3. Agent signs an EIP-712 typed data authorization (gasless for the payer)

  4. Server settles atomically on-chain via the M2MCent Escrow contract

  5. Agent receives the premium response + transaction receipt

Agent ──► API Server ──► 402 + metadata
Agent ◄── signs EIP-712 authorization
Agent ──► API Server + Payment-Signature header
          └──► Escrow.settle() on Base L2
Agent ◄── Premium Response + tx hash

βš™οΈ Configuration

Parameter

Description

Required

rpcUrl

Base Mainnet RPC endpoint

βœ…

privateKey

Relayer wallet private key (for settlement)

βœ…

recipient

Treasury address to receive payments

βœ…

πŸ”’ Security

  • Non-custodial: Funds flow directly from payer β†’ treasury via on-chain escrow

  • Gasless for payers: Uses EIP-3009 transferWithAuthorization (USDC native)

  • Zero-Leak: No agent data is retained after settlement

  • Atomic: Payment and service delivery happen in a single request cycle

🌐 Network Details

Parameter

Value

Network

Base Mainnet (Chain ID: 8453)

USDC Contract

0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Escrow Contract

0x5d47070A36A37DAf417e64FF27a1e5B3F1c84efa

Settlement

Atomic, sub-second finality

🧩 MCP Server Integration

Perfect for Model Context Protocol servers:

import express from 'express';
import { X402Handler } from 'm2mcent-sdk';

const app = express();
const x402 = new X402Handler({
  rpcUrl: process.env.BASE_RPC_URL!,
  privateKey: process.env.RELAYER_PRIVATE_KEY!,
  recipient: process.env.TREASURY_ADDRESS!
});

// Any MCP tool endpoint becomes monetizable
app.post('/api/tools/analyze', x402.requirePayment("50000"), async (req, res) => {
  const result = await runMCPTool(req.body);
  res.json({ ...result, paymentTx: req.paymentTx });
});

πŸ“Š Ecosystem

M2MCent powers 100+ production MCP servers on Base Mainnet, processing real USDC micro-payments for AI-to-AI commerce.

πŸ“„ License

MIT Β© M2MCent

Available Tools

2 tools
execute_m2mcent_toolBInspect

Execute any of the 1,004 M2MCent microservices. Fee varies per node (e.g. $0.01 - $0.50 USDC).

Inputs: payload (required), toolName (required).

search_m2mcent_catalogBInspect

Search the M2MCent Universal Catalog of 1,004+ Agentic Services

Inputs: query (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have completely distinct purposes: one searches the catalog, the other executes a selected service. There is no overlap or ambiguity about which tool to use for a given task.

    Naming Consistency5/5

    Both tools follow a clear verb_noun pattern with the shared 'm2mcent' prefix (search_m2mcent_catalog, execute_m2mcent_tool). The naming is predictable and consistent despite the slightly different second nouns.

    Tool Count5/5

    For a gateway SDK exposing a catalog of 1,004+ services, two tools are exactly the right scope: search to discover and execute to invoke. Each tool earns its place, and adding more would overcomplicate the surface.

    Completeness5/5

    The core lifecycle of discover-then-execute is fully covered. Search returns catalog details, and execute runs the chosen microservice. No obvious gaps exist for the stated purpose of being a thin client to the M2MCent ecosystem.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers