How to Build and Monetize Your Own MCP Server with Stripe and Cloudflare
Craft an MCP server that monetizes through Stripe and Cloudflare. Learn to set up payments, authentication, and a seamless user experience to distribute and earn from your custom AI assistant.
27 maj 2025

Unlock the power of monetizing your own MCP (Multi-Modal Capability) server with this comprehensive guide. Discover how to set up a seamless payment system, implement a robust authentication layer, and leverage cutting-edge tools to build a thriving MCP business. Elevate your AI-powered offerings and reach a wider audience with this benefit-driven approach.
Build Your Own Profitable MCP Server with Stripe and Cloudflare
Set Up Payment System for Your MCP Server
Onetime Payment
Subscription Payment
Usage-Based Payment
Implement Authentication System for Your MCP Server
Conclusion
Build Your Own Profitable MCP Server with Stripe and Cloudflare
Build Your Own Profitable MCP Server with Stripe and Cloudflare
To build your own profitable MCP (Multi-modal Capability) server, you can leverage the Stripe Agent Toolkit and Cloudflare's MCP Agent class. Here's how you can set it up:
-
Set up Payment System for Your MCP Server:
- Use the Stripe Agent Toolkit to define your MCP server and add payment-gated tools.
- You can set up various pricing strategies, such as one-time payments, recurring subscriptions, or usage-based pricing.
- For usage-based pricing, you can create tiers with free credits and per-unit charges for additional usage.
- Stripe's Agent SDK makes it easy to integrate payment functionality into your MCP server.
-
Implement Authentication Layer for Your MCP Server:
- Use Cloudflare's OAuth Provider class to handle the OAuth flow for your MCP server.
- Implement a sign-up flow and replace the default handler logic to check if the user is already logged in.
- Leverage the MCP Remote package to provide a seamless user experience, where users are prompted to sign in when trying to connect to your MCP server.
- Integrate a third-party authentication system, such as Supabase, to manage user accounts and one-time passwords.
By combining the Stripe Agent Toolkit, Cloudflare's MCP Agent class, and the MCP Remote package, you can create a paid MCP server that offers a smooth user experience, sophisticated pricing strategies, and secure authentication. This setup allows you to monetize your MCP server effectively and distribute it to a wide audience.
For more detailed step-by-step instructions and code examples, you can refer to the resources available in the AI Builder Club, which the speaker mentioned in the transcript.
Set Up Payment System for Your MCP Server
Set Up Payment System for Your MCP Server
Stripe has an agent toolkit that allows you to define an MCP server and easily add payment gateways. You can set up various pricing strategies, such as one-time pricing for lifetime access, recurring subscriptions, or usage-based pricing.
The paid MCP agent class provided by Stripe is an extended version of Cloudflare's MCP agent class, which allows you to turn any function into an MCP tool. With the paid MCP agent class, you can add paid tools by providing the price ID, payment reason, and other necessary information.
When a user tries to call a paid MCP tool without having paid, the agent will return a payment link and the reason for the payment, which the agent can then render and show to the user.
You can set up different pricing tiers, such as the first 5 generations being free, then $1 per unit for the next 30 generations, and $10 for 500 credits, with additional usage charged at $0.001 per new generation. Stripe's metering feature can be used to track the usage and automatically calculate the invoice.
By using the Stripe agent toolkit, you can easily add pricing and payment to your MCP server, allowing you to start monetizing your MCP offerings.
Onetime Payment
Onetime Payment
To set up a one-time payment for your MCP server, you can follow these steps:
- Go to Stripe and create a new product.
- Define the pricing for the one-time payment. This will be a one-off fee that users will pay to access your MCP server.
- Stripe will provide you with a Pricing ID for this one-time payment. Copy this Pricing ID.
- In your MCP server code, use the Stripe Agent Toolkit to define a new paid MCP tool. Provide the Pricing ID, a payment reason, and a payment success URL where users will be redirected after successful payment.
const paidTool = this.addPaidTool({
name: 'One-Time MCP Access',
description: 'Access to the MCP server',
inputType: 'string',
handler: async (input) => {
// Your MCP tool logic here
},
pricingId: 'price_12345abcde',
paymentReason: 'Access to the MCP server',
paymentSuccessUrl: 'https://your-website.com/success'
});
- When a user tries to use the paid MCP tool, the Stripe Agent Toolkit will automatically handle the payment flow. If the user hasn't paid yet, it will return a payment link that the user can use to complete the payment.
- After the user completes the payment, they will be redirected to the
paymentSuccessUrl
, where you can provide them with instructions on how to start using the MCP server.
This setup allows you to easily monetize your MCP server by offering a one-time payment option for users to access its capabilities.
Subscription Payment
Subscription Payment
To set up a subscription payment for your MCP server, you can use the Stripe Agent Toolkit. The setup is similar to the one-time payment, but the pricing will be recurring.
Here's how you can do it:
- Go to Stripe and create a new product.
- Set up the pricing for the subscription. You can choose a flat-rate fee for the subscription.
- Copy the Pricing ID for the subscription.
- In your MCP server code, use the
paid MCP agent
class provided by Stripe. Define the paid tool and pass the Pricing ID, payment reason, and payment success URL.
const paidMCPAgent = new PaidMCPAgent({
name: 'My Paid MCP Server',
version: '1.0.0',
});
paidMCPAgent.addPaidTool({
name: 'Emoji Generator',
inputType: 'string',
handler: generateEmoji,
priceId: 'price_12345678',
paymentReason: 'Access to the Emoji Generator tool',
paymentSuccessUrl: 'https://your-app.com/payment-success',
});
In this example, the priceId
is the Pricing ID you copied from Stripe, and the paymentSuccessUrl
is the page where you'll redirect the user after a successful payment.
With this setup, when a user tries to use the "Emoji Generator" tool, they'll be prompted to subscribe and make a payment. After the payment is successful, they'll be able to use the tool.
You can also set up more sophisticated pricing strategies, such as usage-based pricing, by using Stripe's Metering feature. This allows you to charge users based on the actual usage of your MCP server.
Remember to also set up the authentication layer using Cloudflare's OAuth provider and the MCP Remote package, as described in the previous section, to provide a seamless user experience for your paid MCP server.
Usage-Based Payment
Usage-Based Payment
Stripe's agent toolkit allows you to define an MCP server and easily add payment gateways to your tools. One of the most interesting payment strategies for an MCP server is usage-based pricing.
With usage-based pricing, you can set up sophisticated tiers to monetize your MCP server effectively. For example, you could offer the first 5 generations for free, then charge $1 per unit for the next 30 generations, and then introduce a $10 tier that includes 500 credits. Any usage beyond the 500 credits could be charged at $0.001 per new generation.
To implement this, you'll need to create a Stripe meter to track the usage. You can then attach this meter to your pricing tiers, and Stripe will automatically calculate the invoice based on the user's consumption.
This usage-based approach allows you to provide a great user experience, where users can start using your MCP server right away, and only pay for what they use. As they find more value in your MCP, they'll be more likely to upgrade to higher tiers, helping you build a sustainable and scalable business.
Implement Authentication System for Your MCP Server
Implement Authentication System for Your MCP Server
To build an authentication system for your MCP server, you'll need to use two key components:
-
Cloudflare OAuth Provider: Cloudflare provides an OAuth provider class that handles the OAuth flow for your MCP server. This allows users to grant access to your MCP server from various client applications.
-
MCP Remote: The MCP Remote package helps you create a seamless user experience where users are prompted to log in when they try to connect your MCP server, such as in Cursor. This eliminates the need for users to manually generate an API key and pass it in.
Here's how you can implement the authentication system:
-
Set up Cloudflare OAuth Provider:
- In your
index.ts
file, define the Cloudflare OAuth Provider at the bottom, similar to the example provided. - Implement the default handler
app
in theapp.ts
file, which will handle the OAuth flow. - Instead of the mock authentication logic, build your own authentication flow, such as checking if the user is already logged in. If not, show a sign-up page.
- In your
-
Integrate MCP Remote:
- Install the
mcp-remote
package. - In your MCP server setup, change the command to
mpx mcp-remote
and provide the URL endpoint. - This will automatically prompt the user to log in when they try to connect your MCP server, and only after the user approves will the MCP tools be displayed.
- Install the
-
Implement User Authentication:
- You can use a service like Supabase to handle user authentication.
- Create a
supabase.ts
file with functions to set up the Supabase client, send a one-time password to the user, and verify the one-time password. - In the
app.ts
file, update the/authorize
endpoint to handle the authentication flow, including requesting the one-time password, verifying it, and storing the user session.
By combining the Cloudflare OAuth Provider, MCP Remote, and a user authentication service like Supabase, you can create a seamless authentication system for your MCP server. This will allow users to easily connect and use your MCP tools, while also capturing their email addresses and enabling you to monetize your MCP server through usage-based pricing or subscriptions.
Conclusion
Conclusion
Here is the body of the "Conclusion" section in Markdown format:
In conclusion, we have explored the process of setting up a paid MCP (Multimodal Capability Provider) server that can be monetized effectively. The key steps covered include:
-
Integrating Stripe's Agent Toolkit: This allows you to define paid MCP tools with various pricing models, such as one-time payments, subscriptions, and usage-based tiers. You can easily set up sophisticated pricing strategies to monetize your MCP server.
-
Implementing Authentication with Cloudflare's OS Provider: By using Cloudflare's OS provider, you can set up an authentication system for your MCP server, enabling users to sign up, log in, and grant access to your MCP tools.
-
Enhancing the User Experience with MCP Remote: The MCP Remote package helps provide a seamless user experience, where users can connect to your MCP server directly from tools like Cursor, without the need to manually generate API keys or go through a complex setup process.
By combining these components, you can create a paid MCP server that offers a smooth and user-friendly experience, while also providing a robust monetization strategy. This approach makes it easier to distribute and monetize your MCP server, allowing you to reach a wider audience and potentially generate revenue from your domain-specific AI capabilities.
Remember, the resources and templates mentioned in the video are available in the AI Builder Club, where you can find more in-depth tutorials and support from the community. Feel free to explore the club and start building your own successful paid MCP server.
FAQ
FAQ