rebuild_hooks
Restart the pg_net worker to resolve connectivity issues in self-hosted Supabase instances when the extension is installed.
Instructions
Attempts to restart the pg_net worker. Requires the pg_net extension to be installed and available.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/rebuild_hooks.ts:31-61 (handler)The main handler function for the 'rebuild_hooks' tool. It executes SQL to restart the pg_net worker using executeSqlWithFallback, handles errors, and returns success/failure with a message.execute: async (input: RebuildHooksInput, context: ToolContext) => { const client = context.selfhostedClient; // Attempt to restart the pg_net worker. // This might fail if pg_net is not installed or the user lacks permissions. const restartSql = 'SELECT net.worker_restart()'; // Remove semicolon try { console.error('Attempting to restart pg_net worker...'); const result = await executeSqlWithFallback(client, restartSql, false); // Check if the result contains an error if ('error' in result) { // Specific check for function not found (pg_net might not be installed/active) const notFound = result.error.code === '42883'; // undefined_function const message = `Failed to restart pg_net worker: ${result.error.message}${notFound ? ' (Is pg_net installed and enabled?)' : ''}`; console.error(message); return { success: false, message }; } // If no error, assume success console.error('pg_net worker restart requested successfully.'); return { success: true, message: 'pg_net worker restart requested successfully.' }; } catch (error: unknown) { // Catch exceptions during the RPC call itself const errorMessage = error instanceof Error ? error.message : String(error); console.error(`Exception attempting to restart pg_net worker: ${errorMessage}`); return { success: false, message: `Exception attempting to restart pg_net worker: ${errorMessage}` }; } },
- src/tools/rebuild_hooks.ts:8-15 (schema)Zod schemas defining the input (empty object) and output (success boolean and message string) for the rebuild_hooks tool.const RebuildHooksInputSchema = z.object({}); type RebuildHooksInput = z.infer<typeof RebuildHooksInputSchema>; // Output schema const RebuildHooksOutputSchema = z.object({ success: z.boolean(), message: z.string(), });
- src/index.ts:98-121 (registration)The rebuildHooksTool is registered in the availableTools object, which is used to set up the MCP server's tool capabilities.const availableTools = { // Cast here assumes tools will implement AppTool structure [listTablesTool.name]: listTablesTool as AppTool, [listExtensionsTool.name]: listExtensionsTool as AppTool, [listMigrationsTool.name]: listMigrationsTool as AppTool, [applyMigrationTool.name]: applyMigrationTool as AppTool, [executeSqlTool.name]: executeSqlTool as AppTool, [getDatabaseConnectionsTool.name]: getDatabaseConnectionsTool as AppTool, [getDatabaseStatsTool.name]: getDatabaseStatsTool as AppTool, [getProjectUrlTool.name]: getProjectUrlTool as AppTool, [getAnonKeyTool.name]: getAnonKeyTool as AppTool, [getServiceKeyTool.name]: getServiceKeyTool as AppTool, [generateTypesTool.name]: generateTypesTool as AppTool, [rebuildHooksTool.name]: rebuildHooksTool as AppTool, [verifyJwtSecretTool.name]: verifyJwtSecretTool as AppTool, [listAuthUsersTool.name]: listAuthUsersTool as AppTool, [getAuthUserTool.name]: getAuthUserTool as AppTool, [deleteAuthUserTool.name]: deleteAuthUserTool as AppTool, [createAuthUserTool.name]: createAuthUserTool as AppTool, [updateAuthUserTool.name]: updateAuthUserTool as AppTool, [listStorageBucketsTool.name]: listStorageBucketsTool as AppTool, [listStorageObjectsTool.name]: listStorageObjectsTool as AppTool, [listRealtimePublicationsTool.name]: listRealtimePublicationsTool as AppTool, };
- src/index.ts:22-22 (registration)Import statement for the rebuildHooksTool in the main index file.import { rebuildHooksTool } from './tools/rebuild_hooks.js';