Skip to content

Commit becc794

Browse files
committed
feat: test feature groups
1 parent 148cf7f commit becc794

File tree

1 file changed

+159
-6
lines changed

1 file changed

+159
-6
lines changed

packages/mcp-server-supabase/src/server.test.ts

Lines changed: 159 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from '../test/mocks.js';
2525
import { createSupabaseApiPlatform } from './platform/api-platform.js';
2626
import { BRANCH_COST_HOURLY, PROJECT_COST_MONTHLY } from './pricing.js';
27-
import { createSupabaseMcpServer } from './server.js';
27+
import { createSupabaseMcpServer, type FeatureGroup } from './server.js';
2828

2929
beforeEach(async () => {
3030
mockOrgs.clear();
@@ -39,7 +39,7 @@ type SetupOptions = {
3939
accessToken?: string;
4040
projectId?: string;
4141
readOnly?: boolean;
42-
features?: string[];
42+
features?: FeatureGroup[];
4343
};
4444

4545
/**
@@ -497,7 +497,7 @@ describe('tools', () => {
497497
});
498498

499499
test('get project url', async () => {
500-
const { callTool } = await setup({ features: ['development'] });
500+
const { callTool } = await setup();
501501

502502
const org = await createOrganization({
503503
name: 'My Org',
@@ -522,7 +522,7 @@ describe('tools', () => {
522522
});
523523

524524
test('get anon key', async () => {
525-
const { callTool } = await setup({ features: ['development'] });
525+
const { callTool } = await setup();
526526
const org = await createOrganization({
527527
name: 'My Org',
528528
plan: 'free',
@@ -1568,7 +1568,7 @@ describe('tools', () => {
15681568

15691569
test('create branch', async () => {
15701570
const { callTool } = await setup({
1571-
features: ['account', 'branching', 'database'],
1571+
features: ['account', 'branching'],
15721572
});
15731573

15741574
const org = await createOrganization({
@@ -1652,7 +1652,7 @@ describe('tools', () => {
16521652

16531653
test('delete branch', async () => {
16541654
const { callTool } = await setup({
1655-
features: ['account', 'branching', 'database'],
1655+
features: ['account', 'branching'],
16561656
});
16571657

16581658
const org = await createOrganization({
@@ -2096,6 +2096,159 @@ describe('tools', () => {
20962096
});
20972097
});
20982098

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+
20992252
describe('project scoped tools', () => {
21002253
test('no account level tools should exist', async () => {
21012254
const org = await createOrganization({

0 commit comments

Comments
 (0)