• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase-community / supabase-mcp / 16727694595

04 Aug 2025 03:41PM UTC coverage: 96.357% (+0.03%) from 96.328%
16727694595

push

github

web-flow
Merge pull request #119 from supabase-community/charis/user-agent

fix: add user-agent string to content api requests

225 of 244 branches covered (92.21%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 3 files covered. (100.0%)

2076 of 2144 relevant lines covered (96.83%)

34.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.12
/packages/mcp-server-supabase/src/tools/branching-tools.ts
1
import { tool } from '@supabase/mcp-utils';
2✔
2
import { z } from 'zod';
3
import type { SupabasePlatform } from '../platform/types.js';
4
import { getBranchCost } from '../pricing.js';
5
import { hashObject } from '../util.js';
6
import { injectableTool } from './util.js';
7

8
export type BranchingToolsOptions = {
9
  platform: SupabasePlatform;
10
  projectId?: string;
11
};
12

13
export function getBranchingTools({
2✔
14
  platform,
107✔
15
  projectId,
107✔
16
}: BranchingToolsOptions) {
107✔
17
  const project_id = projectId;
107✔
18

19
  return {
107✔
20
    create_branch: injectableTool({
107✔
21
      description:
107✔
22
        'Creates a development branch on a Supabase project. This will apply all migrations from the main project to a fresh branch database. Note that production data will not carry over. The branch will get its own project_id via the resulting project_ref. Use this ID to execute queries and migrations on the branch.',
107✔
23
      parameters: z.object({
107✔
24
        project_id: z.string(),
107✔
25
        name: z
107✔
26
          .string()
107✔
27
          .default('develop')
107✔
28
          .describe('Name of the branch to create'),
107✔
29
        confirm_cost_id: z
107✔
30
          .string({
107✔
31
            required_error:
107✔
32
              'User must confirm understanding of costs before creating a branch.',
107✔
33
          })
107✔
34
          .describe('The cost confirmation ID. Call `confirm_cost` first.'),
107✔
35
      }),
107✔
36
      inject: { project_id },
107✔
37
      execute: async ({ project_id, name, confirm_cost_id }) => {
107✔
38
        const cost = getBranchCost();
6✔
39
        const costHash = await hashObject(cost);
6✔
40
        if (costHash !== confirm_cost_id) {
6✔
41
          throw new Error(
×
42
            'Cost confirmation ID does not match the expected cost of creating a branch.'
×
43
          );
×
44
        }
×
45
        return await platform.createBranch(project_id, { name });
6✔
46
      },
6✔
47
    }),
107✔
48
    list_branches: injectableTool({
107✔
49
      description:
107✔
50
        'Lists all development branches of a Supabase project. This will return branch details including status which you can use to check when operations like merge/rebase/reset complete.',
107✔
51
      parameters: z.object({
107✔
52
        project_id: z.string(),
107✔
53
      }),
107✔
54
      inject: { project_id },
107✔
55
      execute: async ({ project_id }) => {
107✔
56
        return await platform.listBranches(project_id);
3✔
57
      },
3✔
58
    }),
107✔
59
    delete_branch: tool({
107✔
60
      description: 'Deletes a development branch.',
107✔
61
      parameters: z.object({
107✔
62
        branch_id: z.string(),
107✔
63
      }),
107✔
64
      execute: async ({ branch_id }) => {
107✔
65
        return await platform.deleteBranch(branch_id);
2✔
66
      },
2✔
67
    }),
107✔
68
    merge_branch: tool({
107✔
69
      description:
107✔
70
        'Merges migrations and edge functions from a development branch to production.',
107✔
71
      parameters: z.object({
107✔
72
        branch_id: z.string(),
107✔
73
      }),
107✔
74
      execute: async ({ branch_id }) => {
107✔
75
        return await platform.mergeBranch(branch_id);
1✔
76
      },
1✔
77
    }),
107✔
78
    reset_branch: tool({
107✔
79
      description:
107✔
80
        'Resets migrations of a development branch. Any untracked data or schema changes will be lost.',
107✔
81
      parameters: z.object({
107✔
82
        branch_id: z.string(),
107✔
83
        migration_version: z
107✔
84
          .string()
107✔
85
          .optional()
107✔
86
          .describe(
107✔
87
            'Reset your development branch to a specific migration version.'
107✔
88
          ),
107✔
89
      }),
107✔
90
      execute: async ({ branch_id, migration_version }) => {
107✔
91
        return await platform.resetBranch(branch_id, {
2✔
92
          migration_version,
2✔
93
        });
2✔
94
      },
2✔
95
    }),
107✔
96
    rebase_branch: tool({
107✔
97
      description:
107✔
98
        'Rebases a development branch on production. This will effectively run any newer migrations from production onto this branch to help handle migration drift.',
107✔
99
      parameters: z.object({
107✔
100
        branch_id: z.string(),
107✔
101
      }),
107✔
102
      execute: async ({ branch_id }) => {
107✔
103
        return await platform.rebaseBranch(branch_id);
1✔
104
      },
1✔
105
    }),
107✔
106
  };
107✔
107
}
107✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc