Skip to main content
Glama
NightTrek

Supabase MCP Server

by NightTrek

generate_types

Generate TypeScript types from your Supabase database schema to ensure type safety in your applications.

Instructions

Generate TypeScript types for your Supabase database schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNoDatabase schema (optional, defaults to public)

Implementation Reference

  • Executes the generate_types tool: validates input, checks for Supabase CLI, constructs and runs the 'supabase gen types' command with appropriate flags, returns generated TypeScript types.
    case "generate_types": { if (!isValidTypeGenArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, "Invalid type generation arguments" ); } const hasSupabaseCLI = await this.checkSupabaseCLI(); if (!hasSupabaseCLI) { throw new McpError( ErrorCode.InternalError, 'Supabase CLI not found. Please install it with: npm install -g supabase' ); } const { schema = 'public' } = request.params.arguments; let command = 'npx supabase gen types typescript'; if (this.projectRef) { command += ` --project-id "${this.projectRef}"`; } else { command += ' --local'; } command += ` --schema ${schema}`; try { const { stdout, stderr } = await execAsync(command); return { content: [ { type: "text", text: stdout || stderr || 'No types generated', }, ], }; } catch (error: any) { throw new McpError( ErrorCode.InternalError, `Failed to generate types: ${error.message}` ); } }
  • src/index.ts:231-243 (registration)
    Registers the generate_types tool in the list of available tools, including name, description, and input schema.
    { name: "generate_types", description: "Generate TypeScript types for your Supabase database schema", inputSchema: { type: "object", properties: { schema: { type: "string", description: "Database schema (optional, defaults to public)", } }, }, },
  • Defines the input schema for the generate_types tool, specifying an optional 'schema' string parameter.
    inputSchema: { type: "object", properties: { schema: { type: "string", description: "Database schema (optional, defaults to public)", } }, },
  • Type guard function to validate input arguments for generate_types tool.
    const isValidTypeGenArgs = (args: any): args is TypeGenArgs => typeof args === "object" && args !== null && (args.schema === undefined || typeof args.schema === "string");
  • TypeScript interface defining the expected arguments for generate_types.
    interface TypeGenArgs { schema?: string; }

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/NightTrek/Supabase-MCP'

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