Skip to content

feat: add MPP support#309

Draft
gjj wants to merge 1 commit intomainfrom
feat/mpp-payment-support
Draft

feat: add MPP support#309
gjj wants to merge 1 commit intomainfrom
feat/mpp-payment-support

Conversation

@gjj
Copy link
Copy Markdown
Member

@gjj gjj commented Mar 23, 2026

Summary

Adds optional MPP (Machine Payments Protocol) payment support alongside the existing x402 protocol. Agent builders configure which protocol(s) to accept via aixyz.config.ts — the presence of an x402 or mpp block determines what's active. Both can coexist.

Design

Config shape drives the choice — no extra flags needed:

// x402 only (existing behavior, zero breaking changes)
const config: AixyzConfig = {
  x402: { payTo: '0x...', network: 'eip155:8453' },
};

// MPP only (Tempo stablecoins, Stripe, Lightning)
const config: AixyzConfig = {
  mpp: {
    recipient: '0x...',
    methods: ['tempo', 'stripe'],
    stripeSecretKey: process.env.MPP_STRIPE_SECRET_KEY,
  },
};

// Both simultaneously — clients pick what they speak
const config: AixyzConfig = {
  x402: { payTo: '0x...', network: 'eip155:8453' },
  mpp: { recipient: '0x...', methods: ['tempo', 'stripe'] },
};

The accepts export on agents/tools is unchanged — still just price. The framework handles the rest.

Protocol Dispatch (when both are active)

Incoming header Path
Authorization: Payment ... MPP verification
X-Payment: ... / PAYMENT-SIGNATURE: ... x402 verification
Neither 402 with both challenge headers

Files Changed

File Change
packages/aixyz-config/index.ts x402 now optional; new mpp config block with Zod schema
packages/aixyz/app/payment/mpp.ts New MppPaymentGateway wrapping mppx/server (dynamic import)
packages/aixyz/app/index.ts Dual-protocol dispatch logic in AixyzApp
packages/aixyz/app/types.ts RoutePaymentOptions replaces bare AcceptsX402 on RouteEntry
packages/aixyz/app/plugins/a2a.ts Passes both x402 and mppAmount on the agent route
packages/aixyz/app/plugins/mcp.ts Guards against undefined config.x402
packages/aixyz-cli/build/AixyzConfigPlugin.ts Build banner shows MPP config when present
packages/aixyz/package.json mppx added as optional peer dependency
examples/with-mpp/ MPP-only and dual-protocol example configs

Notes

  • mppx is an optional peer dependency — a clear error is thrown at startup if mpp is configured but mppx isn't installed
  • Zero breaking changes for existing x402-only agents
  • MPP unlocks Stripe card payments, Lightning BTC, and Tempo session-based per-token billing

Closes #

Adds optional MPP payment support alongside the existing x402 protocol.
Agent builders configure which protocol(s) they want via aixyz.config.ts —
the presence of an x402 or mpp block (or both) determines what's active.

## Changes

### packages/aixyz-config
-  is now optional (was required)
- New  config block: recipient, currency, methods (tempo/stripe/lightning),
  stripeSecretKey, feePayerKey, optimistic
- Zod validation: at least one of x402 or mpp must be present
- MppMethod type exported

### packages/aixyz
- New  (app/payment/mpp.ts): wraps mppx/server,
  dynamically imported so mppx stays an optional peer dependency
-  now holds  instead of a bare AcceptsX402
-  initializes both gateways based on config; dispatch routes
  payments by inspecting the incoming Authorization header:
  -    → MPP path
  -                → x402 path
  - neither + both configured      → 402 with both challenges
- A2APlugin passes both x402 and mppAmount on the agent route
- MCPPlugin guards against undefined config.x402
- CLI build banner updated to show MPP config when present

### examples/with-mpp
- aixyz.config.ts: MPP-only example (Tempo + Stripe)
- aixyz-both.config.ts: x402 + MPP dual-protocol example

## Notes
- mppx is an optional peer dependency; a clear error is thrown if mpp is
  configured but mppx is not installed
- Existing x402-only agents require no changes (zero breaking changes)
- Both protocols can be active simultaneously for maximum client compat

See: https://mpp.dev
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-boilerplate Ready Ready Preview, Comment Mar 23, 2026 4:35am
examples-chainlink Ready Ready Preview, Comment Mar 23, 2026 4:35am
examples-flight-search Ready Ready Preview, Comment Mar 23, 2026 4:35am
examples-with-custom-server Ready Ready Preview, Comment Mar 23, 2026 4:35am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ai-xyz.dev Ignored Ignored Mar 23, 2026 4:35am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant