Stripe | Financial Infrastructure to Grow Your Revenue

Stripe | Financial Infrastructure to Grow Your Revenue

5282 articles

Monetise your Model Context Protocol (MCP) server


Public preview

Monetise your Model Context Protocol (MCP) server Public preview

Charge AI agents for one-time payments using MPP.

This guide shows how to charge AI agents for one-time purchases, such as service bookings, donations, or digital goods, by using a Model Context Protocol (MCP) server, Stripe, and the Machine Payments Protocol (MPP).

The approach in this guide is experimental and works with AI agents that support MCP and can make HTTP requests that handle MPP. You can accept payments from agents with a variety of payment methods, including cards through Shared Payment Tokens (SPTs) and stablecoin payments.

Payments settle through your existing Stripe or Connect setup, so you keep your receipts, fees and customer relationship. The same link also falls back to your existing checkout or donation form for human users, so you don’t need to change how you currently accept payments to support agents.

Note

Non-profits and fundraising platforms can use this flow to accept agent-initiated donations. The MPP receipt confirms the payment, but it doesn’t replace any donation acknowledgement or tax receipt that the non-profit or platform must provide.

Understand how payment works

When an AI agent calls one of your MCP tools, you can collect payment before you return a result.

When MPP defines the HTTP payment handshake:

  1. The client requests a resource without payment.
  2. Your server returns an HTTP 402 response with a payment challenge.
  3. The client obtains an SPT credential and retries the request.
  4. Your server verifies payment and returns the resource with a receipt.

In this pattern, your MCP tool validates the request, then returns a payment link. That link points to a separate HTTP endpoint that handles MPP. The agent posts to the URL, and MPP handles the challenge and credential flow at the HTTP layer.

The same URL can also work for human users. If a browser opens it, the endpoint recognises the Accept: text/html header, redirects to a checkout page that you control and prefills the relevant parameters. This example demonstrates browser detection and redirection, but it doesn’t implement a card checkout or donation form. Replace the placeholder route with your existing browser payment flow.

Review the flow

The following sequence diagrams show how the same integration supports both the agent flow and browser fallback.

Before you begin

Make sure you have the following set up before you start:

  • Access to Shared Payment Tokens and a valid Stripe profile.
  • A fulfilment flow that validates requests and completes purchases, such as checking availability, confirming inventory or recording a donation.
  • These environment variables:
  • BASE _ URL : The base URL for your application
  • the related setting _ the related setting _ KEY : Your Stripe secret key
  • the related setting _ the related setting _ ID : Your Stripe profile identifier

If you use Connect to route funds to connected accounts, make sure you have the connected account ID available.

Use a coding agent

You can monetise an MCP server by giving your coding agent this prompt:

Command Line

To build the integration yourself, follow the steps in this guide to define your MCP tool, create a server that handles MPP payments and test the full payment flow.

You can also review the app’s complete source code on GitHub.

Install dependencies

Install the required dependencies:

Command Line

npm install @hono/node-server @modelcontextprotocol/sdk hono mppx stripe zod

Define your catalogue

This example shows a minimal catalogue for testing. In production, replace it with your inventory and fulfilment logic.

catalog.ts

const catalog = [
 { id: 'coffee', title: 'Coffee', priceCents: 500 },
 { id: 'sticker', title: 'MCP sticker', priceCents: 200 },
]

type Purchase = {
 item: (typeof catalog)[number]
 quantity: number
 customerName: string
 customerEmail: string
}

export function getItem(itemId: string | null) {
 return catalog.find((item) => item.id === itemId)
}

export function validatePurchase(input: { item: (typeof catalog)[number] | undefined; quantity: number; customerName: string | null; customerEmail: string | null }): input is Purchase {
 return input.item !== undefined && Number.isInteger(input.quantity) && input.quantity >= 1 && input.customerName !== null && input.customerName.length > 0 && input.customerEmail !== null && input.customerEmail.length > 0
}

