x402 payment wrapper for AI Agents and MCP Servers. USDC settlements on Base L2.
Ultra-lightweight x402 payment interceptor for AI Agents and MCP Servers. Monetize any API in 3 lines of code.
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 });
});
M2MCent implements the x402 Payment Protocol β a machine-native payment standard inspired by HTTP 402:
402 Payment Required + payment metadata (Base64 encoded)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
| Parameter | Description | Required |
|---|---|---|
rpcUrl | Base Mainnet RPC endpoint | β |
privateKey | Relayer wallet private key (for settlement) | β |
recipient | Treasury address to receive payments | β |
transferWithAuthorization (USDC native)| Parameter | Value |
|---|---|
| Network | Base Mainnet (Chain ID: 8453) |
| USDC Contract | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| Escrow Contract | 0xf3c3416A843d13C944554A54Ac274BB7fF264BcC |
| Settlement | Atomic, sub-second finality |
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 });
});
M2MCent powers 100+ production MCP servers on Base Mainnet, processing real USDC micro-payments for AI-to-AI commerce.
MIT Β© M2MCent
Source-derived launch command. Check the maintainerβs required arguments and credentials before running:
npx -y m2mcent-sdkMerge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.
{
"mcpServers": {
"io-github-evozim-m2mcent": {
"command": "npx",
"args": [
"-y",
"m2mcent-sdk"
]
}
}
}Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the clientβs tool list, then try a read-only example from its documentation.
Claude Desktop setup referencem2mcent-sdknpmio.github.Evozim/m2mcent works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.~/.cursor/mcp.jsonRestart Cursor for changes to take effect..vscode/mcp.jsonReload VS Code window for changes to take effect.~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect..mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.