Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ navigation:
- page: x402
icon: fa-solid fa-credit-card
path: pages/integrations/x402.mdx
- page: MPP
icon: fa-solid fa-credit-card
path: pages/integrations/mpp.mdx
- page: LiveKit
icon: fa-solid fa-phone
path: pages/integrations/integrate-livekit-agents.mdx
Expand Down
83 changes: 83 additions & 0 deletions fern/pages/integrations/mpp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: MPP
subtitle: Pay-per-use AgentMail with Stripe's Machine Payments Protocol
slug: integrations/mpp
description: AgentMail's MPP integration for machine-to-machine payments via Stripe
---

## Getting started

[MPP (Machine Payments Protocol)](https://mpp.dev) is Stripe's open protocol that enables machine-to-machine payments. By integrating MPP with AgentMail, your agents can pay for API usage directly without managing API keys or subscriptions.

### Prerequisites

- A crypto wallet with funds (EVM-compatible wallet)
- Node.js installed

### Install dependencies

```bash
npm install agentmail mppx viem
```

### Quickstart

```typescript
import { privateKeyToAccount } from "viem/accounts";
import { Mppx, tempo } from "mppx/client";

import { AgentMailClient } from "agentmail";


// setup MPP client

const PRIVATE_KEY = "0x...";

const account = privateKeyToAccount(PRIVATE_KEY);

export const mppx = Mppx.create({ methods: [tempo({ account })] });
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Disable MPP's default global fetch polyfill here. AgentMailClient({ mppx }) already consumes mppx.fetch, so leaving the default on adds an unnecessary process-wide side effect for unrelated requests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At fern/pages/integrations/mpp.mdx, line 38:

<comment>Disable MPP's default global fetch polyfill here. `AgentMailClient({ mppx })` already consumes `mppx.fetch`, so leaving the default on adds an unnecessary process-wide side effect for unrelated requests.</comment>

<file context>
@@ -0,0 +1,83 @@
+
+const account = privateKeyToAccount(PRIVATE_KEY);
+
+export const mppx = Mppx.create({ methods: [tempo({ account })] });
+
+
</file context>
Fix with Cubic



// setup AgentMail client

export const client = new AgentMailClient({ mppx });


// create inbox

const inboxRes = await client.inboxes.create({
username: `mpp-${Date.now()}`,
});
console.log("Created inbox: ", inboxRes.inboxId);


// subscribe to inbox

const socket = await client.websockets.connect();
console.log("Connected to websocket");

socket.on("message", async (event) => {
if (event.type === "subscribed") {
console.log("Subscribed to", event.inboxIds);
} else if (event.type === "event" && event.eventType === "message.received") {
console.log("Received message from: ", event.message.from);
}
});

socket.sendSubscribe({
type: "subscribe",
inboxIds: [inboxRes.inboxId],
});
```

## How it works

When you pass an `mppx` client to `AgentMailClient`, the SDK automatically handles payment negotiation for each API request. The MPP client signs payments using your wallet, enabling your agent to pay per request seamlessly.

This means your agent can use the full AgentMail API (inboxes, messages, threads, attachments) without needing a traditional API key. Payment happens per-request via Stripe's Machine Payments Protocol.

## Resources

- [MPP documentation](https://mpp.dev)
- [AgentMail API reference](/api-reference)
- [WebSockets overview](/websockets)
Loading