Skip to content

Commit 24602bf

Browse files
authored
fix: return success response from void operations (AI-164) (#168)
* 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 * refactor: return SUCCESS_RESPONSE in tool layer instead of platform layer - Keep Promise<void> return types in platform abstraction - Return SUCCESS_RESPONSE in tool execute functions - Affects: pauseProject, restoreProject, deleteBranch, mergeBranch, resetBranch, rebaseBranch, applyMigration, updateStorageConfig - Avoids need to update hosted/self-hosted remote MCP implementations Implements feedback from Matt's review on PR #168
1 parent d9d9f0e commit 24602bf

File tree

6 files changed

+37
-12
lines changed

6 files changed

+37
-12
lines changed

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

Lines changed: 3 additions & 2 deletions
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.
@@ -724,8 +727,6 @@ export function createSupabaseApiPlatform(
724727
);
725728

726729
assertSuccess(response, 'Failed to update storage config');
727-
728-
return response.data;
729730
},
730731
};
731732

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

Lines changed: 12 additions & 2 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(),
@@ -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<void>;
222229
listAllBuckets(projectId: string): Promise<StorageBucket[]>;
223230
};
224231

@@ -230,7 +237,10 @@ export type BranchingOperations = {
230237
): Promise<Branch>;
231238
deleteBranch(branchId: string): Promise<void>;
232239
mergeBranch(branchId: string): Promise<void>;
233-
resetBranch(branchId: string, options: ResetBranchOptions): Promise<void>;
240+
resetBranch(
241+
branchId: string,
242+
options: ResetBranchOptions
243+
): Promise<void>;
234244
rebaseBranch(branchId: string): Promise<void>;
235245
};
236246

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { type Cost, getBranchCost, getNextProjectCost } from '../pricing.js';
55
import { AWS_REGION_CODES } from '../regions.js';
66
import { hashObject } from '../util.js';
77

8+
const SUCCESS_RESPONSE = { success: true };
9+
810
export type AccountToolsOptions = {
911
account: AccountOperations;
1012
readOnly?: boolean;
@@ -187,7 +189,8 @@ export function getAccountTools({ account, readOnly }: AccountToolsOptions) {
187189
throw new Error('Cannot pause a project in read-only mode.');
188190
}
189191

190-
return await account.pauseProject(project_id);
192+
await account.pauseProject(project_id);
193+
return SUCCESS_RESPONSE;
191194
},
192195
}),
193196
restore_project: tool({
@@ -207,7 +210,8 @@ export function getAccountTools({ account, readOnly }: AccountToolsOptions) {
207210
throw new Error('Cannot restore a project in read-only mode.');
208211
}
209212

210-
return await account.restoreProject(project_id);
213+
await account.restoreProject(project_id);
214+
return SUCCESS_RESPONSE;
211215
},
212216
}),
213217
};

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { getBranchCost } from '../pricing.js';
55
import { hashObject } from '../util.js';
66
import { injectableTool } from './util.js';
77

8+
const SUCCESS_RESPONSE = { success: true };
9+
810
export type BranchingToolsOptions = {
911
branching: BranchingOperations;
1012
projectId?: string;
@@ -93,7 +95,8 @@ export function getBranchingTools({
9395
throw new Error('Cannot delete a branch in read-only mode.');
9496
}
9597

96-
return await branching.deleteBranch(branch_id);
98+
await branching.deleteBranch(branch_id);
99+
return SUCCESS_RESPONSE;
97100
},
98101
}),
99102
merge_branch: tool({
@@ -114,7 +117,8 @@ export function getBranchingTools({
114117
throw new Error('Cannot merge a branch in read-only mode.');
115118
}
116119

117-
return await branching.mergeBranch(branch_id);
120+
await branching.mergeBranch(branch_id);
121+
return SUCCESS_RESPONSE;
118122
},
119123
}),
120124
reset_branch: tool({
@@ -141,9 +145,10 @@ export function getBranchingTools({
141145
throw new Error('Cannot reset a branch in read-only mode.');
142146
}
143147

144-
return await branching.resetBranch(branch_id, {
148+
await branching.resetBranch(branch_id, {
145149
migration_version,
146150
});
151+
return SUCCESS_RESPONSE;
147152
},
148153
}),
149154
rebase_branch: tool({
@@ -164,7 +169,8 @@ export function getBranchingTools({
164169
throw new Error('Cannot rebase a branch in read-only mode.');
165170
}
166171

167-
return await branching.rebaseBranch(branch_id);
172+
await branching.rebaseBranch(branch_id);
173+
return SUCCESS_RESPONSE;
168174
},
169175
}),
170176
};

packages/mcp-server-supabase/src/tools/database-operation-tools.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
import type { DatabaseOperations } from '../platform/types.js';
99
import { injectableTool } from './util.js';
1010

11+
const SUCCESS_RESPONSE = { success: true };
12+
1113
export type DatabaseOperationToolsOptions = {
1214
database: DatabaseOperations;
1315
projectId?: string;
@@ -218,7 +220,7 @@ export function getDatabaseTools({
218220
query,
219221
});
220222

221-
return { success: true };
223+
return SUCCESS_RESPONSE;
222224
},
223225
}),
224226
execute_sql: injectableTool({

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { z } from 'zod';
22
import type { StorageOperations } from '../platform/types.js';
33
import { injectableTool } from './util.js';
44

5+
const SUCCESS_RESPONSE = { success: true };
6+
57
export type StorageToolsOptions = {
68
storage: StorageOperations;
79
projectId?: string;
@@ -76,7 +78,7 @@ export function getStorageTools({
7678
}
7779

7880
await storage.updateStorageConfig(project_id, config);
79-
return { success: true };
81+
return SUCCESS_RESPONSE;
8082
},
8183
}),
8284
};

0 commit comments

Comments
 (0)