The first native monetization layer for Model Context Protocol servers. No API keys, no subscriptions, no accounts — just an OWS Wallet and an HTTP request.
import express from 'express' import { mcpay } from '@nikhilraikwar/mcpay' // npm i @nikhilraikwar/mcpay const app = express() // ── TOOL 1: Weather — $0.01 flat ── app.use(...mcpay({ price: '$0.01', walletAddress: process.env.TOOL_WALLET_ADDRESS, toolName: 'weather-data', description: 'Real-time weather for any city', })) // ── TOOL 2: AI Inference — dynamic pricing by model ── app.use(...mcpay({ price: (req) => getDynamicPrice(req.body.model), walletAddress: process.env.TOOL_WALLET_ADDRESS, toolName: 'ai-inference', description: 'Pay-per-inference across 5 AI models', }))
// Agent-side: mcpayFetch auto-handles 402 + OWS payment import { mcpayFetch } from '@nikhilraikwar/mcpay' const result = await mcpayFetch('http://localhost:3001/tools/weather-data', { method: 'POST', body: JSON.stringify({ city: 'Delhi' }), owsWallet: 'mcpay-agent', // OWS wallet name maxPrice: '$0.05' // OWS policy ceiling }) // → { city: 'Delhi', temperature: '28°C', _mcpay: { paid: '$0.01' } } // 402 intercepted → OWS CLI pays → result returned automatically
MCPay wraps AIML API behind x402 with per-model pricing. The first pay-per-inference layer that covers Track 03 and Track 04 simultaneously.
Surge pricing activates when queue depth > 10 concurrent requests. OWS policy maxPrice ceiling prevents agents from overpaying.