Skip to main content
Glama
HenkDz

Self-Hosted Supabase MCP Server

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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}` };
        }
    },
  • 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';
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the prerequisite for the pg_net extension, which is useful behavioral context. However, it lacks details on potential side effects (e.g., downtime, errors), success criteria, or response format, leaving gaps in transparency for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, consisting of two sentences that efficiently convey the action and prerequisite without any wasted words. Every sentence earns its place by providing essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity as a mutation operation with no annotations and no output schema, the description is incomplete. It covers the prerequisite but omits details on what 'restart' entails, potential outcomes, or error handling. This leaves the agent with insufficient guidance for reliable invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the absence of inputs. The description does not add parameter-specific information, which is unnecessary here. A baseline of 4 is appropriate as it compensates for the lack of parameters by focusing on usage context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('restart') and resource ('pg_net worker'), making it understandable. However, it does not explicitly differentiate from sibling tools like 'list_extensions' or 'execute_sql', which might involve similar system operations, so it falls short of a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool by stating the prerequisite that 'the pg_net extension to be installed and available.' This helps guide usage, but it does not specify when not to use it or name alternatives among siblings, such as other maintenance tools, which would be needed for a higher score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/HenkDz/selfhosted-supabase-mcp'

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