TypeScript Interface for Machine Payments Protocol
mppx is an established TypeScript project in the AI payments / x402 ecosystem, focused on machine-payments, machine-payments-protocol, mpp, payments. It currently has 154 GitHub stars and 55 forks, and sits alongside related tools like mpp-rs, pympp, takjil-agents-mpp, awesome-mpp, mpp-swift, MPP-Inspector.
mppx is a TypeScript interface for the Machine Payments Protocol (MPP) from the wevm team — the group behind viem and wagmi, the libraries most of the Ethereum TypeScript ecosystem already depends on. That pedigree matters: it means MPP tooling arrives with the same ergonomics and type-safety standards developers expect from wevm’s other packages.
MPP sits in the coordination layer of the agent-payment stack — how machines discover prices and authorize spend — and mppx is the client-side surface for it in TypeScript, with Tempo integration in its topic set. If you are building agent software in the viem/wagmi world, this is the most natural entry point to MPP.
Best for: TypeScript teams already using viem/wagmi who want a typed client for machine payments. See our MPP category for the wider ecosystem.
TypeScript SDK for the Machine Payments Protocol
Documentation · Install · Quick Start · Examples · CLI · Payments Proxy · Protocol
Full documentation, API reference, and guides are available at mpp.dev/sdk/typescript.
Contributors changing Tempo sessions should read the session design before altering credential, recovery, accounting, or transport behavior.
npm i mppx
import { Mppx, tempo } from 'mppx/server'
const mppx = Mppx.create({
methods: [
tempo({
currency: '0x20c0000000000000000000000000000000000000',
recipient: '0x742d35Cc6634c0532925a3b844bC9e7595F8fE00',
}),
],
secretKey: process.env.MPP_SECRET_KEY!,
})
export async function handler(request: Request) {
const response = await mppx.charge({ amount: '1' })(request)
if (response.status === 402) return response.challenge
return response.withReceipt(Response.json({ data: '...' }))
}
Generate MPP_SECRET_KEY with at least 32 bytes, for example: openssl rand -base64 32.
import { privateKeyToAccount } from 'viem/accounts'
import { Mppx, tempo } from 'mppx/client'
Mppx.create({
methods: [tempo({ account: privateKeyToAccount('0x...') })],
})
// Global fetch now handles 402 automatically
const res = await fetch('https://mpp.dev/api/ping/paid')
| Example | Description |
|---|---|
| charge | Payment-gated photo generation API |
| charge-wagmi | Payment-gated charge with Wagmi + React |
| session/multi-fetch | Multiple paid requests over a single payment channel |
| session/sse | Pay-per-token LLM streaming with SSE |
| stripe | Stripe SPT charge with automatic client |
npx gitpick wevm/mppx/examples/charge
mppx includes a basic CLI for making HTTP requests with automatic payment handling. Tempo
session channels are retained and reused automatically until you close them.
# create account - stored in keychain, autofunded on testnet
mppx account create
# make request - automatic payment handling, curl-like api
mppx example.com
# open another session instead of reusing the preferred channel
mppx example.com --session new
# inspect and close retained sessions
mppx sessions list
mppx sessions view <channel-id>
mppx sessions close <channel-id>
mppx sessions close --all --yes
--session auto is the default. Pass new to open another channel or a channel ID to select one
explicitly.
You can also install globally to use the mppx CLI from anywhere:
npm i -g mppx
mppx exports a Proxy server handler so that you can create or define a 402-protected payments proxy for any API.
import { openai, stripe, Proxy } from 'mppx/proxy'
import { Mppx, tempo } from 'mppx/server'
const mppx = Mppx.create({
methods: [tempo()],
secretKey: process.env.MPP_SECRET_KEY!,
})
const proxy = Proxy.create({
services: [
openai({
apiKey: 'sk-...',
routes: {
'POST /v1/chat/completions': mppx.charge({ amount: '0.05' }),
'POST /v1/completions': mppx.tempo.session({
amount: '0.0001',
unitType: 'token',
}),
'GET /v1/models': true,
},
}),
stripe({
apiKey: 'sk-...',
routes: {
'POST /v1/charges': mppx.charge({ amount: '0.01' }),
'GET /v1/customers/:id': true,
},
}),
],
})
createServer(proxy.listener) // Node.js
Bun.serve(proxy) // Bun
Deno.serve(proxy.fetch) // Deno
app.use(proxy.listener) // Express
app.all('*', (c) => proxy.fetch(c.req.raw)) // Hono
app.all('*', (c) => proxy.fetch(c.request)) // Elysia
export const GET = proxy.fetch // Next.js
export const POST = proxy.fetch // Next.js
This exposes the following routes:
| Route | Pricing |
|---|---|
POST /openai/v1/chat/completions |
charge $0.005 |
POST /openai/v1/completions |
session $0.0001 per token |
GET /openai/v1/models |
free |
POST /stripe/v1/charges |
charge $0.01 |
GET /stripe/v1/customers/:id |
free |
Built on the "Payment" HTTP Authentication Scheme. See mpp-specs for the full specification.
MIT
Rust SDK for the Machine Payments Protocol
Python SDK for the Machine Payments Protocol
Tempo Agent Chalengger
The MPP registry — 100+ Machine Payments Protocol tools, SDKs, services, and payment methods across 15+ chains. The definitive directory for Stripe + Tempo agent payments.
Canonical Swift SDK for the Machine Payments Protocol (MPP) — pay for and charge for machine-to-machine API calls over HTTP 402.
A CLI tool and web dashboard for inspecting, testing, and debugging Machine Payments Protocol flows. Think "Postman for HTTP 402" — it visualizes the full challenge-response-receipt cycle, simulates payment failures, validates receipt signatures, benchmarks session channels, and generates test reports.
Open Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes instantly, manages risk while you sleep. Agent commerce protocol for machine-to-machine payments. Self-hosted. Built on Claude.
Drop-in OpenAI Python client with transparent x402 payment support.
Drop-in OpenAI Typescript client with transparent x402 payment support.
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.
The financial operating system for AI agents. A single HTTP client that intercepts '402 Payment Required', routes across x402, L402, and MPP, persists credentials as recoverable assets, enforces per-envelope budgets, and emits a structured trace.