Skip to main content
Glama
enemyrr

MCP-MySQL Server

create_table

Build and define new database tables on MCP-MySQL Server by specifying table names, fields, indexes, and column properties for structured data storage.

Instructions

Create a new table in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsYes
indexesNo
tableYesTable name

Implementation Reference

  • The handler function that implements the core logic for the 'create_table' tool. It builds a CREATE TABLE SQL statement based on the input fields and optional indexes, executes it using executeQuery, and returns a success message.
    private async handleCreateTable(args: any) {
      const fields = args.fields.map((field: SchemaField) => {
        let def = `\`${field.name}\` ${field.type.toUpperCase()}`;
        if (field.length) def += `(${field.length})`;
        if (field.nullable === false) def += ' NOT NULL';
        if (field.default !== undefined) {
          def += ` DEFAULT ${field.default === null ? 'NULL' : `'${field.default}'`}`;
        }
        if (field.autoIncrement) def += ' AUTO_INCREMENT';
        if (field.primary) def += ' PRIMARY KEY';
        return def;
      });
    
      const indexes = args.indexes?.map((idx: IndexDefinition) => {
        const type = idx.unique ? 'UNIQUE INDEX' : 'INDEX';
        return `${type} \`${idx.name}\` (\`${idx.columns.join('`, `')}\`)`;
      }) || [];
    
      const sql = `CREATE TABLE \`${args.table}\` (
        ${[...fields, ...indexes].join(',\n      ')}
      )`;
    
      await this.executeQuery(sql);
      return {
        content: [
          {
            type: 'text',
            text: `Table ${args.table} created successfully`
          }
        ]
      };
    }
  • src/index.ts:490-539 (registration)
    Registration of the 'create_table' tool in the ListToolsRequestSchema handler, including its name, description, and detailed input schema definition.
    {
      name: 'create_table',
      description: 'Create a new table in the database',
      inputSchema: {
        type: 'object',
        properties: {
          table: {
            type: 'string',
            description: 'Table name',
          },
          fields: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                name: { type: 'string' },
                type: { type: 'string' },
                length: { type: 'number', optional: true },
                nullable: { type: 'boolean', optional: true },
                default: {
                  type: 'string',
                  description: 'Default value for the column (as string).',
                  optional: true
                },
                autoIncrement: { type: 'boolean', optional: true },
                primary: { type: 'boolean', optional: true }
              },
              required: ['name', 'type']
            }
          },
          indexes: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                name: { type: 'string' },
                columns: {
                  type: 'array',
                  items: { type: 'string' }
                },
                unique: { type: 'boolean', optional: true }
              },
              required: ['name', 'columns']
            },
            optional: true
          }
        },
        required: ['table', 'fields']
      }
    },
  • src/index.ts:581-582 (registration)
    Registration of the 'create_table' handler in the CallToolRequestSchema switch statement, dispatching to handleCreateTable.
    case 'create_table':
      return await this.handleCreateTable(request.params.arguments);
  • TypeScript interface defining the structure of table fields used in create_table input and handler.
    interface SchemaField {
      name: string;
      type: string;
      length?: number;
      nullable?: boolean;
      default?: string | number | null;
      autoIncrement?: boolean;
      primary?: boolean;
    }
  • TypeScript interface defining indexes for table creation in create_table tool.
    interface IndexDefinition {
      name: string;
      columns: string[];
      unique?: boolean;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'Create' which implies a write/mutation operation, but doesn't cover critical aspects like required permissions, whether the operation is idempotent, error handling, or what happens on conflicts (e.g., if the table already exists). This leaves significant gaps for a tool that modifies database state.

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 directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly.

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 with 3 parameters, low schema description coverage (33%), no annotations, and no output schema, the description is inadequate. It doesn't compensate for the missing behavioral context (e.g., mutation effects, error cases) or parameter details, leaving the agent poorly equipped to use this tool correctly in a database environment.

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?

Schema description coverage is low at 33%, with only the 'table' parameter documented. The description adds no parameter semantics beyond what the schema provides—it doesn't explain the purpose of 'fields' or 'indexes', their structure, or constraints. However, the schema itself defines these parameters with detailed properties, providing some baseline understanding despite the coverage gap.

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') and resource ('new table in the database'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'add_column' or 'execute', which might also involve database modifications, leaving room for ambiguity.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention prerequisites like needing an existing database connection (which 'connect_db' might handle) or when to use 'execute' for other SQL operations, leaving the agent without contextual usage cues.

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/enemyrr/mcp-mysql-server'

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