@@ -267,7 +267,7 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
267
267
name,
268
268
query,
269
269
} ,
270
- } as any // TODO: remove once API spec updated to include body
270
+ }
271
271
) ;
272
272
273
273
assertSuccess ( response , 'Failed to apply migration' ) ;
@@ -345,6 +345,153 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
345
345
346
346
assertSuccess ( response , 'Failed to fetch TypeScript types' ) ;
347
347
348
+ return response . data ;
349
+ } ,
350
+ } ) ,
351
+ // Experimental features
352
+ create_branch : tool ( {
353
+ description :
354
+ 'Creates a development branch with migrations from production project.' ,
355
+ parameters : z . object ( {
356
+ project_id : z . string ( ) ,
357
+ name : z
358
+ . string ( )
359
+ . default ( 'develop' )
360
+ . describe ( 'Name of the branch to create' ) ,
361
+ } ) ,
362
+ execute : async ( { project_id, name } ) => {
363
+ const response = await managementApiClient . POST (
364
+ '/v1/projects/{ref}/branches' ,
365
+ {
366
+ params : {
367
+ path : {
368
+ ref : project_id ,
369
+ } ,
370
+ } ,
371
+ body : {
372
+ branch_name : name ,
373
+ } ,
374
+ }
375
+ ) ;
376
+
377
+ assertSuccess ( response , 'Failed to create branch' ) ;
378
+
379
+ return response . data ;
380
+ } ,
381
+ } ) ,
382
+ list_branches : tool ( {
383
+ description : 'Lists all development branches.' ,
384
+ parameters : z . object ( {
385
+ project_id : z . string ( ) ,
386
+ } ) ,
387
+ execute : async ( { project_id } ) => {
388
+ const response = await managementApiClient . GET (
389
+ '/v1/projects/{ref}/branches' ,
390
+ {
391
+ params : {
392
+ path : {
393
+ ref : project_id ,
394
+ } ,
395
+ } ,
396
+ }
397
+ ) ;
398
+
399
+ assertSuccess ( response , 'Failed to list branches' ) ;
400
+
401
+ return response . data ;
402
+ } ,
403
+ } ) ,
404
+ delete_branch : tool ( {
405
+ description : 'Deletes a development branch.' ,
406
+ parameters : z . object ( {
407
+ branch_id : z . string ( ) ,
408
+ } ) ,
409
+ execute : async ( { branch_id } ) => {
410
+ const response = await managementApiClient . DELETE (
411
+ '/v1/branches/{branch_id}' ,
412
+ {
413
+ params : {
414
+ path : {
415
+ branch_id,
416
+ } ,
417
+ } ,
418
+ }
419
+ ) ;
420
+
421
+ assertSuccess ( response , 'Failed to delete branch' ) ;
422
+
423
+ return response . data ;
424
+ } ,
425
+ } ) ,
426
+ merge_branch : tool ( {
427
+ description :
428
+ 'Merges migrations and edge functions from a development branch to production.' ,
429
+ parameters : z . object ( {
430
+ branch_id : z . string ( ) ,
431
+ } ) ,
432
+ execute : async ( { branch_id } ) => {
433
+ const response = await managementApiClient . POST (
434
+ '/v1/branches/{branch_id}/merge' ,
435
+ {
436
+ params : {
437
+ path : {
438
+ branch_id,
439
+ } ,
440
+ } ,
441
+ body : { } ,
442
+ }
443
+ ) ;
444
+
445
+ assertSuccess ( response , 'Failed to merge branch' ) ;
446
+
447
+ return response . data ;
448
+ } ,
449
+ } ) ,
450
+ reset_branch : tool ( {
451
+ description :
452
+ 'Resets migrations on a development branch to a prior version.' ,
453
+ parameters : z . object ( {
454
+ branch_id : z . string ( ) ,
455
+ } ) ,
456
+ execute : async ( { branch_id } ) => {
457
+ const response = await managementApiClient . POST (
458
+ '/v1/branches/{branch_id}/reset' ,
459
+ {
460
+ params : {
461
+ path : {
462
+ branch_id,
463
+ } ,
464
+ } ,
465
+ body : { } ,
466
+ }
467
+ ) ;
468
+
469
+ assertSuccess ( response , 'Failed to reset branch' ) ;
470
+
471
+ return response . data ;
472
+ } ,
473
+ } ) ,
474
+ rebase_branch : tool ( {
475
+ description :
476
+ 'Rebases development branch back on production in case it drifted.' ,
477
+ parameters : z . object ( {
478
+ branchId : z . string ( ) ,
479
+ } ) ,
480
+ execute : async ( { branchId } ) => {
481
+ const response = await managementApiClient . POST (
482
+ '/v1/branches/{branch_id}/push' ,
483
+ {
484
+ params : {
485
+ path : {
486
+ branch_id : branchId ,
487
+ } ,
488
+ } ,
489
+ body : { } ,
490
+ }
491
+ ) ;
492
+
493
+ assertSuccess ( response , 'Failed to rebase branch' ) ;
494
+
348
495
return response . data ;
349
496
} ,
350
497
} ) ,
0 commit comments