UNPKG

@rip-user/rls-debugger-mcp

Version:

AI-powered MCP server for debugging Supabase Row Level Security policies with Claude structured outputs

23 lines 1.75 kB
import { SupabaseClient } from '@supabase/supabase-js'; import { RLSPolicy } from './types.js'; /** * SQL query to fetch all RLS policies from PostgreSQL system tables */ export declare const GET_ALL_RLS_POLICIES = "\n SELECT\n nsp.nspname AS schemaname,\n rel.relname AS tablename,\n pol.polname AS policyname,\n CASE pol.polpermissive\n WHEN true THEN 'PERMISSIVE'\n WHEN false THEN 'RESTRICTIVE'\n END AS polpermissive,\n CASE\n WHEN cardinality(pol.polroles) > 0 THEN pg_get_userbyid(pol.polroles[1])\n ELSE 'public'\n END AS policyrole,\n CASE pol.polcmd\n WHEN '*' THEN 'ALL'\n WHEN 'r' THEN 'SELECT'\n WHEN 'a' THEN 'INSERT'\n WHEN 'w' THEN 'UPDATE'\n WHEN 'd' THEN 'DELETE'\n END AS polcmd,\n pg_get_expr(pol.polqual, pol.polrelid) AS policyqual,\n pg_get_expr(pol.polwithcheck, pol.polrelid) AS policywithcheck\n FROM pg_catalog.pg_policy pol\n JOIN pg_catalog.pg_class rel ON pol.polrelid = rel.oid\n JOIN pg_catalog.pg_namespace nsp ON rel.relnamespace = nsp.oid\n WHERE nsp.nspname = 'public'\n ORDER BY rel.relname, pol.polname;\n"; /** * SQL query to get policies for a specific table */ export declare function getTablePoliciesQuery(tableName: string): string; /** * Fetch all RLS policies from Supabase */ export declare function fetchAllPolicies(supabase: SupabaseClient): Promise<RLSPolicy[]>; /** * Fetch policies for a specific table */ export declare function fetchTablePolicies(supabase: SupabaseClient, tableName: string): Promise<RLSPolicy[]>; /** * Check if a table has RLS enabled */ export declare function isRLSEnabled(supabase: SupabaseClient, tableName: string): Promise<boolean>; //# sourceMappingURL=rls-queries.d.ts.map