Skip to content

Commit d63a33c

Browse files
committed
fix: return success response from void operations (AI-164)
- Add SuccessResponse type for operations that don't return data - Update all void operations to return { success: true } - Affected operations: pauseProject, restoreProject, deleteBranch, mergeBranch, resetBranch, rebaseBranch, applyMigration, updateStorageConfig - Prevents LLMs from thinking operations failed and attempting retries Fixes AI-164
1 parent c3e263c commit d63a33c

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
type DebuggingOperations,
3030
type DeployEdgeFunctionOptions,
3131
type DevelopmentOperations,
32+
type SuccessResponse,
3233
type EdgeFunction,
3334
type EdgeFunctionsOperations,
3435
type EdgeFunctionWithBody,
@@ -42,6 +43,8 @@ import {
4243

4344
const { version } = packageJson;
4445

46+
const SUCCESS_RESPONSE: SuccessResponse = { success: true };
47+
4548
export type SupabaseApiPlatformOptions = {
4649
/**
4750
* The access token for the Supabase Management API.
@@ -148,6 +151,8 @@ export function createSupabaseApiPlatform(
148151
);
149152

150153
assertSuccess(response, 'Failed to pause project');
154+
155+
return SUCCESS_RESPONSE;
151156
},
152157
async restoreProject(projectId: string) {
153158
const response = await managementApiClient.POST(
@@ -162,6 +167,8 @@ export function createSupabaseApiPlatform(
162167
);
163168

164169
assertSuccess(response, 'Failed to restore project');
170+
171+
return SUCCESS_RESPONSE;
165172
},
166173
};
167174

@@ -229,6 +236,7 @@ export function createSupabaseApiPlatform(
229236
// Intentionally don't return the result of the migration
230237
// to avoid prompt injection attacks. If the migration failed,
231238
// it will throw an error.
239+
return SUCCESS_RESPONSE;
232240
},
233241
};
234242

@@ -612,6 +620,8 @@ export function createSupabaseApiPlatform(
612620
);
613621

614622
assertSuccess(response, 'Failed to delete branch');
623+
624+
return SUCCESS_RESPONSE;
615625
},
616626
async mergeBranch(branchId: string) {
617627
const response = await managementApiClient.POST(
@@ -627,6 +637,8 @@ export function createSupabaseApiPlatform(
627637
);
628638

629639
assertSuccess(response, 'Failed to merge branch');
640+
641+
return SUCCESS_RESPONSE;
630642
},
631643
async resetBranch(branchId: string, options: ResetBranchOptions) {
632644
const { migration_version } = resetBranchOptionsSchema.parse(options);
@@ -646,6 +658,8 @@ export function createSupabaseApiPlatform(
646658
);
647659

648660
assertSuccess(response, 'Failed to reset branch');
661+
662+
return SUCCESS_RESPONSE;
649663
},
650664
async rebaseBranch(branchId: string) {
651665
const response = await managementApiClient.POST(
@@ -661,6 +675,8 @@ export function createSupabaseApiPlatform(
661675
);
662676

663677
assertSuccess(response, 'Failed to rebase branch');
678+
679+
return SUCCESS_RESPONSE;
664680
},
665681
};
666682

@@ -725,7 +741,7 @@ export function createSupabaseApiPlatform(
725741

726742
assertSuccess(response, 'Failed to update storage config');
727743

728-
return response.data;
744+
return SUCCESS_RESPONSE;
729745
},
730746
};
731747

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import type { InitData } from '@supabase/mcp-utils';
22
import { z } from 'zod';
33
import { AWS_REGION_CODES } from '../regions.js';
44

5+
export type SuccessResponse = {
6+
success: true;
7+
};
8+
59
export const storageBucketSchema = z.object({
610
id: z.string(),
711
name: z.string(),
@@ -177,7 +181,7 @@ export type DatabaseOperations = {
177181
applyMigration(
178182
projectId: string,
179183
options: ApplyMigrationOptions
180-
): Promise<void>;
184+
): Promise<SuccessResponse>;
181185
};
182186

183187
export type AccountOperations = {
@@ -186,8 +190,8 @@ export type AccountOperations = {
186190
listProjects(): Promise<Project[]>;
187191
getProject(projectId: string): Promise<Project>;
188192
createProject(options: CreateProjectOptions): Promise<Project>;
189-
pauseProject(projectId: string): Promise<void>;
190-
restoreProject(projectId: string): Promise<void>;
193+
pauseProject(projectId: string): Promise<SuccessResponse>;
194+
restoreProject(projectId: string): Promise<SuccessResponse>;
191195
};
192196

193197
export type EdgeFunctionsOperations = {
@@ -218,7 +222,10 @@ export type DevelopmentOperations = {
218222

219223
export type StorageOperations = {
220224
getStorageConfig(projectId: string): Promise<StorageConfig>;
221-
updateStorageConfig(projectId: string, config: StorageConfig): Promise<void>;
225+
updateStorageConfig(
226+
projectId: string,
227+
config: StorageConfig
228+
): Promise<SuccessResponse>;
222229
listAllBuckets(projectId: string): Promise<StorageBucket[]>;
223230
};
224231

@@ -228,10 +235,13 @@ export type BranchingOperations = {
228235
projectId: string,
229236
options: CreateBranchOptions
230237
): Promise<Branch>;
231-
deleteBranch(branchId: string): Promise<void>;
232-
mergeBranch(branchId: string): Promise<void>;
233-
resetBranch(branchId: string, options: ResetBranchOptions): Promise<void>;
234-
rebaseBranch(branchId: string): Promise<void>;
238+
deleteBranch(branchId: string): Promise<SuccessResponse>;
239+
mergeBranch(branchId: string): Promise<SuccessResponse>;
240+
resetBranch(
241+
branchId: string,
242+
options: ResetBranchOptions
243+
): Promise<SuccessResponse>;
244+
rebaseBranch(branchId: string): Promise<SuccessResponse>;
235245
};
236246

237247
export type SupabasePlatform = {

0 commit comments

Comments
 (0)