Supabase MCP Server
A Model Context Protocol (MCP) server for interacting with Supabase databases. This server implements the Model Context Protocol using the FastMCP Python SDK to provide database operation tools for large language models (LLMs).
Features
- Read records from Supabase tables with filtering, pagination, and sorting
- Create new records (single or batch) in Supabase tables
- Update existing records based on filter conditions
- Delete records from tables based on filter conditions
- Communicates using MCP's Stdio transport
Prerequisites
- Python 3.8 or higher
- A Supabase project with tables already set up
- Supabase service role key for authentication
Installation
- Clone this repository:Copy
- Set up a virtual environment (recommended):Copy
- Install the dependencies:Copy
- Set up environment variables:
- Copy the
.env.example
file to.env
:Copy - Fill in your Supabase URL and service role key in the
.env
file:Copy
- Copy the
Usage
Starting the Server
Make sure your virtual environment is activated, then run the server:
The server uses Stdio transport, so it will listen for MCP requests on standard input and respond on standard output.
Integrating with MCP Clients
This server implements the Model Context Protocol and can be integrated with any MCP-compatible client. For example, you can use it with LLM frameworks that support MCP tools.
Adding to Windsurf/Cursor MCP Configuration
To add this MCP server to your Windsurf or Cursor configuration:
- Locate your
mcp_config.json
file:- Windows:
C:\Users\<username>\.codeium\windsurf\mcp_config.json
- macOS:
~/.codeium/windsurf/mcp_config.json
- Linux:
~/.codeium/windsurf/mcp_config.json
- Windows:
- Add the Supabase MCP server to the
mcpServers
section:
Replace /path/to/your/supabase-mcp/server.py
with the absolute path to your server.py file.
Note: For better isolation, you can use the Python executable from your virtual environment:
- Restart your Windsurf/Cursor application to apply the changes.
- The Supabase MCP tools will now be available to your AI assistant.
Tool Descriptions
The server provides the following tools:
1. read_records
Reads records from a Supabase database table with flexible querying options.
Parameters:
table
(string, required): Name of the table to read fromcolumns
(string, optional, default: "*"): Columns to select (comma-separated or * for all)filters
(object, optional): Filtering conditions as key-value pairslimit
(integer, optional): Maximum number of records to returnoffset
(integer, optional): Number of records to skip for paginationorder_by
(object, optional): Sorting options as column:direction pairs
Example:
2. create_records
Creates one or more records in a Supabase database table.
Parameters:
table
(string, required): Name of the table to create records inrecords
(object or array, required): A single record object or array of record objects to create
Example (single record):
Example (multiple records):
3. update_records
Updates existing records in a Supabase database table based on filter conditions.
Parameters:
table
(string, required): Name of the table to update records inupdates
(object, required): Fields to update as key-value pairsfilters
(object, required): Filtering conditions to identify records to update
Example:
4. delete_records
Deletes records from a Supabase database table based on filter conditions.
Parameters:
table
(string, required): Name of the table to delete records fromfilters
(object, required): Filtering conditions to identify records to delete
Example:
Development
Project Structure
server.py
: Main MCP server implementationsupabase_client.py
: Supabase client wrapperrequirements.txt
: Python dependencies.env.example
: Example environment variables file
Adding New Tools
To add a new tool to the server:
- Define a Pydantic model for the tool's request parameters in
server.py
- Add a handler method to the
SupabaseMCPServer
class - Register the tool in the
_register_tools
method with a descriptive name and documentation
License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
This server cannot be installed
Implements the Model Context Protocol to provide LLMs with tools for interacting with Supabase databases, supporting operations like reading, creating, updating, and deleting records with filtering and pagination capabilities.