export function completeOrder(purchase: Purchase) {
 return { id: `${purchase.item.id}-${purchase.quantity}`, status: 'complete' }
}

Define your MCP tool

The following example shows the MCP tool definition. It validates the purchase request and returns a payment link without handling payment directly.

mcp.ts

Create your server

The following example shows the HTTP endpoint that handles MPP payments for agents and redirects browsers to a checkout flow that you control. It also hosts the MCP tool.

server.ts

This example uses a basic implementation of an MCP endpoint. For a production deployment, make sure to add authentication and other controls that your application requires.

Configure Connect

If you’re using Connect, define connectOptions before the stripe.create() call and uncomment the connect line:

const connectedAccountId = process.env.STRIPE_CONNECTED_ACCOUNT_ID

const connectOptions = {
 applicationFeeAmount: 250,

 // Direct charge — the PaymentIntent is created directly on the connected
 // account. Pass the connected account ID as `stripeAccount` instead of
 // `transferData`/`onBehalfOf`.
 stripeAccount: connectedAccountId,

 // Destination charge — the PaymentIntent is created on your platform
 // account and funds move to the connected account after the charge.
 // `onBehalfOf` is optional; set it if you want the connected account's
 // statement descriptor, MCC, and so on to apply to the charge.
 // transferData: { destination: connectedAccountId },
 // onBehalfOf: connectedAccountId,
}

Test your integration

You can test the full agent payment flow end to end by connecting your MCP server and the Link agent wallet to an agent harness that you control, such as Claude Code, then asking the agent to complete a payment. When everything is configured correctly, the agent can use your MCP server and the Link agent wallet independently to discover your tool, call the payment endpoint, obtain a credential, and complete the purchase.

Start your server

Start the server to host both the MCP tool and payment functionality:

Command Line

Add your MCP server

Add your MCP server to an agent harness that you control. Replace https://example.com/mcp with the URL where your server is running. For local testing, this URL is http://localhost:4242/mcp by default.

Run the following command:

Command Line

claude mcp add --transport http paid-catalog https://example.com/mcp

Add the Link agent wallet skill so the agent can provision a shared payment token to pay:

Command Line

npx skills add stripe/link-cli

Configure Test mode

Add an instruction to your agent’s context, such as in the related setting.md or the system prompt, that identifies the flow as a test. This signals the Link agent wallet to create shared payment tokens in a sandbox, which return test credentials and don’t charge the underlying payment method.

With that configuration in place, make sure that your agent passes the --test flag when it creates a spend request so the entire flow runs against test credentials end to end.

Ask the agent to complete a payment

Prompt the agent to use your MCP server to make a purchase.

Command Line

Use the `create_purchase_link` tool from the paid-catalog MCP to purchase one item with the ID `coffee` for a customer named `Alice` with the email `test@example.com`.

This flow uses test mode, so it doesn't move real funds. Make sure you use the test mode flag when you create the Link spend request.

When you configure your integration correctly, the agent calls your MCP tool, receives the payment link, follows the returned Link CLI instructions to obtain a sandbox credential and completes the payment.

Verify expected behaviour

Verify these behaviours during testing:

  • The order is completed in your system.
  • The payment succeeds.
  • The link shows a checkout page when you open it in a browser.
  • If you use Connect , your integration routes funds to the expected connected account.

You can also test the payment endpoint directly, open it in a browser, or use the Link CLI to make an MPP payment request manually.

List your MCP server on the Stripe Directory

After you finish your integration, submit it for listing in the Stripe Directory, a catalogue of tools and services that helps agents find your business.

Email with:

  • Your business name
  • Your Stripe account ID
  • Your Stripe profile ID. If necessary, claim your Stripe profile .
  • A link to your llms. txt file and links to any agent skills
  • One to three example prompts that demonstrate your use case

See also

Last verified 2026-09-25

Is this helpful?