Skip to content

Conversation

@Rodriguespn
Copy link
Contributor

@Rodriguespn Rodriguespn commented Oct 27, 2025

Summary

Implements MCP elicitation for the apply_migration tool to request user confirmation before applying database migrations.

Implementation

Uses a try-catch pattern to gracefully fallback when clients don't support elicitation:

  • Supporting clients: Show confirmation dialog with migration details and SQL preview
  • Non-supporting clients: Proceed with migration without confirmation (existing behavior)

Client Support

Currently supported: VS Code Copilot, Cursor, Postman, VT Code, fast-agent, mcp-use, MCPJam

Not yet supported: Claude Desktop, Claude.ai, GitHub Copilot coding agent

Related

AI-142: Explore MCP Elicitations

- 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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds user confirmation prompts for database migrations using MCP's elicitation feature. When applying migrations, users will now be presented with the SQL to review and must explicitly confirm before the migration executes.

Key Changes:

  • Adds elicitation/create request to prompt users for confirmation before applying migrations
  • Passes server instance to database tools to enable elicitation requests
  • Maintains backwards compatibility by proceeding without confirmation if elicitation is not supported

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/mcp-server-supabase/src/tools/database-operation-tools.ts Implements elicitation request for user confirmation with SQL review before migration execution
packages/mcp-server-supabase/src/server.ts Passes server instance to getDatabaseTools to enable elicitation functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +252 to +256
// If elicitation fails (client doesn't support it), proceed without confirmation
// This maintains backwards compatibility
console.warn(
'Elicitation not supported by client, proceeding with migration without confirmation'
);
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch block silently proceeds with the migration after any elicitation error, which could include network failures or other issues unrelated to client support. Consider checking the specific error type to distinguish between 'unsupported' vs other failures, and potentially fail fast for unexpected errors rather than always proceeding.

Suggested change
// If elicitation fails (client doesn't support it), proceed without confirmation
// This maintains backwards compatibility
console.warn(
'Elicitation not supported by client, proceeding with migration without confirmation'
);
// Only proceed if the error is due to unsupported elicitation; otherwise, fail fast
const errorMessage =
typeof error === 'string'
? error
: error instanceof Error
? error.message
: '';
if (
errorMessage &&
(
errorMessage.includes('elicitation not supported') ||
errorMessage.includes('Elicitation not supported') ||
errorMessage.includes('not implemented') ||
errorMessage.includes('unsupported')
)
) {
console.warn(
'Elicitation not supported by client, proceeding with migration without confirmation'
);
} else {
// Unexpected error, fail fast
throw error;
}

Copilot uses AI. Check for mistakes.
},
},
},
// @ts-ignore - elicitation types might not be available
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @ts-ignore suppresses all type checking for the next line. Consider using @ts-expect-error instead, which will fail if the error no longer exists, helping track when types become available.

Suggested change
// @ts-ignore - elicitation types might not be available
// @ts-expect-error - elicitation types might not be available

Copilot uses AI. Check for mistakes.
@Rodriguespn
Copy link
Contributor Author

Rodriguespn commented Oct 27, 2025

@mattrossman I've implemented elicitation on apply_migration as a POC. Would love to discuss the implementation and testing approach before rolling it out to the other high-priority tools (execute_sql, merge_branch, etc.).

// Try to request user confirmation via elicitation
if (server) {
try {
const result = (await server.request(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we can use the elicitInput helper here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants