Skip to main content
Glama
madhukarkumar

SingleStore MCP Server

create_table

Define and create a new database table with specific columns, constraints, and table options in SingleStore using the MCP Server for structured data management.

Instructions

Create a new table in the database with specified columns and constraints

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnsYesList of columns to create
table_nameYesName of the table to create
table_optionsNo

Implementation Reference

  • src/index.ts:1237-1308 (registration)
    Registration of the 'create_table' tool in the ListToolsRequestSchema handler, including detailed input schema definition
    {
      name: 'create_table',
      description: 'Create a new table in the database with specified columns and constraints',
      inputSchema: {
        type: 'object',
        properties: {
          table_name: {
            type: 'string',
            description: 'Name of the table to create'
          },
          columns: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                name: {
                  type: 'string',
                  description: 'Column name'
                },
                type: {
                  type: 'string',
                  description: 'Data type (e.g., INT, VARCHAR(255), etc.)'
                },
                nullable: {
                  type: 'boolean',
                  description: 'Whether the column can be NULL'
                },
                default: {
                  type: 'string',
                  description: 'Default value for the column'
                },
                auto_increment: {
                  type: 'boolean',
                  description: 'Whether the column should auto increment'
                }
              },
              required: ['name', 'type']
            },
            description: 'List of columns to create'
          },
          table_options: {
            type: 'object',
            properties: {
              shard_key: {
                type: 'array',
                items: { type: 'string' },
                description: 'Columns to use as shard key'
              },
              sort_key: {
                type: 'array',
                items: { type: 'string' },
                description: 'Columns to use as sort key'
              },
              is_reference: {
                type: 'boolean',
                description: 'Whether this is a reference table'
              },
              compression: {
                type: 'string',
                enum: ['SPARSE'],
                description: 'Table compression type'
              },
              auto_increment_start: {
                type: 'number',
                description: 'Starting value for auto increment columns'
              }
            }
          }
        },
        required: ['table_name', 'columns']
      }
    },
  • The handler function for the 'create_table' tool that validates input arguments, constructs the SingleStore-specific CREATE TABLE SQL statement (including shard keys, sort keys, reference tables, etc.), executes it via mysql2 connection, and returns success message or throws MCP error.
    case 'create_table': {
      if (!request.params.arguments || !request.params.arguments.table_name || !Array.isArray(request.params.arguments.columns)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid parameters for create_table'
        );
      }
    
      try {
        // First convert to unknown, then to our expected type
        const args = request.params.arguments as unknown as CreateTableArguments;
        const { table_name, columns, table_options = {} as TableOptions } = args;
        
        // Start building the CREATE TABLE statement
        let sql = `CREATE ${(table_options as TableOptions).is_reference ? 'REFERENCE ' : ''}TABLE ${table_name} (\n`;
        
        // Add columns
        const columnDefs = columns.map(col => {
          let def = `  ${col.name} ${col.type}`;
          if (col.nullable === false) def += ' NOT NULL';
          if (col.default !== undefined) def += ` DEFAULT ${col.default}`;
          if (col.auto_increment) def += ' AUTO_INCREMENT';
          return def;
        });
    
        // Add primary key if auto_increment is used
        const autoIncrementCol = columns.find(col => col.auto_increment);
        if (autoIncrementCol) {
          columnDefs.push(`  PRIMARY KEY (${autoIncrementCol.name})`);
        }
    
        // Add shard key if specified
        if ((table_options as TableOptions).shard_key?.length) {
          columnDefs.push(`  SHARD KEY (${(table_options as TableOptions).shard_key.join(', ')})`);
        }
    
        // Add sort key if specified
        if ((table_options as TableOptions).sort_key?.length) {
          columnDefs.push(`  SORT KEY (${(table_options as TableOptions).sort_key.join(', ')})`);
        }
    
        sql += columnDefs.join(',\n');
        sql += '\n)';
    
        // Add table options
        const tableOptions = [];
        if ((table_options as TableOptions).compression === 'SPARSE') {
          tableOptions.push('COMPRESSION = SPARSE');
        }
        if ((table_options as TableOptions).auto_increment_start) {
          tableOptions.push(`AUTO_INCREMENT = ${(table_options as TableOptions).auto_increment_start}`);
        }
        if (tableOptions.length) {
          sql += ' ' + tableOptions.join(' ');
        }
    
        // Execute the CREATE TABLE statement
        await conn.query(sql);
    
        return {
          content: [
            {
              type: 'text',
              text: `Table ${table_name} created successfully`
            }
          ]
        };
      } catch (error: unknown) {
        const err = error as Error;
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to create table: ${err.message}`
        );
      }
    }
  • TypeScript interface defining the expected arguments structure for the create_table tool, used for type safety in the handler.
    interface CreateTableArguments {
      table_name: string;
      columns: Column[];
      table_options?: TableOptions;
    }
  • TypeScript interface for table options used in create_table tool, supporting SingleStore-specific features like shard_key, sort_key, etc.
    interface TableOptions {
      is_reference?: boolean;
      shard_key?: string[];
      sort_key?: string[];
      compression?: string;
      auto_increment_start?: number;
    }
  • TypeScript interface defining column structure used in create_table tool arguments.
    interface Column {
      name: string;
      type: string;
      nullable?: boolean;
      default?: string | number | boolean;
      auto_increment?: boolean;
    }
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 this is a creation operation but doesn't mention important behavioral aspects: whether this requires specific database permissions, if it's a destructive operation that might overwrite existing tables, what happens on success/failure, or any rate limits. The description is minimal and doesn't compensate for the lack of annotations.

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 front-loads the core purpose ('Create a new table in the database') and adds necessary qualification ('with specified columns and constraints'). Every word serves a purpose with zero waste or redundancy. It's appropriately sized for a creation operation with moderate complexity.

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 database mutation tool with no annotations, no output schema, and moderate parameter complexity (3 parameters including nested objects), the description is insufficient. It doesn't address critical context: what permissions are needed, whether the operation is idempotent, what happens if a table already exists, what the return value looks like, or error conditions. The agent lacks necessary operational context for safe and 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?

The description mentions 'columns and constraints' which aligns with the 'columns' and 'table_options' parameters in the schema, providing some semantic context beyond the schema's technical descriptions. However, with 67% schema description coverage (2 of 3 parameters have descriptions), the description doesn't fully compensate for the coverage gap - it doesn't explain what 'table_options' encompasses or provide examples of constraint types. The baseline is appropriate given partial schema coverage.

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 action ('Create a new table') and the resource ('in the database'), with additional context about what gets created ('with specified columns and constraints'). It distinguishes from siblings like 'list_tables' or 'describe_table' by being a creation operation rather than querying existing tables. However, it doesn't explicitly differentiate from other potential table-related operations that might exist in other contexts.

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. It doesn't mention prerequisites (e.g., database permissions, existing schema), when not to use it (e.g., for temporary tables vs permanent), or refer to sibling tools like 'generate_er_diagram' for design planning or 'optimize_sql' for performance considerations. The agent must infer usage from the tool name alone.

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

Related 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/madhukarkumar/singlestore-mcp-server'

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