Skip to content

Commit fdc7950

Browse files
committed
format code
1 parent c492a40 commit fdc7950

File tree

6 files changed

+75
-42
lines changed

6 files changed

+75
-42
lines changed

packages/mcp-server-supabase/src/platform/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ export type GenerateTypescriptTypesResult = z.infer<
154154

155155
export type StorageConfigResponse = z.infer<typeof storageConfigResponseSchema>;
156156
export type StorageConfigUpdate = z.infer<typeof storageConfigResponseSchema>;
157-
export type StorageBucketResponse = z.infer<typeof v1StorageBucketResponseSchema>;
157+
export type StorageBucketResponse = z.infer<
158+
typeof v1StorageBucketResponseSchema
159+
>;
158160

159161
export type SupabasePlatform = {
160162
init?(info: InitData): Promise<void>;
@@ -212,6 +214,9 @@ export type SupabasePlatform = {
212214

213215
// Storage
214216
getStorageConfig(projectId: string): Promise<StorageConfigResponse>;
215-
updateStorageConfig(projectId: string, config: StorageConfigUpdate): Promise<void>;
217+
updateStorageConfig(
218+
projectId: string,
219+
config: StorageConfigUpdate
220+
): Promise<void>;
216221
listAllBuckets(projectId: string): Promise<StorageBucketResponse[]>;
217222
};

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -570,18 +570,22 @@ describe('tools', () => {
570570

571571
expect(Array.isArray(result)).toBe(true);
572572
expect(result.length).toBe(2);
573-
expect(result[0]).toEqual(expect.objectContaining({
574-
name: 'bucket1',
575-
public: true,
576-
created_at: expect.any(String),
577-
updated_at: expect.any(String),
578-
}));
579-
expect(result[1]).toEqual(expect.objectContaining({
580-
name: 'bucket2',
581-
public: false,
582-
created_at: expect.any(String),
583-
updated_at: expect.any(String),
584-
}));
573+
expect(result[0]).toEqual(
574+
expect.objectContaining({
575+
name: 'bucket1',
576+
public: true,
577+
created_at: expect.any(String),
578+
updated_at: expect.any(String),
579+
})
580+
);
581+
expect(result[1]).toEqual(
582+
expect.objectContaining({
583+
name: 'bucket2',
584+
public: false,
585+
created_at: expect.any(String),
586+
updated_at: expect.any(String),
587+
})
588+
);
585589
});
586590

587591
test('get storage config', async () => {

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ export type SupabaseMcpServerOptions = {
5656
features?: string[];
5757
};
5858

59-
export type FeatureGroup = 'account' | 'branching' | 'database' | 'debug' | 'development' | 'docs' | 'functions' | 'storage';
59+
export type FeatureGroup =
60+
| 'account'
61+
| 'branching'
62+
| 'database'
63+
| 'debug'
64+
| 'development'
65+
| 'docs'
66+
| 'functions'
67+
| 'storage';
6068

6169
// Single source of truth for valid feature values
6270
export const VALID_FEATURES: readonly FeatureGroup[] = [
@@ -67,11 +75,22 @@ export const VALID_FEATURES: readonly FeatureGroup[] = [
6775
'development',
6876
'docs',
6977
'functions',
70-
'storage'
78+
'storage',
7179
] as const;
7280

73-
const DEFAULT_ACCOUNT_FEATURES: FeatureGroup[] = ['account', 'database', 'debug', 'docs', 'functions'];
74-
const DEFAULT_PROJECT_FEATURES: FeatureGroup[] = ['database', 'debug', 'docs', 'functions'];
81+
const DEFAULT_ACCOUNT_FEATURES: FeatureGroup[] = [
82+
'account',
83+
'database',
84+
'debug',
85+
'docs',
86+
'functions',
87+
];
88+
const DEFAULT_PROJECT_FEATURES: FeatureGroup[] = [
89+
'database',
90+
'debug',
91+
'docs',
92+
'functions',
93+
];
7594

7695
/**
7796
* Creates an MCP server for interacting with Supabase.
@@ -91,15 +110,17 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
91110

92111
if (features && features.length > 0) {
93112
// Use explicitly provided features
94-
features.forEach(feature => {
113+
features.forEach((feature) => {
95114
if (VALID_FEATURES.includes(feature as FeatureGroup)) {
96115
enabledFeatures.add(feature as FeatureGroup);
97116
}
98117
});
99118
} else {
100119
// Use defaults based on mode
101-
const defaultFeatures = projectId ? DEFAULT_PROJECT_FEATURES : DEFAULT_ACCOUNT_FEATURES;
102-
defaultFeatures.forEach(feature => enabledFeatures.add(feature));
120+
const defaultFeatures = projectId
121+
? DEFAULT_PROJECT_FEATURES
122+
: DEFAULT_ACCOUNT_FEATURES;
123+
defaultFeatures.forEach((feature) => enabledFeatures.add(feature));
103124
}
104125

105126
const server = createMcpServer({
@@ -124,7 +145,10 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
124145
}
125146

126147
if (enabledFeatures.has('database')) {
127-
Object.assign(tools, getDatabaseOperationTools({ platform, projectId, readOnly }));
148+
Object.assign(
149+
tools,
150+
getDatabaseOperationTools({ platform, projectId, readOnly })
151+
);
128152
}
129153

130154
if (enabledFeatures.has('debug')) {

packages/mcp-server-supabase/src/tools/account-tools.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export type AccountToolsOptions = {
99
platform: SupabasePlatform;
1010
};
1111

12-
export function getAccountTools({
13-
platform,
14-
}: AccountToolsOptions) {
12+
export function getAccountTools({ platform }: AccountToolsOptions) {
1513
return {
1614
list_organizations: tool({
1715
description: 'Lists all organizations that the user is a member of.',

packages/mcp-server-supabase/src/tools/storage-tools.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ export type StorageToolsOptions = {
77
projectId?: string;
88
};
99

10-
export function getStorageTools({
11-
platform,
12-
projectId,
13-
}: StorageToolsOptions) {
10+
export function getStorageTools({ platform, projectId }: StorageToolsOptions) {
1411
const project_id = projectId;
1512

1613
return {
@@ -44,7 +41,7 @@ export function getStorageTools({
4441
imageTransformation: z.object({ enabled: z.boolean() }),
4542
s3Protocol: z.object({ enabled: z.boolean() }),
4643
}),
47-
})
44+
}),
4845
}),
4946
inject: { project_id },
5047
execute: async ({ project_id, config }) => {

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -806,18 +806,20 @@ export const mockManagementApi = [
806806
);
807807
}
808808

809-
const buckets = Array.from(project.storage_buckets.values()).map(bucket => ({
810-
id: bucket.id,
811-
name: bucket.name,
812-
public: bucket.public,
813-
created_at: bucket.created_at.toISOString(),
814-
updated_at: bucket.updated_at.toISOString(),
815-
}));
809+
const buckets = Array.from(project.storage_buckets.values()).map(
810+
(bucket) => ({
811+
id: bucket.id,
812+
name: bucket.name,
813+
public: bucket.public,
814+
created_at: bucket.created_at.toISOString(),
815+
updated_at: bucket.updated_at.toISOString(),
816+
})
817+
);
816818

817819
return HttpResponse.json(buckets);
818820
}
819821
),
820-
822+
821823
/**
822824
* Get storage config
823825
*/
@@ -837,11 +839,11 @@ export const mockManagementApi = [
837839
features: {
838840
imageTransformation: { enabled: true },
839841
s3Protocol: { enabled: false },
840-
}
842+
},
841843
});
842844
}
843845
),
844-
846+
845847
/**
846848
* Update storage config
847849
*/
@@ -867,7 +869,7 @@ export const mockManagementApi = [
867869
);
868870
}
869871
}
870-
)
872+
),
871873
];
872874

873875
export async function createOrganization(options: MockOrganizationOptions) {
@@ -1177,7 +1179,10 @@ export class MockProject {
11771179
}
11781180
}
11791181

1180-
createStorageBucket(name: string, isPublic: boolean = false): MockStorageBucket {
1182+
createStorageBucket(
1183+
name: string,
1184+
isPublic: boolean = false
1185+
): MockStorageBucket {
11811186
const id = nanoid();
11821187
const bucket: MockStorageBucket = {
11831188
id,

0 commit comments

Comments
 (0)