Supabase Lite MCP Server
A lightweight MCP server that provides 8 essential Supabase database management commands with minimal token usage, enabling efficient database operations through Claude.
README
Supabase Lite MCP Server
Overview
The Supabase Lite MCP Server is a lightweight Model Context Protocol (MCP) server that provides essential Supabase database management commands. This focused implementation reduces token usage from ~14,800 to ~3,700 tokens by exposing only 8 core commands instead of the full 26.
Features
- š Minimal Token Usage: Only ~3,700 tokens vs ~14,800 for the full Supabase MCP
- šÆ Essential Commands Only: 8 carefully selected database management commands
- š¦ Easy Installation: Automated setup script with environment validation
- š§ TypeScript: Full type safety and modern ES modules
- š Secure: Uses service role keys with proper environment variable handling
- š ļø Production Ready: Error handling, logging, and MCP protocol compliance
Quick Start
Automated Installation
# Clone the repository
git clone https://github.com/your-username/supabase-lite-mcp.git
cd supabase-lite-mcp
# Run the setup script
./setup.sh
The setup script will:
- Check Node.js version (requires v22+)
- Install dependencies
- Guide you through configuration
- Build the TypeScript code
- Optionally test the server
Manual Installation
-
Install dependencies:
npm install -
Configure environment:
cp .env.example .env # Edit .env with your Supabase credentials -
Build the project:
npm run build -
Test the server:
npm run dev
Configuration
Environment Variables
Create a .env file with your Supabase credentials:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
SUPABASE_PROJECT_REF=your-project-ref # Optional
Get these from your Supabase dashboard:
- URL: Settings ā API ā Project URL
- Service Key: Settings ā API ā Service role key (NOT anon key!)
- Project Ref: Settings ā General ā Reference ID
Claude Integration
Add to your MCP configuration file (.mcp.json):
{
"mcpServers": {
"supabase-lite": {
"command": "node",
"args": ["path/to/supabase-lite-mcp/dist/index.js"],
"env": {
"SUPABASE_URL": "${SUPABASE_URL}",
"SUPABASE_SERVICE_KEY": "${SUPABASE_SERVICE_KEY}"
}
}
}
}
Or use npm link for global access:
cd supabase-lite-mcp
npm link
Then use "command": "supabase-lite-mcp" in your MCP config.
Available Commands
1. list_tables
Lists all tables in specified schemas.
- Use case: Discovering database structure
- Token cost: 457 tokens
2. list_extensions
Shows installed PostgreSQL extensions.
- Use case: Checking available database features
- Token cost: 413 tokens
3. list_migrations
Displays migration history.
- Use case: Tracking schema changes
- Token cost: 413 tokens
4. apply_migration
Applies DDL changes to the database.
- Use case: Creating tables, indexes, etc.
- Token cost: 485 tokens
5. execute_sql
Runs SQL queries for data operations.
- Use case: Querying and modifying data
- Token cost: 474 tokens
6. get_logs
Retrieves service logs from the last minute.
- Use case: Debugging issues
- Token cost: 516 tokens
7. get_advisors
Provides security and performance recommendations.
- Use case: Database optimization
- Token cost: 516 tokens
8. generate_typescript_types
Creates TypeScript interfaces from schema.
- Use case: Type-safe development
- Token cost: 417 tokens
Architecture
How It Works
The server implements the Model Context Protocol (MCP) to communicate with Claude:
Claude āļø MCP Protocol (stdio) āļø Server āļø Supabase API
Key Components
- MCP Server: Handles protocol communication via stdio
- Tool Registry: Defines available commands and their schemas
- Command Handlers: Execute Supabase operations
- Type Safety: Full TypeScript with strict typing
- Error Handling: Graceful error reporting in MCP format
Extending the Server
Adding New Commands
- Add command to
ALLOWED_COMMANDSinsrc/index.ts - Define tool schema in
getToolDefinitions() - Add case in
executeCommand()switch - Implement handler method
Example:
// 1. Add to ALLOWED_COMMANDS
const ALLOWED_COMMANDS = [
// ... existing commands
'custom_command'
] as const;
// 2. Add tool definition
tools.push({
name: 'custom_command',
description: 'My custom command',
inputSchema: {
type: 'object',
properties: {
param: { type: 'string' }
}
}
});
// 3. Add case in executeCommand
case 'custom_command':
return await this.customCommand(args);
// 4. Implement handler
private async customCommand(args: any): Promise<any> {
// Your implementation
return {
content: [{
type: 'text',
text: 'Result'
}]
};
}
Development
Scripts
npm run build- Build TypeScript to JavaScriptnpm run dev- Run in development mode with hot reloadnpm start- Run production buildnpm run clean- Clean build artifacts
Project Structure
supabase-lite-mcp/
āāā src/
ā āāā index.ts # Main server implementation
āāā dist/ # Compiled JavaScript (generated)
āāā .env # Environment variables (create from .env.example)
āāā .env.example # Environment template
āāā package.json # Node.js configuration
āāā tsconfig.json # TypeScript configuration
āāā setup.sh # Installation script
āāā README.md # Documentation
Comparison with Full Supabase MCP
| Feature | Full Supabase MCP | Supabase Lite MCP |
|---|---|---|
| Commands | 26 | 8 (essential only) |
| Token Usage | ~14,800 | ~3,700 |
| Startup Time | ~2s | <1s |
| Memory Usage | ~50MB | ~30MB |
| Focus | Complete platform | Database only |
Security
- š Never commit
.envfiles - š Use service role keys carefully (full database access)
- š Rotate keys regularly
- š Consider network isolation for production
Troubleshooting
Common Issues
Server won't start:
- Check Node.js version:
node --version(requires v22+) - Verify
.envfile exists with valid credentials - Run
npm run buildto compile TypeScript
Authentication errors:
- Ensure you're using the service role key, not anon key
- Check if the key has been regenerated in Supabase dashboard
Build errors:
- Run
npm installto install dependencies - Check TypeScript version:
npx tsc --version
License
MIT
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Acknowledgments
Built with:
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.