Skip to main content
Glama
kevinbin

MCP MySQL Server

by kevinbin

add_column

Add a new column to an existing MySQL table by specifying the column name, 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 that implements the add_column tool. It constructs an ALTER TABLE ADD COLUMN SQL statement based on the input arguments and executes it using the shared executeQuery method.
    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}`
          }
        ]
      };
    }
  • src/index.ts:489-513 (registration)
    Registers the 'add_column' tool in the listTools response, including its description and input schema definition.
    {
      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', 'number', 'null'],
                optional: true
              }
            },
            required: ['name', 'type']
          }
        },
        required: ['table', 'field']
      }
    }
  • src/index.ts:531-532 (registration)
    In the CallToolRequest handler switch statement, 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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a mutation ('Add'), implying it modifies database structure, but doesn't cover critical aspects like permissions required, whether changes are reversible, impact on existing data, error handling, or response format. For a tool that alters schema with no 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 wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word ('Add', 'new column', 'existing table') contributes directly to understanding the tool's function.

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 (2 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain the input structure (e.g., that 'field' is an object with specific properties), behavioral traits (e.g., mutation effects), or output expectations. For a schema-altering tool with rich parameters but no supporting documentation, this leaves too much undefined.

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%, meaning none of the parameters (table, field with nested properties like name, type, nullable, length, default) are documented in the schema. The description only mentions 'table' and 'column' generically, without explaining what 'field' represents or detailing the nested properties. It fails to compensate for the schema's lack of documentation, leaving key semantics unclear.

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 resource ('new column to existing table'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'create_table' (which creates entire tables) and 'describe_table' (which inspects structure). However, it doesn't specify what kind of database or system it operates on, which could help further differentiate it from generic column-adding tools.

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 table from 'create_table' or 'list_tables'), exclusions (e.g., not for modifying columns), or comparisons to siblings like 'execute' (which might handle SQL directly). Without this context, an 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/kevinbin/mcp-mysql-server'

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