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:
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。