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;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe how it works - whether it connects to a live database, reads from configuration files, requires authentication, has rate limits, or what format the output takes. The description is functional but lacks operational context.

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 a single, efficient sentence that communicates the core functionality without any wasted words. It's appropriately sized for a tool with one simple parameter and gets straight to the point.

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

Completeness2/5

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

For a tool that presumably generates code/types from a database schema, the description is minimal. With no annotations and no output schema, it doesn't explain what the output looks like (TypeScript files? Inline code?), how errors are handled, or any dependencies or requirements. The description is functional but lacks important context for effective use.

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

Parameters3/5

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

With 100% schema description coverage, the input schema already documents the single optional 'schema' parameter with its default value. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation but doesn't provide additional value.

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

Purpose5/5

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

The description clearly states the specific action ('Generate TypeScript types') and target resource ('your Supabase database schema'), providing a complete purpose statement. It distinguishes from the sibling tool 'query_table' which appears to be for data querying rather than schema type generation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, nor any context about prerequisites or constraints. While it's clear what the tool does, there's no information about appropriate use cases or limitations.

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

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