Mppx

From tempoxyz/mpp · View interactive version

Mppx is an AI agent skill from the GitHub repository tempoxyz/mpp. TypeScript SDK for the Payment HTTP Authentication Scheme. Handles 402 Payment Required flows with Tempo, Stripe, and other payment methods. Use when integrating payments or mppx into a client or server application.

How to use this skill

Skill file

mppx

TypeScript SDK for the "Payment" HTTP Authentication Scheme. Full 402 flow: challenge → credential → receipt.

What I can accomplish

Required inputs

Constraints

Client

import { Mppx, tempo } from 'mppx/client'

// Polyfills globalThis.fetch to handle 402 automatically
Mppx.create({
  methods: [tempo({ account })],
})

const res = await fetch('https://api.example.com/resource')

Without polyfilling:

const mppx = Mppx.create({
  methods: [tempo({ account })],
  polyfill: false,
})

const res = await mppx.fetch('https://api.example.com/resource')

Server

import { Mppx, Store, tempo } from 'mppx/server'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount('0x...')

const mppx = Mppx.create({
  methods: [
    tempo.charge({ recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' }),
    tempo.session({
      account,
      chainId: 4217,
      recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      store: Store.memory(),
    }),
  ],
  secretKey: process.env.MPP_SECRET_KEY,
})

async function handler(request: Request): Promise<Response> {
  const result = await mppx.charge({ amount: '1.00' })(request)
  if (result.status === 402) return result.challenge
  return result.withReceipt(Response.json({ data: '...' }))
}

Methods

| Method | Intent | Description |

|---|---|---|

| tempo.charge | charge | One-time stablecoin payment (TIP-20 token transfer on Tempo) |

| tempo.session | session | Streaming payments via payment channels on Tempo |

| stripe.charge | charge | One-time payment via Stripe |

Server tempo() returns a charge/session pair per accepted currency. Individual server tempo.charge() and tempo.session() factories return nonempty method arrays for their intent. Mppx.create flattens these groups. Mainnet defaults to OUSD then USDC.e; Moderato defaults to OUSD then pathUSD. Pass currencies to replace that list, for example currencies: ['0x20c0000000000000000000006a37DA5C996874BE'] to accept only OUSD.

Exports

| Path | Purpose |

|---|---|

| mppx | Core primitives (Challenge, Credential, Method, Receipt, PaymentRequest) |

| mppx/client | Mppx, tempo, stripe, session, Transport |

| mppx/server | Mppx, tempo, stripe, Transport, Store, NodeListener |

| mppx/hono | Hono middleware |

| mppx/express | Express middleware |

| mppx/nextjs | Next.js middleware |

| mppx/elysia | Elysia middleware |

CLI

mppx includes a CLI for making paid requests during development:

npx mppx account create        # create wallet
npx mppx mpp.dev/api/ping/paid --network testnet # make paid request (mpp.dev charges on testnet)
npx mppx example.com -v        # verbose output

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.