@tpmjs/tools-supabase
Delete rows from a Supabase table matching a PostgREST filter condition.
Test @tpmjs/tools-supabase (deleteRows) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-supabasepnpm add @tpmjs/tools-supabaseyarn add @tpmjs/tools-supabasebun add @tpmjs/tools-supabasedeno add npm:@tpmjs/tools-supabaseimport { deleteRows } from '@tpmjs/tools-supabase';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { deleteRows } from '@tpmjs/tools-supabase';
const result = await generateText({
model: openai('gpt-4o'),
tools: { deleteRows },
prompt: 'Your prompt here...',
});
console.log(result.text);(table: string, filter: string, returning?: string) => Promise<unknown>Available configuration options
tablestringThe table name to delete from.
filterstringPostgREST filter string (REQUIRED, must be non-empty). Example: "id=eq.123".
returningstringColumns to return from deleted rows (default: "*").
Schema extracted: 2/28/2026, 3:59:25 AM
Supabase REST API tools for AI agents. Query, insert, update, delete rows, call RPC functions, and more using the PostgREST API.
npm install @tpmjs/tools-supabase
Set these environment variables:
SUPABASE_URL="https://your-project.supabase.co" SUPABASE_SERVICE_ROLE_KEY="your-service-role-key"
The service role key bypasses Row Level Security (RLS) and grants full database access to AI agents.
import { generateText } from 'ai'; import { openai } from '@ai-sdk/openai'; import { queryRows, insertRows } from '@tpmjs/tools-supabase'; const result = await generateText({ model: openai('gpt-4o'), prompt: 'Get the first 5 users from the database', tools: { queryRows, insertRows }, });
import { queryRows } from '@tpmjs/tools-supabase'; // Query with filtering and ordering await queryRows.execute({ table: 'users', select: 'id,name,email', filter: 'age=gte.18&status=eq.active', order: 'created_at.desc', limit: 10, });
import { insertRows } from '@tpmjs/tools-supabase'; // Insert a single row await insertRows.execute({ table: 'users', rows: [{ name: 'Alice', email: 'alice@example.com' }], }); // Bulk insert await insertRows.execute({ table: 'users', rows: [ { name: 'Bob', email: 'bob@example.com' }, { name: 'Carol', email: 'carol@example.com' }, ], });
| Tool | Description |
|---|---|
queryRows | Query rows from a table with filtering, ordering, and pagination |
getRowById | Get a single row by its primary key value |
insertRows | Insert one or more rows into a table |
updateRows | Update rows matching a filter condition |
deleteRows | Delete rows matching a filter condition |
upsertRows | Insert or update rows using merge-duplicates strategy |
callRpc | Call a PostgreSQL function (RPC) with parameters |
countRows | Count rows in a table with optional filtering |
listTables | List all available tables in the database |
searchRows | Search rows using case-insensitive pattern matching |
Supabase uses PostgREST filter syntax for queries:
status=eq.activeage=gt.18age=gte.18price=lt.100name=like.*smith*email=ilike.*@gmail.comage=gte.18&status=eq.active (AND)See PostgREST documentation for more operators.
Important: The updateRows and deleteRows tools require a non-empty filter to prevent accidental full-table operations. This is a safety requirement to protect your data.
// ❌ This will throw an error await deleteRows.execute({ table: 'users', filter: '' }); // ✅ This is safe await deleteRows.execute({ table: 'users', filter: 'id=eq.123' });
MIT
Downloads/month
46
GitHub Stars
15
Quality Score