Skip to main content
Glama
yaoxiaolinglong

MCP-MongoDB-MySQL-Server

add_column

Add a new column to an existing table in MySQL or MongoDB databases through the MCP server, specifying column name, data type, and optional constraints like length, nullability, or default values.

Instructions

Add a new column to existing table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYes
fieldYes

Implementation Reference

  • The handler function that executes the add_column tool. It validates inputs, constructs an ALTER TABLE ADD COLUMN SQL statement based on the field definition, executes it, and returns success or error message.
    private async handleAddColumn(args: any) {
      await this.ensureConnection();
    
      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}'`}`;
      }
    
      try {
        await this.connection!.query(sql);
        return {
          content: [
            {
              type: 'text',
              text: `Column ${args.field.name} added to table ${args.table}`
            }
          ]
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to add column: ${getErrorMessage(error)}`
        );
      }
    }
  • Input schema definition for the add_column tool, specifying required table name and field object with name, type, and optional 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', 'number', 'null'],
              optional: true
            }
          },
          required: ['name', 'type']
        }
      },
      required: ['table', 'field']
    }
  • src/index.ts:373-397 (registration)
    Tool registration in the ListTools response, 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', 'number', 'null'],
                optional: true
              }
            },
            required: ['name', 'type']
          }
        },
        required: ['table', 'field']
      }
    },
  • src/index.ts:549-550 (registration)
    Dispatch case in the CallToolRequestHandler switch statement that routes add_column calls to the handler 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. 'Add a new column' implies a write/mutation operation, but the description doesn't cover critical aspects: whether this requires specific permissions, if it's reversible, potential side effects (e.g., locking the table), or error conditions. For a schema-altering 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, front-loaded sentence with zero wasted words—it directly states the tool's purpose. Every word earns its place, making it highly efficient and easy to parse. No extraneous details or redundancy are present, which is ideal for 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 complexity (schema-altering operation with nested parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral traits, parameter meanings, return values, or error handling. For a tool that modifies database schemas, this minimal description leaves too many gaps for safe and effective use by an AI agent.

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 parameters are undocumented in the schema. The description mentions 'table' and 'field' implicitly but adds no semantic details: it doesn't explain what 'table' refers to (e.g., table name), what 'field' encompasses (e.g., column definition with properties like type), or provide examples. With two required parameters and nested objects, the description fails to compensate for the lack of schema documentation.

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 from siblings like 'create_table' (creates new tables) and 'describe_table' (reads metadata). However, it doesn't specify the database system or context, which could help differentiate from similar tools 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., needing an existing table), exclusions (e.g., not for modifying existing columns), or sibling tools like 'execute' (which might handle SQL directly) or 'create_table' (for initial schema). Without this context, 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

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

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