Help us improve
Share bugs, ideas, or general feedback.
From stripe-mpp
Implements Mppx server middleware for Hono, Express, Next.js, and Elysia to protect API routes with HTTP 402 payment gates, verify proofs of payment, and configure methods like Stripe.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin stripe-mppHow this skill is triggered — by the user, by Claude, or both
Slash command
/stripe-mpp:mpp-server-middlewareThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Fetch live docs**:
Scaffolds MPP projects for machine payments: installs mppx/pympp SDKs, configures Stripe/Tempo, adds middleware/paid endpoints for Hono/Express/FastAPI servers.
Injects x402 payment middleware into Express APIs to enforce USDC micropayments on Base L2 for machine-to-machine monetization. Useful for premium endpoints or MCP servers.
Builds an Express server that charges USDC per API request using the x402 payment protocol. Use for monetizing endpoints as a paid service discoverable by other agents.
Share bugs, ideas, or general feedback.
Fetch live docs:
https://www.npmjs.com/package/mppx for the current server middleware API and configuration optionsmppx server middleware hono express next.js elysia for framework-specific integration patternssite:github.com stripe-samples machine-payments server for official server sample codehttps://docs.stripe.com/payments/machine/mpp for Stripe-side server configurationThe mppx server middleware intercepts requests to protected routes and implements the full HTTP 402 challenge-response flow:
Authorization: Payment header, returns 402 with WWW-Authenticate: Payment challengePayment-Receipt header to the responseThe central factory creates the server instance:
const mppx = Mppx.create({
secretKey: process.env.MPP_SECRET_KEY, // 32-byte hex for HMAC challenge binding
methods: [/* payment method configurations */],
});
The secretKey is critical — it binds challenges to prevent forgery and replay attacks.
| Framework | Middleware Pattern | Notes |
|---|---|---|
| Hono | app.get('/path', mppx.charge(...), handler) | Native middleware chaining |
| Express | app.get('/path', mppx.charge(...), handler) | Standard Express middleware |
| Next.js | Route handler wrapping | App Router and Pages Router |
| Elysia | Plugin-style integration | Bun-native framework |
Two middleware functions match the two payment intents:
mppx.charge({ amount }) — Per-request payment gate (charge intent)mppx.session({ maxAmount }) — Session-based streaming payment gate (session intent)'100' = $0.01 (USDC has 6 decimals, so 100 = 0.000100, but convention varies by method)A single server can accept multiple payment methods simultaneously:
const mppx = Mppx.create({
secretKey: process.env.MPP_SECRET_KEY,
methods: [
tempo.charge({ /* Tempo config */ }),
stripe.charge({ /* Stripe config */ }),
],
});
The client selects which method to use when fulfilling the challenge.
For routes where the price depends on the request:
mppx.charge()The middleware returns RFC 9457 Problem Details on payment errors:
| Status | Type | When |
|---|---|---|
| 402 | payment-required | No credential provided |
| 402 | verification-failed | Invalid proof of payment |
| 402 | payment-expired | Challenge or credential expired |
| 402 | malformed-credential | Unparseable credential |
secretKey, never hardcodeFetch the latest mppx package README for exact middleware API signatures, configuration options, and framework-specific examples before implementing.