Skip to main content
Glama
enemyrr

MCP-MySQL Server

add_column

Add a new column to a MySQL table by specifying the column name, data type, and optional attributes such as length, nullability, and default value.

Instructions

Add a new column to existing table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldYes
tableYes

Implementation Reference

  • The handler function for the 'add_column' tool. It constructs an ALTER TABLE ADD COLUMN SQL statement based on the input arguments and executes it using executeQuery. Returns a success message.
    private async handleAddColumn(args: any) {
      if (!args.table || !args.field) {
        throw new McpError(ErrorCode.InvalidParams, 'Table name and field are required');
      }
    
      let sql = `ALTER TABLE \`${args.table}\` ADD COLUMN \`${args.field.name}\` ${args.field.type.toUpperCase()}`;
      if (args.field.length) sql += `(${args.field.length})`;
      if (args.field.nullable === false) sql += ' NOT NULL';
      if (args.field.default !== undefined) {
        sql += ` DEFAULT ${args.field.default === null ? 'NULL' : `'${args.field.default}'`}`;
      }
    
      await this.executeQuery(sql);
      return {
        content: [
          {
            type: 'text',
            text: `Column ${args.field.name} added to table ${args.table}`
          }
        ]
      };
    }
  • The input schema definition for the 'add_column' tool, specifying the expected structure of table name and field properties (name, type, length, nullable, default).
    inputSchema: {
      type: 'object',
      properties: {
        table: { type: 'string' },
        field: {
          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
            }
          },
          required: ['name', 'type']
        }
      },
      required: ['table', 'field']
    }
  • src/index.ts:540-565 (registration)
    The tool registration object for 'add_column' in the setTools call, including name, description, and input schema.
    {
      name: 'add_column',
      description: 'Add a new column to existing table',
      inputSchema: {
        type: 'object',
        properties: {
          table: { type: 'string' },
          field: {
            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
              }
            },
            required: ['name', 'type']
          }
        },
        required: ['table', 'field']
      }
    }
  • src/index.ts:583-584 (registration)
    The dispatch case in setRequestHandler that routes 'add_column' tool calls to the handleAddColumn method.
    case 'add_column':
      return await this.handleAddColumn(request.params.arguments);
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 mutation operation ('Add'), implying it modifies the database schema, but doesn't mention permissions required, whether it's reversible, potential side effects on existing data, or error conditions. This leaves significant gaps for a tool that alters database structure.

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 gets straight to the point with no wasted words. It's appropriately sized for a simple tool and front-loads the core action without unnecessary elaboration.

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 complexity (database schema mutation with nested parameters), lack of annotations, and no output schema, the description is inadequate. It doesn't cover behavioral aspects like permissions or side effects, parameter details, or what to expect upon success/failure. For a tool that modifies database structure, this leaves too many unknowns for safe and effective use.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but fails to do so. It doesn't explain what 'table' and 'field' parameters represent, their expected formats, or the nested structure of 'field' with properties like 'name', 'type', 'nullable', etc. The description adds no meaningful parameter context beyond what's minimally implied by the tool name.

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 ('Add') and the target resource ('new column to existing table'), making the purpose immediately understandable. It doesn't distinguish from siblings like 'create_table' or 'describe_table', but it's specific enough to avoid confusion with other database operations.

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 like 'create_table' for new tables or 'execute' for general SQL commands. There's no mention of prerequisites, such as needing an existing table, or any context about when this operation is appropriate versus other schema modifications.

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