Earlier this month, Stripe and Cloudflare released a new SDK for creating paid Model Context Protocol (MCP) servers.

Understanding MCP

The Model Context Protocol (MCP) is an open standard that enables AI assistants and LLMs to connect with external services and tools. Anthropic describes it as "a USB-C port for AI applications," providing a standardized way to connect AI models with various data sources and tools.

Until recently, MCP support was limited to Claude Desktop with local servers. This update changes the game by enabling seamless integration between remote MCP servers and web platforms, significantly expanding the ecosystem's potential.

Why Stripe and Cloudflare's Paid MCP Matters

This collaboration brings together Stripe's payment processing expertise and Cloudflare's edge computing infrastructure to create a toolkit that makes it easy to implement paid tools and services that AI assistants can access.

What makes this particularly interesting is the ability to monetize your APIs and services through AI assistants. Developers can now expose their services to AI assistants and charge for their use, opening up new revenue streams in the AI space.

Implementation Walkthrough

Let's dive into how to build a paid MCP server step by step.

1. Setting Up the Project

First, create a basic MCP server using Cloudflare's template:

npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-authless

This command creates a template for a basic MCP server without authentication.

2. Adding Stripe Integration

Next, install Stripe's agent toolkit:

npm i @stripe/agent-toolkit

3. Modifying the Code

Edit the src/index.ts file to incorporate Stripe integration:

import { McpAgent } from "agents/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import {
  PaymentState,
  experimental_PaidMcpAgent as PaidMcpAgent,
} from '@stripe/agent-toolkit/cloudflare';

type Bindings = {
  // Add environment variables here
}

type Props = {
  userEmail: string;
};

type State = PaymentState & {};

// Change from standard McpAgent to PaidMcpAgent
export class MyMCP extends PaidMcpAgent<Bindings, State, Props> {
  server = new McpServer({
    name: "Authless Calculator",
    version: "1.0.0",
  });

  async init() {
    // Existing free tool
    this.server.tool(
      "add",
      { a: z.number(), b: z.number() },
      async ({ a, b }) => ({
        content: [{ type: "text", text: String(a + b) }],
      })
    );

    // Calculator functionality (free)
    this.server.tool(
      "calculate",
      {
        operation: z.enum(["add", "subtract", "multiply", "divide"]),
        a: z.number(),
        b: z.number(),
      },
      async ({ operation, a, b }) => {
        let result: number;
        switch (operation) {
          case "add":
            result = a + b;
            break;
          case "subtract":
            result = a - b;
            break;
          case "multiply":
            result = a * b;
            break;
          case "divide":
            if (b === 0)
              return {
                content: [
                  {
                    type: "text",
                    text: "Error: Cannot divide by zero",
                  },
                ],
              };
            result = a / b;
            break;
        }
        return { content: [{ type: "text", text: String(result) }] };
      }
    );

    // Paid tool using Stripe
    this.paidTool(
      'add_numbers',
      {
        a: z.number(),
        b: z.number(),
      },
      ({a, b}) => {
        return {
          content: [{type: 'text', text: `Result: ${a + b}`}],
        };
      },
      {
        priceId: '{{PRICE_ID}}', // Replace with your actual price ID from Stripe
        successUrl: 'https://mcp.mysite.com/success',
        paymentReason:
          'You must pay a subscription to add two big numbers together.',
      }
    );
  }
}

export default {
  fetch(request: Request, env: Env, ctx: ExecutionContext) {
    const url = new URL(request.url);
    if (url.pathname === "/sse" || url.pathname === "/sse/message") {
      // @ts-ignore
      return MyMCP.serveSSE("/sse").fetch(request, env, ctx);
    }
    if (url.pathname === "/mcp") {
      // @ts-ignore
      return MyMCP.serve("/mcp").fetch(request, env, ctx);
    }
    return new Response("Not found", { status: 404 });
  },
};

4. Configuring Stripe API Keys

For Stripe integration, you'll need an API key with the following permissions:

  • customer: write
  • checkout: write
  • subscription: read
  • meterEvents: write

Image description

After generating a new restricted API key, place this API key in your .dev.vars file as shown below:

STRIPE_SECRET_KEY=rk_test_xxx

Make sure to replace rk_test_xxx with your actual restricted API key.

5. User Authentication

The PaidMcpAgent uses props.userEmail to identify or create a Stripe customer. You have two options:

  1. Directly populate the email address
  2. Integrate with OAuthProvider from @cloudflare/workers-oauth-provider to set the prop on successful authentication

For testing purposes, you can simply ask users to enter their email address directly.

6. Local Development and Testing

Start the local development server:

npm run dev

Then, add your local server to Claude Desktop's MCP configuration:

{
  "mcpServers": {
    "calculator": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:8787/sse" // Change to your remote URL in production
      ]
    }
  }
}

You can use the add_numbers tool for calculating number.

Image description

However, when you first try to use it, the server will return an error message because you haven't subscribed to their paid plan yet.

Image description

To resolve this, you need to copy and paste the checkout session link provided in the error message and complete the payment process. Once the subscription is activated, you'll be able to use this calculation tool without any issues.

Image description

Hands-on Experience

The basic calculation tools that came with the template worked flawlessly, confirming that the MCP setup and functionality were correctly implemented.

The key to paid tools is the integration with Stripe's payment flow. When a user attempts to use a paid tool, they're redirected to Stripe's payment page, and once payment is complete, the tool becomes available for use.

Technical Considerations

When implementing a paid MCP server, a few technical considerations stand out:

  1. Authentication Flow: Deciding between direct email input and OAuth integration depends on your application's security requirements and user experience goals.

  2. State Management: The PaidMcpAgent handles payment state, but you may need to extend it for your specific use case.

  3. Error Handling: Robust error handling for payment failures and API issues is essential for a smooth user experience.

  4. Testing Environment: Stripe provides a testing environment that allows you to simulate payments without processing actual charges.

Future Possibilities

The integration of paid MCP servers by Stripe and Cloudflare significantly expands the possibilities for services that can be offered through AI assistants. Developers who own open-source projects can monetize their documentation by turning it into MCP servers. Those who write technical blogs focused on specific languages or frameworks can offer paid knowledge bases that make it easy to incorporate their expertise into development processes. It's also possible to provide tools that handle complex workflows.

What we're seeing is the emergence of new business opportunities for MCP servers, which were previously often viewed primarily as internal productivity tools. This technology is transforming how specialized knowledge and capabilities can be packaged, distributed, and monetized through AI assistants.

Conclusion

The Stripe and Cloudflare SDK for paid MCP servers represents a significant milestone in the evolution of AI capabilities monetization. This collaboration between payment infrastructure and edge computing creates new opportunities for developers to build sustainable business models around their expertise and tools.

What makes this particularly exciting is how it democratizes AI monetization. Individual developers with specialized knowledge, technical bloggers with deep domain expertise, and companies with proprietary workflows can all now package their value as MCP servers that integrate directly with AI assistants. This shifts MCP from being primarily an internal productivity enhancement to a potential revenue stream.

The barrier to entry is relatively low, with implementation leveraging Stripe's familiar infrastructure and Cloudflare's developer-friendly platform. As the AI ecosystem matures, we're likely to see a rich marketplace of specialized MCP servers emerge, each offering unique capabilities that extend what AI assistants can do for users.

For those looking to position themselves in the growing AI economy, building a paid MCP server could be a strategic way to package existing expertise and capabilities for a new audience of AI-powered applications.


This article is based on information available as of May 2, 2025. MCP and Stripe's API may change in the future, so please refer to the official documentation for the most up-to-date information.