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
return'Gets the cost of creating a new project or branch and requests user confirmation. Returns a unique ID for this confirmation which must be passed to `create_project` or `create_branch`. Never assume organization as costs can be different for each.';
91
+
}
92
+
return'Gets the cost of creating a new project or branch. You must repeat the cost to the user and confirm their understanding before calling `create_project` or `create_branch`. Returns a unique ID for this confirmation which must be passed to `create_project` or `create_branch`. Never assume organization as costs can be different for each.';
93
+
},
88
94
annotations: {
89
-
title: 'Get cost of new resources',
95
+
title: 'Get and confirm cost',
90
96
readOnlyHint: true,
91
97
destructiveHint: false,
92
98
idempotentHint: true,
@@ -96,49 +102,94 @@ export function getAccountTools({
96
102
type: z.enum(['project','branch']),
97
103
organization_id: z
98
104
.string()
99
-
.describe('The organization ID. Always ask the user.'),
105
+
.describe('The organization ID. Always ask the user.')
106
+
.optional(),
100
107
}),
101
108
execute: async({ type, organization_id })=>{
102
-
functiongenerateResponse(cost: Cost){
103
-
return`The new ${type} will cost $${cost.amount}${cost.recurrence}. You must repeat this to the user and confirm their understanding.`;
'Ask the user to confirm their understanding of the cost of creating a new project or branch. Call `get_cost` first. Returns a unique ID for this confirmation which should be passed to `create_project` or `create_branch`.',
// If elicitation fails (client doesn't support it), return cost info for manual confirmation
164
+
console.warn(
165
+
'Elicitation not supported by client, returning cost for manual confirmation'
166
+
);
167
+
console.warn(error);
168
+
}
169
+
}
170
+
171
+
if(userDeclinedCost){
172
+
thrownewError(
173
+
'The user declined to confirm the cost. Ask the user to confirm if they want to proceed with the operation or do something else.'
174
+
);
175
+
}
176
+
177
+
// Generate and return confirmation ID
178
+
constconfirmationId=awaithashObject(cost);
179
+
180
+
return{
181
+
...cost,
182
+
confirm_cost_id: confirmationId,
183
+
message:
184
+
cost.amount>0
185
+
? `The new ${type} will cost $${cost.amount}${cost.recurrence}. ${clientCapabilities?.elicitation ? 'User has confirmed.' : 'You must confirm this cost with the user before proceeding.'}`
186
+
: `The new ${type} is free. ${clientCapabilities?.elicitation ? 'User has confirmed.' : 'You may proceed with creation.'}`,
187
+
};
137
188
},
138
189
}),
139
190
create_project: tool({
140
191
description:
141
-
'Creates a new Supabase project. Always ask the user which organization to create the project in. If there is a cost involved, the user will be asked to confirm before creation. The project can take a few minutes to initialize - use `get_project` to check the status.',
192
+
'Creates a new Supabase project. Always ask the user which organization to create the project in. Call `get_and_confirm_cost` first to verify the cost and get user confirmation. The project can take a few minutes to initialize - use `get_project` to check the status.',
142
193
annotations: {
143
194
title: 'Create project',
144
195
readOnlyHint: false,
@@ -152,47 +203,30 @@ export function getAccountTools({
152
203
.enum(AWS_REGION_CODES)
153
204
.describe('The region to create the project in.'),
154
205
organization_id: z.string(),
206
+
confirm_cost_id: z
207
+
.string({
208
+
required_error:
209
+
'User must confirm understanding of costs before creating a project.',
210
+
})
211
+
.describe(
212
+
'The cost confirmation ID. Call `get_and_confirm_cost` first.'
// Only request confirmation if there's a cost AND server supports elicitation
165
-
if(cost.amount>0&&context?.server?.elicitInput){
166
-
constcostMessage=`$${cost.amount} per ${cost.recurrence}`;
167
-
168
-
constresult=awaitcontext.server.elicitInput({
169
-
message: `You are about to create project "${name}" in region ${region}.\n\n💰 Cost: ${costMessage}\n\nDo you want to proceed with this billable project?`,
170
-
requestedSchema: {
171
-
type: 'object',
172
-
properties: {
173
-
confirm: {
174
-
type: 'boolean',
175
-
title: 'Confirm billable project creation',
176
-
description: `I understand this will cost ${costMessage} and want to proceed`,
Copy file name to clipboardExpand all lines: packages/mcp-server-supabase/src/tools/branching-tools.ts
+12-58Lines changed: 12 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ export function getBranchingTools({
23
23
return{
24
24
create_branch: injectableTool({
25
25
description:
26
-
'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.',
26
+
'Creates a development branch on a Supabase project. Call `get_and_confirm_cost` first to verify the cost and get user confirmation. 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.',
27
27
annotations: {
28
28
title: 'Create branch',
29
29
readOnlyHint: false,
@@ -37,73 +37,27 @@ export function getBranchingTools({
37
37
.string()
38
38
.default('develop')
39
39
.describe('Name of the branch to create'),
40
-
// When the client supports elicitation, we will ask the user to confirm the
41
-
// branch cost interactively and this parameter is not required. For clients
42
-
// without elicitation support, this confirmation ID is required.
43
40
confirm_cost_id: z
44
-
.string()
45
-
.optional()
41
+
.string({
42
+
required_error:
43
+
'User must confirm understanding of costs before creating a branch.',
44
+
})
46
45
.describe(
47
-
'The cost confirmation ID. Call `confirm_cost` first if elicitation is not supported.'
46
+
'The cost confirmation ID. Call `get_and_confirm_cost` first.'
constcostMessage=`$${cost.amount} per ${cost.recurrence}`;
68
-
69
-
constresult=awaitcontext.server.elicitInput({
70
-
message: `You are about to create branch "${name}" on project ${project_id}.\n\n💰 Cost: ${costMessage}\n\nDo you want to proceed with this billable branch?`,
71
-
requestedSchema: {
72
-
type: 'object',
73
-
properties: {
74
-
confirm: {
75
-
type: 'boolean',
76
-
title: 'Confirm billable branch creation',
77
-
description: `I understand this will cost ${costMessage} and want to proceed`,
0 commit comments