@@ -24,7 +24,7 @@ import {
24
24
} from '../test/mocks.js' ;
25
25
import { createSupabaseApiPlatform } from './platform/api-platform.js' ;
26
26
import { BRANCH_COST_HOURLY , PROJECT_COST_MONTHLY } from './pricing.js' ;
27
- import { createSupabaseMcpServer } from './server.js' ;
27
+ import { createSupabaseMcpServer , type FeatureGroup } from './server.js' ;
28
28
29
29
beforeEach ( async ( ) => {
30
30
mockOrgs . clear ( ) ;
@@ -39,7 +39,7 @@ type SetupOptions = {
39
39
accessToken ?: string ;
40
40
projectId ?: string ;
41
41
readOnly ?: boolean ;
42
- features ?: string [ ] ;
42
+ features ?: FeatureGroup [ ] ;
43
43
} ;
44
44
45
45
/**
@@ -497,7 +497,7 @@ describe('tools', () => {
497
497
} ) ;
498
498
499
499
test ( 'get project url' , async ( ) => {
500
- const { callTool } = await setup ( { features : [ 'development' ] } ) ;
500
+ const { callTool } = await setup ( ) ;
501
501
502
502
const org = await createOrganization ( {
503
503
name : 'My Org' ,
@@ -522,7 +522,7 @@ describe('tools', () => {
522
522
} ) ;
523
523
524
524
test ( 'get anon key' , async ( ) => {
525
- const { callTool } = await setup ( { features : [ 'development' ] } ) ;
525
+ const { callTool } = await setup ( ) ;
526
526
const org = await createOrganization ( {
527
527
name : 'My Org' ,
528
528
plan : 'free' ,
@@ -1568,7 +1568,7 @@ describe('tools', () => {
1568
1568
1569
1569
test ( 'create branch' , async ( ) => {
1570
1570
const { callTool } = await setup ( {
1571
- features : [ 'account' , 'branching' , 'database' ] ,
1571
+ features : [ 'account' , 'branching' ] ,
1572
1572
} ) ;
1573
1573
1574
1574
const org = await createOrganization ( {
@@ -1652,7 +1652,7 @@ describe('tools', () => {
1652
1652
1653
1653
test ( 'delete branch' , async ( ) => {
1654
1654
const { callTool } = await setup ( {
1655
- features : [ 'account' , 'branching' , 'database' ] ,
1655
+ features : [ 'account' , 'branching' ] ,
1656
1656
} ) ;
1657
1657
1658
1658
const org = await createOrganization ( {
@@ -2096,6 +2096,159 @@ describe('tools', () => {
2096
2096
} ) ;
2097
2097
} ) ;
2098
2098
2099
+ describe ( 'feature groups' , ( ) => {
2100
+ test ( 'account tools' , async ( ) => {
2101
+ const { client : accountClient } = await setup ( {
2102
+ features : [ 'account' ] ,
2103
+ } ) ;
2104
+
2105
+ const { tools : accountTools } = await accountClient . listTools ( ) ;
2106
+ const accountToolNames = accountTools . map ( ( tool ) => tool . name ) ;
2107
+
2108
+ expect ( accountToolNames ) . toEqual ( [
2109
+ 'list_organizations' ,
2110
+ 'get_organization' ,
2111
+ 'list_projects' ,
2112
+ 'get_project' ,
2113
+ 'get_cost' ,
2114
+ 'confirm_cost' ,
2115
+ 'create_project' ,
2116
+ 'pause_project' ,
2117
+ 'restore_project' ,
2118
+ ] ) ;
2119
+ } ) ;
2120
+
2121
+ test ( 'database tools' , async ( ) => {
2122
+ const { client : databaseClient } = await setup ( {
2123
+ features : [ 'database' ] ,
2124
+ } ) ;
2125
+
2126
+ const { tools : databaseTools } = await databaseClient . listTools ( ) ;
2127
+ const databaseToolNames = databaseTools . map ( ( tool ) => tool . name ) ;
2128
+
2129
+ expect ( databaseToolNames ) . toEqual ( [
2130
+ 'list_tables' ,
2131
+ 'list_extensions' ,
2132
+ 'list_migrations' ,
2133
+ 'apply_migration' ,
2134
+ 'execute_sql' ,
2135
+ ] ) ;
2136
+ } ) ;
2137
+
2138
+ test ( 'debug tools' , async ( ) => {
2139
+ const { client : debugClient } = await setup ( {
2140
+ features : [ 'debug' ] ,
2141
+ } ) ;
2142
+
2143
+ const { tools : debugTools } = await debugClient . listTools ( ) ;
2144
+ const debugToolNames = debugTools . map ( ( tool ) => tool . name ) ;
2145
+
2146
+ expect ( debugToolNames ) . toEqual ( [ 'get_logs' , 'get_advisors' ] ) ;
2147
+ } ) ;
2148
+
2149
+ test ( 'development tools' , async ( ) => {
2150
+ const { client : developmentClient } = await setup ( {
2151
+ features : [ 'development' ] ,
2152
+ } ) ;
2153
+
2154
+ const { tools : developmentTools } = await developmentClient . listTools ( ) ;
2155
+ const developmentToolNames = developmentTools . map ( ( tool ) => tool . name ) ;
2156
+
2157
+ expect ( developmentToolNames ) . toEqual ( [
2158
+ 'get_project_url' ,
2159
+ 'get_anon_key' ,
2160
+ 'generate_typescript_types' ,
2161
+ ] ) ;
2162
+ } ) ;
2163
+
2164
+ test ( 'docs tools' , async ( ) => {
2165
+ const { client : docsClient } = await setup ( {
2166
+ features : [ 'docs' ] ,
2167
+ } ) ;
2168
+
2169
+ const { tools : docsTools } = await docsClient . listTools ( ) ;
2170
+ const docsToolNames = docsTools . map ( ( tool ) => tool . name ) ;
2171
+
2172
+ expect ( docsToolNames ) . toEqual ( [ 'search_docs' ] ) ;
2173
+ } ) ;
2174
+
2175
+ test ( 'functions tools' , async ( ) => {
2176
+ const { client : functionsClient } = await setup ( {
2177
+ features : [ 'functions' ] ,
2178
+ } ) ;
2179
+
2180
+ const { tools : functionsTools } = await functionsClient . listTools ( ) ;
2181
+ const functionsToolNames = functionsTools . map ( ( tool ) => tool . name ) ;
2182
+
2183
+ expect ( functionsToolNames ) . toEqual ( [
2184
+ 'list_edge_functions' ,
2185
+ 'deploy_edge_function' ,
2186
+ ] ) ;
2187
+ } ) ;
2188
+
2189
+ test ( 'branching tools' , async ( ) => {
2190
+ const { client : branchingClient } = await setup ( {
2191
+ features : [ 'branching' ] ,
2192
+ } ) ;
2193
+
2194
+ const { tools : branchingTools } = await branchingClient . listTools ( ) ;
2195
+ const branchingToolNames = branchingTools . map ( ( tool ) => tool . name ) ;
2196
+
2197
+ expect ( branchingToolNames ) . toEqual ( [
2198
+ 'create_branch' ,
2199
+ 'list_branches' ,
2200
+ 'delete_branch' ,
2201
+ 'merge_branch' ,
2202
+ 'reset_branch' ,
2203
+ 'rebase_branch' ,
2204
+ ] ) ;
2205
+ } ) ;
2206
+
2207
+ test ( 'storage tools' , async ( ) => {
2208
+ const { client : storageClient } = await setup ( {
2209
+ features : [ 'storage' ] ,
2210
+ } ) ;
2211
+
2212
+ const { tools : storageTools } = await storageClient . listTools ( ) ;
2213
+ const storageToolNames = storageTools . map ( ( tool ) => tool . name ) ;
2214
+
2215
+ expect ( storageToolNames ) . toEqual ( [
2216
+ 'list_storage_buckets' ,
2217
+ 'get_storage_config' ,
2218
+ 'update_storage_config' ,
2219
+ ] ) ;
2220
+ } ) ;
2221
+
2222
+ test ( 'invalid group fails' , async ( ) => {
2223
+ const setupPromise = setup ( {
2224
+ features : [ 'my-invalid-group' as FeatureGroup ] ,
2225
+ } ) ;
2226
+
2227
+ await expect ( setupPromise ) . rejects . toThrow ( 'Invalid enum value' ) ;
2228
+ } ) ;
2229
+
2230
+ test ( 'duplicate group behaves like single group' , async ( ) => {
2231
+ const { client : duplicateClient } = await setup ( {
2232
+ features : [ 'account' , 'account' ] ,
2233
+ } ) ;
2234
+
2235
+ const { tools : duplicateTools } = await duplicateClient . listTools ( ) ;
2236
+ const duplicateToolNames = duplicateTools . map ( ( tool ) => tool . name ) ;
2237
+
2238
+ expect ( duplicateToolNames ) . toEqual ( [
2239
+ 'list_organizations' ,
2240
+ 'get_organization' ,
2241
+ 'list_projects' ,
2242
+ 'get_project' ,
2243
+ 'get_cost' ,
2244
+ 'confirm_cost' ,
2245
+ 'create_project' ,
2246
+ 'pause_project' ,
2247
+ 'restore_project' ,
2248
+ ] ) ;
2249
+ } ) ;
2250
+ } ) ;
2251
+
2099
2252
describe ( 'project scoped tools' , ( ) => {
2100
2253
test ( 'no account level tools should exist' , async ( ) => {
2101
2254
const org = await createOrganization ( {
0 commit comments