Skip to main content
Glama

edit-table-schema

Modify table structure in Xano databases by adding, removing, or renaming columns to adapt data models to changing application requirements.

Instructions

Edit the schema of an existing table (add, remove, or modify columns)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_idYesID of the table to edit
operationYesType of schema operation to perform
schemaNoFull schema specification (for 'update' operation)
columnNoColumn specification (for 'add_column' operation)
renameNoRename specification (for 'rename_column' operation)
column_nameNoName of the column to remove (for 'remove_column' operation)

Implementation Reference

  • The handler function for 'edit-table-schema' tool. It handles four operations: 'update' (PUT entire schema), 'add_column' (POST to /schema/type/{type}), 'rename_column' (POST to /schema/rename), 'remove_column' (DELETE /schema/{column_name}). Uses makeXanoRequest helper for API calls.
    async ({ table_id, operation, schema, column, rename, column_name }) => {
      console.error(`[Tool] Executing edit-table-schema for table ID: ${table_id}, operation: ${operation}`);
      
      try {
        let result;
        let successMessage = "";
        
        switch (operation) {
          case 'update':
            if (!schema || schema.length === 0) {
              return {
                content: [{ type: "text", text: "Error: Schema array must be provided for 'update' operation" }],
                isError: true
              };
            }
            
            // PUT request to update the entire schema
            await makeXanoRequest(
              `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema`,
              'PUT',
              { schema }
            );
            
            successMessage = `Successfully updated the entire schema for table ID: ${table_id}`;
            break;
            
          case 'add_column':
            if (!column) {
              return {
                content: [{ type: "text", text: "Error: Column specification must be provided for 'add_column' operation" }],
                isError: true
              };
            }
            
            // POST request to add a new column of the specified type
            await makeXanoRequest(
              `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema/type/${column.type}`,
              'POST',
              column
            );
            
            successMessage = `Successfully added column '${column.name}' of type '${column.type}' to table ID: ${table_id}`;
            break;
            
          case 'rename_column':
            if (!rename) {
              return {
                content: [{ type: "text", text: "Error: Rename specification must be provided for 'rename_column' operation" }],
                isError: true
              };
            }
            
            // POST request to rename a column
            await makeXanoRequest(
              `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema/rename`,
              'POST',
              rename
            );
            
            successMessage = `Successfully renamed column from '${rename.old_name}' to '${rename.new_name}' in table ID: ${table_id}`;
            break;
            
          case 'remove_column':
            if (!column_name) {
              return {
                content: [{ type: "text", text: "Error: Column name must be provided for 'remove_column' operation" }],
                isError: true
              };
            }
            
            // DELETE request to remove a column
            await makeXanoRequest(
              `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema/${column_name}`,
              'DELETE'
            );
            
            successMessage = `Successfully removed column '${column_name}' from table ID: ${table_id}`;
            break;
        }
        
        console.error(`[Tool] ${successMessage}`);
        return {
          content: [{ type: "text", text: successMessage }]
        };
        
      } catch (error) {
        console.error(`[Error] Failed to edit table schema: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [
            {
              type: "text",
              text: `Error editing table schema: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod input schema defining parameters for edit-table-schema: table_id (string), operation (enum), conditional params like schema (array), column (object), rename (object), column_name (string).
    {
      table_id: z.string().describe("ID of the table to edit"),
      operation: z.enum(['update', 'add_column', 'rename_column', 'remove_column']).describe("Type of schema operation to perform"),
      
      // For updating the entire schema
      schema: z.array(z.object({
        name: z.string().describe("Name of the schema element"),
        type: z.enum([
          "attachment", "audio", "bool", "date", "decimal", "email", "enum", 
          "geo_linestring", "geo_multilinestring", "geo_multipoint", "geo_multipolygon", 
          "geo_point", "geo_polygon", "image", "int", "json", "object", "password", 
          "tableref", "tablerefuuid", "text", "timestamp", "uuid", "vector", "video"
        ]).describe("Type of the schema element"),
        description: z.string().optional().describe("Description of the schema element"),
        nullable: z.boolean().optional().default(false).describe("Whether the field can be null"),
        required: z.boolean().optional().default(false).describe("Whether the field is required"),
        access: z.enum(["public", "private", "internal"]).optional().default("public").describe("Access level for the field"),
        style: z.enum(["single", "list"]).optional().default("single").describe("Whether the field is a single value or a list"),
        default: z.string().optional().describe("Default value for the field"),
        config: z.record(z.any()).optional().describe("Additional configuration for specific field types"),
        children: z.array(z.any()).optional().describe("Nested fields for object types")
      })).optional().describe("Full schema specification (for 'update' operation)"),
      
      // For adding a single column
      column: z.object({
        name: z.string().describe("Name of the column"),
        type: z.enum([
          "attachment", "audio", "bool", "date", "decimal", "email", "enum", 
          "geo_linestring", "geo_multilinestring", "geo_multipoint", "geo_multipolygon", 
          "geo_point", "geo_polygon", "image", "int", "json", "object", "password", 
          "tableref", "tablerefuuid", "text", "timestamp", "uuid", "vector", "video"
        ]).describe("Type of the column"),
        description: z.string().optional().describe("Description of the column"),
        nullable: z.boolean().optional().default(false).describe("Whether the field can be null"),
        required: z.boolean().optional().default(false).describe("Whether the field is required"),
        access: z.enum(["public", "private", "internal"]).optional().default("public").describe("Access level for the field"),
        style: z.enum(["single", "list"]).optional().default("single").describe("Whether the field is a single value or a list"),
        default: z.string().optional().describe("Default value for the field"),
        config: z.record(z.any()).optional().describe("Additional configuration for the column")
      }).optional().describe("Column specification (for 'add_column' operation)"),
      
      // For renaming a column
      rename: z.object({
        old_name: z.string().describe("Current name of the column"),
        new_name: z.string().describe("New name for the column")
      }).optional().describe("Rename specification (for 'rename_column' operation)"),
      
      // For removing a column
      column_name: z.string().optional().describe("Name of the column to remove (for 'remove_column' operation)")
    },
  • src/index.ts:411-562 (registration)
    Registration of the 'edit-table-schema' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool(
      "edit-table-schema",
      "Edit the schema of an existing table (add, remove, or modify columns)",
      {
        table_id: z.string().describe("ID of the table to edit"),
        operation: z.enum(['update', 'add_column', 'rename_column', 'remove_column']).describe("Type of schema operation to perform"),
        
        // For updating the entire schema
        schema: z.array(z.object({
          name: z.string().describe("Name of the schema element"),
          type: z.enum([
            "attachment", "audio", "bool", "date", "decimal", "email", "enum", 
            "geo_linestring", "geo_multilinestring", "geo_multipoint", "geo_multipolygon", 
            "geo_point", "geo_polygon", "image", "int", "json", "object", "password", 
            "tableref", "tablerefuuid", "text", "timestamp", "uuid", "vector", "video"
          ]).describe("Type of the schema element"),
          description: z.string().optional().describe("Description of the schema element"),
          nullable: z.boolean().optional().default(false).describe("Whether the field can be null"),
          required: z.boolean().optional().default(false).describe("Whether the field is required"),
          access: z.enum(["public", "private", "internal"]).optional().default("public").describe("Access level for the field"),
          style: z.enum(["single", "list"]).optional().default("single").describe("Whether the field is a single value or a list"),
          default: z.string().optional().describe("Default value for the field"),
          config: z.record(z.any()).optional().describe("Additional configuration for specific field types"),
          children: z.array(z.any()).optional().describe("Nested fields for object types")
        })).optional().describe("Full schema specification (for 'update' operation)"),
        
        // For adding a single column
        column: z.object({
          name: z.string().describe("Name of the column"),
          type: z.enum([
            "attachment", "audio", "bool", "date", "decimal", "email", "enum", 
            "geo_linestring", "geo_multilinestring", "geo_multipoint", "geo_multipolygon", 
            "geo_point", "geo_polygon", "image", "int", "json", "object", "password", 
            "tableref", "tablerefuuid", "text", "timestamp", "uuid", "vector", "video"
          ]).describe("Type of the column"),
          description: z.string().optional().describe("Description of the column"),
          nullable: z.boolean().optional().default(false).describe("Whether the field can be null"),
          required: z.boolean().optional().default(false).describe("Whether the field is required"),
          access: z.enum(["public", "private", "internal"]).optional().default("public").describe("Access level for the field"),
          style: z.enum(["single", "list"]).optional().default("single").describe("Whether the field is a single value or a list"),
          default: z.string().optional().describe("Default value for the field"),
          config: z.record(z.any()).optional().describe("Additional configuration for the column")
        }).optional().describe("Column specification (for 'add_column' operation)"),
        
        // For renaming a column
        rename: z.object({
          old_name: z.string().describe("Current name of the column"),
          new_name: z.string().describe("New name for the column")
        }).optional().describe("Rename specification (for 'rename_column' operation)"),
        
        // For removing a column
        column_name: z.string().optional().describe("Name of the column to remove (for 'remove_column' operation)")
      },
      async ({ table_id, operation, schema, column, rename, column_name }) => {
        console.error(`[Tool] Executing edit-table-schema for table ID: ${table_id}, operation: ${operation}`);
        
        try {
          let result;
          let successMessage = "";
          
          switch (operation) {
            case 'update':
              if (!schema || schema.length === 0) {
                return {
                  content: [{ type: "text", text: "Error: Schema array must be provided for 'update' operation" }],
                  isError: true
                };
              }
              
              // PUT request to update the entire schema
              await makeXanoRequest(
                `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema`,
                'PUT',
                { schema }
              );
              
              successMessage = `Successfully updated the entire schema for table ID: ${table_id}`;
              break;
              
            case 'add_column':
              if (!column) {
                return {
                  content: [{ type: "text", text: "Error: Column specification must be provided for 'add_column' operation" }],
                  isError: true
                };
              }
              
              // POST request to add a new column of the specified type
              await makeXanoRequest(
                `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema/type/${column.type}`,
                'POST',
                column
              );
              
              successMessage = `Successfully added column '${column.name}' of type '${column.type}' to table ID: ${table_id}`;
              break;
              
            case 'rename_column':
              if (!rename) {
                return {
                  content: [{ type: "text", text: "Error: Rename specification must be provided for 'rename_column' operation" }],
                  isError: true
                };
              }
              
              // POST request to rename a column
              await makeXanoRequest(
                `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema/rename`,
                'POST',
                rename
              );
              
              successMessage = `Successfully renamed column from '${rename.old_name}' to '${rename.new_name}' in table ID: ${table_id}`;
              break;
              
            case 'remove_column':
              if (!column_name) {
                return {
                  content: [{ type: "text", text: "Error: Column name must be provided for 'remove_column' operation" }],
                  isError: true
                };
              }
              
              // DELETE request to remove a column
              await makeXanoRequest(
                `/workspace/${XANO_WORKSPACE}/table/${table_id}/schema/${column_name}`,
                'DELETE'
              );
              
              successMessage = `Successfully removed column '${column_name}' from table ID: ${table_id}`;
              break;
          }
          
          console.error(`[Tool] ${successMessage}`);
          return {
            content: [{ type: "text", text: successMessage }]
          };
          
        } catch (error) {
          console.error(`[Error] Failed to edit table schema: ${error instanceof Error ? error.message : String(error)}`);
          return {
            content: [
              {
                type: "text",
                text: `Error editing table schema: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );
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 the tool edits schema but doesn't mention critical traits like whether it's destructive (e.g., data loss when removing columns), permission requirements, rate limits, or error handling. For a mutation tool with complex operations, this is a significant gap in transparency, scoring low due to missing essential behavioral context.

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 front-loads the core purpose ('edit the schema of an existing table') and specifies operations in parentheses. There's zero waste or redundancy, making it highly concise and well-structured for quick comprehension.

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 (mutation with 6 parameters, nested objects, no output schema, and no annotations), the description is incomplete. It lacks behavioral context (e.g., safety, permissions), usage guidelines, and output expectations. For a schema-editing tool that could impact data integrity, this minimal description fails to provide sufficient context for safe and effective use.

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 input schema fully documents all 6 parameters. The description adds no parameter-specific semantics beyond implying operations (add, remove, modify columns), which aligns with the 'operation' enum but doesn't provide additional syntax or format details. Baseline 3 is appropriate as the schema does the heavy lifting, and the description doesn't compensate with extra insights.

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 ('edit') and resource ('schema of an existing table'), specifying the operations (add, remove, or modify columns). It distinguishes from siblings like 'add-table' or 'get-table-schema' by focusing on schema modification rather than creation or retrieval. However, it doesn't explicitly differentiate from potential overlapping tools like 'update-table' if they exist, keeping it at 4 instead of 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., table must exist), exclusions (e.g., cannot edit system tables), or compare with sibling tools like 'add-table' for new tables or 'get-table-schema' for viewing. This lack of context leaves the agent guessing about appropriate usage scenarios.

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/lowcodelocky2/xano-mcp'

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