You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add MCP elicitation for apply_migration tool
- Implemented user confirmation dialog for apply_migration using MCP elicitation protocol
- Added graceful fallback for clients that don't support elicitation
- Tests pass with fallback behavior in test environment
- Maintains backwards compatibility with all MCP clients
@@ -14,12 +15,14 @@ export type DatabaseOperationToolsOptions = {
14
15
database: DatabaseOperations;
15
16
projectId?: string;
16
17
readOnly?: boolean;
18
+
server?: Server;
17
19
};
18
20
19
21
exportfunctiongetDatabaseTools({
20
22
database,
21
23
projectId,
22
24
readOnly,
25
+
server,
23
26
}: DatabaseOperationToolsOptions){
24
27
constproject_id=projectId;
25
28
@@ -215,6 +218,47 @@ export function getDatabaseTools({
215
218
thrownewError('Cannot apply migration in read-only mode.');
216
219
}
217
220
221
+
// Try to request user confirmation via elicitation
222
+
if(server){
223
+
try{
224
+
constresult=(awaitserver.request(
225
+
{
226
+
method: 'elicitation/create',
227
+
params: {
228
+
message: `You are about to apply migration "${name}" to project ${project_id}. This will modify your database schema.\n\nPlease review the SQL:\n\n${query}\n\nDo you want to proceed?`,
229
+
requestedSchema: {
230
+
type: 'object',
231
+
properties: {
232
+
confirm: {
233
+
type: 'boolean',
234
+
title: 'Confirm Migration',
235
+
description: 'I have reviewed the SQL and approve this migration',
236
+
},
237
+
},
238
+
required: ['confirm'],
239
+
},
240
+
},
241
+
},
242
+
// @ts-ignore - elicitation types might not be available
0 commit comments