Skip to main content
Glama
nilsir

MCP Server MySQL

by nilsir

create_table

Define new database tables with specific columns, data types, and constraints for structured data storage in MySQL.

Instructions

Create a new table with specified columns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesTable name
columnsYesColumn definitions
databaseNoDatabase name (optional)

Implementation Reference

  • The handler function that executes the create_table tool logic: constructs a CREATE TABLE SQL statement from column definitions and executes it.
    async ({ table, columns, database }) => {
      const p = await getPool();
    
      const columnDefs = columns.map((col) => {
        let def = `\`${col.name}\` ${col.type}`;
        if (col.nullable === false) def += " NOT NULL";
        if (col.autoIncrement) def += " AUTO_INCREMENT";
        if (col.default !== undefined) def += ` DEFAULT ${col.default}`;
        if (col.primaryKey) def += " PRIMARY KEY";
        return def;
      });
    
      const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
      const sql = `CREATE TABLE ${tableName} (${columnDefs.join(", ")})`;
    
      await p.execute(sql);
    
      const output = { success: true, table, database: database || null };
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Table ${table} created successfully`,
          },
        ],
        structuredContent: output,
      };
    }
  • Zod schema for column definitions used in the input schema of create_table tool.
    const columnSchema = z.object({
      name: z.string().describe("Column name"),
      type: z.string().describe("Column type (e.g., VARCHAR(255), INT, TEXT)"),
      nullable: z.boolean().optional().describe("Whether column can be null"),
      primaryKey: z.boolean().optional().describe("Whether this is the primary key"),
      autoIncrement: z.boolean().optional().describe("Whether to auto increment"),
      default: z.string().optional().describe("Default value"),
    });
  • src/index.ts:311-348 (registration)
    Registration of the create_table tool using server.tool, including name, description, input schema, and reference to handler.
    server.tool(
      "create_table",
      "Create a new table with specified columns",
      {
        table: z.string().describe("Table name"),
        columns: z.array(columnSchema).describe("Column definitions"),
        database: z.string().optional().describe("Database name (optional)"),
      },
      async ({ table, columns, database }) => {
        const p = await getPool();
    
        const columnDefs = columns.map((col) => {
          let def = `\`${col.name}\` ${col.type}`;
          if (col.nullable === false) def += " NOT NULL";
          if (col.autoIncrement) def += " AUTO_INCREMENT";
          if (col.default !== undefined) def += ` DEFAULT ${col.default}`;
          if (col.primaryKey) def += " PRIMARY KEY";
          return def;
        });
    
        const tableName = database ? `\`${database}\`.\`${table}\`` : `\`${table}\``;
        const sql = `CREATE TABLE ${tableName} (${columnDefs.join(", ")})`;
    
        await p.execute(sql);
    
        const output = { success: true, table, database: database || null };
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Table ${table} created successfully`,
            },
          ],
          structuredContent: output,
        };
      }
    );
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 it 'creates' a new table, implying a write/mutation operation, but doesn't disclose permissions needed, whether it's idempotent, error conditions (e.g., duplicate table names), or what happens on success (e.g., returns confirmation). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero waste—it directly states the tool's purpose without redundancy. It's appropriately sized and front-loaded, making it easy to parse quickly. Every word earns its place, achieving optimal conciseness.

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?

Given the tool's complexity (a mutation operation with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like side effects, error handling, or return values, leaving gaps for an AI agent to infer. For a create operation in a database context, more context is needed to be fully helpful.

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 100%, so the schema fully documents all parameters (table, columns, database). The description adds minimal value beyond the schema by mentioning 'specified columns', which aligns with the 'columns' parameter but doesn't provide additional context like column constraints or examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 with specified columns'), making the purpose immediately understandable. It distinguishes from siblings like 'alter_table' or 'drop_table' by specifying creation rather than modification or deletion. However, it doesn't explicitly contrast with 'create_database' or 'create_index', which would elevate it to a 5.

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., needing an existing database), exclusions (e.g., not for modifying existing tables), or direct comparisons to siblings like 'alter_table' for updates or 'create_database' for database-level operations. Usage is implied but not explicitly stated.

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

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