File tree 2 files changed +48
-0
lines changed
packages/mcp-server-supabase/src
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,12 @@ import columnsSql from './columns.sql';
3
3
import extensionsSql from './extensions.sql' ;
4
4
import tablesSql from './tables.sql' ;
5
5
6
+ export const DEFAULT_SYSTEM_SCHEMAS = [
7
+ 'information_schema' ,
8
+ 'pg_catalog' ,
9
+ 'pg_toast' ,
10
+ ] ;
11
+
6
12
/**
7
13
* Generates the SQL query to list tables in the database.
8
14
*/
@@ -19,6 +25,8 @@ export function listTablesSql(schemas: string[] = []) {
19
25
20
26
if ( schemas . length > 0 ) {
21
27
sql += ` where schema in (${ schemas . map ( ( s ) => `'${ s } '` ) . join ( ',' ) } )` ;
28
+ } else {
29
+ sql += ` where schema not in (${ DEFAULT_SYSTEM_SCHEMAS . map ( ( s ) => `'${ s } '` ) . join ( ',' ) } )` ;
22
30
}
23
31
24
32
return sql ;
Original file line number Diff line number Diff line change @@ -705,6 +705,46 @@ describe('tools', () => {
705
705
) ;
706
706
} ) ;
707
707
708
+ test ( 'listing all tables excludes system schemas' , async ( ) => {
709
+ const { callTool } = await setup ( ) ;
710
+
711
+ const org = await createOrganization ( {
712
+ name : 'My Org' ,
713
+ plan : 'free' ,
714
+ allowed_release_channels : [ 'ga' ] ,
715
+ } ) ;
716
+
717
+ const project = await createProject ( {
718
+ name : 'Project 1' ,
719
+ region : 'us-east-1' ,
720
+ organization_id : org . id ,
721
+ } ) ;
722
+ project . status = 'ACTIVE_HEALTHY' ;
723
+
724
+ const result = await callTool ( {
725
+ name : 'list_tables' ,
726
+ arguments : {
727
+ project_id : project . id ,
728
+ } ,
729
+ } ) ;
730
+
731
+ expect ( result ) . not . toEqual (
732
+ expect . arrayContaining ( [
733
+ expect . objectContaining ( { schema : 'pg_catalog' } ) ,
734
+ ] )
735
+ ) ;
736
+
737
+ expect ( result ) . not . toEqual (
738
+ expect . arrayContaining ( [
739
+ expect . objectContaining ( { schema : 'information_schema' } ) ,
740
+ ] )
741
+ ) ;
742
+
743
+ expect ( result ) . not . toEqual (
744
+ expect . arrayContaining ( [ expect . objectContaining ( { schema : 'pg_toast' } ) ] )
745
+ ) ;
746
+ } ) ;
747
+
708
748
test ( 'list extensions' , async ( ) => {
709
749
const { callTool } = await setup ( ) ;
710
750
You can’t perform that action at this time.
0 commit comments