kodiii/SupabaseSelfHostMCP
If you are the rightful owner of SupabaseSelfHostMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server designed for self-hosted Supabase instances, enabling seamless interaction with local or privately hosted Supabase projects.
Supabase Self-Host MCP Server
A Model Context Protocol (MCP) server designed specifically for self-hosted Supabase instances. This server bridges MCP clients (e.g., IDE extensions) with local or privately hosted Supabase projects, facilitating database introspection, management, and interaction directly from the development environment.
Features
- Database schema introspection and querying
- Database migration management
- Database statistics and connection inspection
- Authentication user management
- Supabase Storage interaction
- Type definition generation
Prerequisites
- Node.js (v16 or higher)
- A self-hosted Supabase instance
- PostgreSQL database access
Installation
-
Clone this repository:
git clone https://github.com/yourusername/supabase-selfhost-mcp.git cd supabase-selfhost-mcp -
Install dependencies:
npm install -
Create a
.envfile based on the example:cp .env.example .env -
Update the
.envfile with your Supabase and database configuration.
Configuration
Create a .env file in the root of the project and add the following environment variables. You can use the .env.example file as a template.
| Variable | Description | Default |
|---|---|---|
PORT | The port the server will run on. | 3010 |
NODE_ENV | The environment mode. Can be development or production. | development |
SUPABASE_URL | The URL of your Supabase instance. | http://localhost:8000 |
SUPABASE_SERVICE_ROLE_KEY | The service role key for your Supabase instance. | |
SUPABASE_ANON_KEY | The anonymous key for your Supabase instance. | |
DB_HOST | (Optional) The host of your PostgreSQL database. If not provided, the server will attempt to connect using SUPABASE_URL. | localhost |
DB_PORT | (Optional) The port of your PostgreSQL database. If not provided, the server will attempt to connect using SUPABASE_URL. | 5432 |
DB_NAME | (Optional) The name of your PostgreSQL database. If not provided, the server will attempt to connect using SUPABASE_URL. | postgres |
DB_USER | (Optional) The username for your PostgreSQL database. If not provided, the server will attempt to connect using SUPABASE_URL. | postgres |
DB_PASSWORD | (Optional) The password for your PostgreSQL database. If not provided, the server will attempt to connect using SUPABASE_URL. | postgres |
JWT_SECRET | A secret key for signing JWTs. | |
JWT_EXPIRY | The expiration time for JWTs (e.g., 24h, 1d). | 24h |
LOG_LEVEL | The logging level. Can be info, warn, error, debug. | info |
Usage
Development
npm run dev
Production
npm run build
npm start
API Endpoints
Database
GET /api/database/schemas: List all schemasGET /api/database/tables: List all tablesGET /api/database/tables/:schema/:table: Get table detailsPOST /api/database/query: Execute SQL query
Migrations
GET /api/migrations: List all migrationsPOST /api/migrations: Create a new migrationPOST /api/migrations/apply: Apply pending migrations
Authentication
GET /api/auth/users: List all usersPOST /api/auth/users: Create a new userPUT /api/auth/users/:id: Update a userDELETE /api/auth/users/:id: Delete a user
Storage
GET /api/storage/buckets: List all bucketsGET /api/storage/buckets/:id/objects: List objects in a bucketPOST /api/storage/buckets/:id/objects: Upload an objectDELETE /api/storage/buckets/:id/objects/:path: Delete an object
Types
GET /api/types/generate: Generate type definitions
Security Considerations
This server is designed to be used in a trusted environment. It uses service role keys to access Supabase resources, which have full access to your database and other services. Make sure to:
- Run this server in a secure environment
- Use strong JWT secrets
- Implement proper authentication for API endpoints
- Restrict network access to the server
- Regularly update dependencies
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.