A simple demo showing how to use the AI SDK with Supabase MCP (Model Context Protocol) to query your database using natural language.
-
Copy the
.env.examplefile to.envand fill in your values -
Install dependencies:
npm install- Run the app:
npm run dev- Connects to Supabase using MCP server
- Uses Google's Gemini 2.0 Flash model to process queries
- Executes SQL queries through natural language
- Formats and displays results
The app queries the user_invoice table for records where invoice_amount is less than 50 dollars. You can modify the prompt in index.ts to ask different questions.
The project includes a provider system (provider.ts) that supports multiple AI models:
- Google: Gemini models
- OpenAI: GPT models
- Anthropic: Claude models
You can switch between providers by modifying the model selection in index.ts.
ai: AI SDK for model interactions@ai-sdk/google: Google AI model integration@ai-sdk/openai: OpenAI model integration@ai-sdk/anthropic: Anthropic model integrationdotenv: Environment variablestsx: TypeScript execution