Supabase MCP Server + Stripe MCP Server

Advanced2 hours
Use Cases

Common Use Cases

  • Subscription management
  • Usage-based billing
  • Customer portal
  • Invoice generation
Before You Begin

Prerequisites

  • Supabase project with auth configured
  • Stripe account with products/prices
  • Understanding of subscription billing models
Walkthrough

Step-by-Step Guide

1

Set Up Data Model

Create Supabase tables for customers, subscriptions, and usage tracking.

2

Configure Stripe Products

Set up products and prices in Stripe matching your plan tiers.

3

Implement Checkout Flow

Create a checkout session that syncs back to Supabase.

async function createSubscription(userId, priceId) {
  const user = await supabase.from("users").select("stripe_customer_id").eq("id", userId).single();
  let customerId = user.stripe_customer_id;
  if (!customerId) {
    const customer = await stripe.createCustomer({ email: user.email, metadata: { userId } });
    customerId = customer.id;
    await supabase.from("users").update({ stripe_customer_id: customerId }).eq("id", userId);
  }
  const session = await stripe.createCheckoutSession({ customer: customerId, line_items: [{ price: priceId, quantity: 1 }], mode: "subscription" });
  return session.url;
}
4

Handle Webhooks

Process Stripe webhook events to update subscription status in Supabase.

5

Build Customer Portal

Allow customers to manage their subscription via Stripe's customer portal.

6

Track Usage

Record feature usage in Supabase for usage-based billing metering.

Examples

Code Examples

typescript
Webhook Handler
async function handleStripeWebhook(event) {
  switch (event.type) {
    case "customer.subscription.updated":
      await supabase.from("subscriptions").upsert({
        stripe_subscription_id: event.data.object.id,
        status: event.data.object.status,
        plan: event.data.object.items.data[0].price.id,
        current_period_end: new Date(event.data.object.current_period_end * 1000)
      });
      break;
    case "invoice.payment_failed":
      await notifyCustomer(event.data.object.customer);
      break;
  }
}
Help

Troubleshooting

How do I handle failed payments?+
How do I implement plan changes?+
What about tax calculation?+

Quick Info

DifficultyAdvanced
Time Estimate2 hours
Tools
Supabase MCP ServerStripe MCP Server

Need Integration Help?

Our team can implement this integration for you.

Get in Touch