Skip to content

xwaleedahmad/supabase-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Supabase MCP - Model Context Protocol Server

A powerful Model Context Protocol (MCP) server that enables seamless interaction with Supabase databases. This project provides a comprehensive suite of CRUD operations through the MCP interface, allowing AI assistants and tools to manage your Supabase data effortlessly.

🌟 About The Project

Supabase MCP is a Next.js-powered MCP server that bridges the gap between AI assistants and Supabase databases. It exposes a set of standardized tools that enable AI models to perform database operations through the Model Context Protocol, making it easy to build AI-powered applications with persistent data storage.

The project features a beautiful landing page showcasing the available tools and provides a production-ready MCP server endpoint that can be integrated with Claude Desktop, AI agents, or any MCP-compatible client.

✨ Key Features

  • πŸ”Œ MCP Server Integration - Full Model Context Protocol server implementation with SSE and HTTP transport support
  • πŸ“Š Complete CRUD Operations - Create, Read, Update, Delete operations for Supabase tables
  • 🎯 Type-Safe - Built with TypeScript and Zod validation for robust type safety
  • ⚑ Real-time Ready - Powered by Supabase's real-time capabilities
  • 🎨 Modern UI - Beautiful, responsive landing page with animated components
  • πŸ”’ Secure - Environment-based configuration with Supabase Row Level Security support
  • πŸš€ Production Ready - Optimized Next.js build with error handling and validation

πŸ› οΈ Available Tools

The MCP server provides 6 powerful tools for database operations:

1. Create Document

Add new products to your inventory with comprehensive validation for title, price, category, and quantity. Automatically validates data types and constraints before insertion.

2. List Documents

Retrieve all products from the database with optional filtering by any column.

3. Get Document

Find specific products by any column (ID, title, price, category, etc.) with exact value matching.

4. Update Document

Modify existing product details with flexible JSON-based updates. Supports partial updates of any field.

5. Upsert Document

Create or update records intelligently based on primary key (ID). Perfect for bulk operations and synchronization tasks.

6. Delete Document

Safely remove products from the inventory with existence verification before deletion.

πŸ—οΈ Tech Stack

Frontend

Backend & Database

Validation & Utilities

  • Zod - TypeScript-first schema validation
  • clsx - Conditional className utility
  • tailwind-merge - Merge Tailwind classes

Development Tools

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm/yarn/pnpm
  • A Supabase account and project (Create one here)

Installation

  1. Clone the repository

    git clone https://github.com/xwaleedahmad/supabase-mcp.git
    cd supabase-mcp
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
    NEXT_PUBLIC_SERVER_URL=http://localhost:3000/mcp  (to connect the mcp with AI Assistants)

    Get your Supabase credentials from:

    • Go to Supabase Dashboard
    • Select your project
    • Navigate to Settings β†’ API
    • Copy the Project URL and anon/public key
  4. Run the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
  5. Open your browser

    Navigate to http://localhost:3000 to see the landing page.

πŸ—„οΈ Database Table Schema

Create the following table in your Supabase database:

Products Table

CREATE TABLE "Products" (
  "id" UUID DEFAULT gen_random_uuid() PRIMARY KEY,
  "title" TEXT NOT NULL,
  "price" NUMERIC NOT NULL CHECK (price > 0),
  "category" TEXT NOT NULL,
  "quantity" INTEGER DEFAULT 1 CHECK (quantity >= 0),
  "created_at" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

Run this SQL in your Supabase SQL Editor:

  1. Go to your Supabase Dashboard
  2. Navigate to SQL Editor
  3. Click New Query
  4. Paste the SQL above and click Run

πŸ“ Project Structure

supabase-mcp/
β”œβ”€β”€ public/                      # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ [transport]/
β”‚   β”‚   β”‚   └── route.ts        # MCP server endpoint (SSE/HTTP)
β”‚   β”‚   β”œβ”€β”€ layout.tsx          # Root layout
β”‚   β”‚   β”œβ”€β”€ page.tsx            # Home page
β”‚   β”‚   └── globals.css         # Global styles
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/                 # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ badge.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   └── card.tsx
β”‚   β”‚   β”œβ”€β”€ AnimatedBackground.tsx
β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”œβ”€β”€ Hero.tsx
β”‚   β”‚   β”œβ”€β”€ ToolsShowcase.tsx
β”‚   β”‚   └── VideoShowcase.tsx
β”‚   └── lib/
β”‚       β”œβ”€β”€ utils.ts            # Utility functions
β”‚       └── supabase/
β”‚           └── server.ts       # Supabase client configuration
β”œβ”€β”€ .env.local                   # Environment variables (create this)
β”œβ”€β”€ components.json              # shadcn/ui configuration
β”œβ”€β”€ next.config.ts              # Next.js configuration
β”œβ”€β”€ package.json                # Dependencies
β”œβ”€β”€ postcss.config.mjs          # PostCSS configuration
β”œβ”€β”€ tailwind.config.ts          # Tailwind CSS configuration
└── tsconfig.json               # TypeScript configuration

πŸ”§ Configuration

MCP Client Configuration

Configuration:

{
  "mcpServers": {
    "supabase-mcp": {
      "url": "http://localhost:3000/mcp"
    }
  }
}

For production:

{
  "mcpServers": {
    "supabase-mcp": {
      "url": "https://your-production-domain.com/mcp"
    }
  }
}

πŸ“‘ API Endpoints

MCP Server Endpoint

  • SSE: http://localhost:3000/sse
  • HTTP: http://localhost:3000/mcp

🎯 Usage Examples

Once configured with an MCP client, you can interact with your database using natural language:

"Add a new laptop to the inventory priced at $999 in the Electronics category"
β†’ Uses create_document tool

"Show me all products in the Electronics category"
β†’ Uses list_documents tool with filtering

"Find the product with ID abc-123"
β†’ Uses get_document tool

"Update the price of product with ID abc-123 to $899"
β†’ Uses update_document tool

"Upsert a product with ID xyz-456, title 'Gaming Mouse', price $59.99, category 'Electronics', quantity 25"
β†’ Uses upsert_document tool

"Delete the product with title 'Old Laptop'"
β†’ Uses delete_document tool

πŸš€ Deployment

Deploy to Vercel (Recommended)

  1. Push your code to GitHub
  2. Import your repository in Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!

Environment Variables for Production

Ensure these are set in your deployment platform:

NEXT_PUBLIC_SUPABASE_URL=your_production_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_production_anon_key

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is open source and available under the MIT License.

πŸ‘¨β€πŸ’» Author

Waleed Ahmad

πŸ™ Acknowledgments

πŸ“ Additional Resources


Built with ❀️ using Model Context Protocol and Supabase

About

MCP server for seamless Supabase interaction, full CRUD support, and effortless data management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors