Skip to main content
Glama
abushadab

Self-Hosted Supabase MCP Server

by abushadab

list_migrations

Track and display applied database migrations from the supabase_migrations.schema_migrations table for self-hosted Supabase instances. Useful for managing and verifying database schema changes.

Instructions

Lists applied database migrations recorded in supabase_migrations.schema_migrations table.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the tool logic: queries the database for applied migrations using a SQL statement and processes the response.
    execute: async (input: ListMigrationsInput, context: ToolContext) => { const client = context.selfhostedClient; // SQL to query the Supabase migrations table const listMigrationsSql = ` SELECT version, name, inserted_at FROM supabase_migrations.schema_migrations ORDER BY version `; // This table might not exist if migrations haven't been run // The RPC call will handle the error, which handleSqlResponse will catch const result = await executeSqlWithFallback(client, listMigrationsSql, true); return handleSqlResponse(result, ListMigrationsOutputSchema); },
  • Zod schema defining the output structure: an array of migration objects containing version, name, and inserted_at.
    const ListMigrationsOutputSchema = z.array(z.object({ version: z.string(), name: z.string(), inserted_at: z.string(), // Keep as string from DB }));
  • Zod schema for input (empty object since no parameters required) and inferred type.
    const ListMigrationsInputSchema = z.object({}); type ListMigrationsInput = z.infer<typeof ListMigrationsInputSchema>;
  • The tool object definition including name, description, schemas, and execute handler, exported for use in the MCP server.
    export const listMigrationsTool = { name: 'list_migrations', description: 'Lists applied database migrations recorded in supabase_migrations.schema_migrations table.', inputSchema: ListMigrationsInputSchema, mcpInputSchema: mcpInputSchema, outputSchema: ListMigrationsOutputSchema, execute: async (input: ListMigrationsInput, context: ToolContext) => { const client = context.selfhostedClient; // SQL to query the Supabase migrations table const listMigrationsSql = ` SELECT version, name, inserted_at FROM supabase_migrations.schema_migrations ORDER BY version `; // This table might not exist if migrations haven't been run // The RPC call will handle the error, which handleSqlResponse will catch const result = await executeSqlWithFallback(client, listMigrationsSql, true); return handleSqlResponse(result, ListMigrationsOutputSchema); }, };
  • src/index.ts:102-102 (registration)
    Registers the listMigrationsTool in the availableTools map used to populate MCP server capabilities.
    [listMigrationsTool.name]: listMigrationsTool as AppTool,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/abushadab/selfhosted-supabase-mcp-basic-auth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server