Skip to main content
Glama

insert_columns

Add one or more columns to an Excel sheet at a specified location. Define the start column and count to customize insertion, enhancing workbook organization and data structure.

Instructions

Insert one or more columns starting at the specified column.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNo
filepathYes
sheet_nameYes
start_colYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for the 'insert_columns' tool. This function is decorated with @mcp.tool(), which both defines the tool interface (parameters and docstring serving as schema) and registers it with the FastMCP server. It wraps the core implementation by calling insert_cols from sheet.py.
    @mcp.tool()
    def insert_columns(
        filepath: str,
        sheet_name: str,
        start_col: int,
        count: int = 1
    ) -> str:
        """Insert one or more columns starting at the specified column."""
        try:
            full_path = get_excel_path(filepath)
            result = insert_cols(full_path, sheet_name, start_col, count)
            return result["message"]
        except (ValidationError, SheetError) as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error inserting columns: {e}")
            raise
  • Core helper function implementing the column insertion logic using openpyxl. Loads the workbook, validates inputs, calls worksheet.insert_cols(), saves the file, and returns a success message.
    def insert_cols(filepath: str, sheet_name: str, start_col: int, count: int = 1) -> Dict[str, Any]:
        """Insert one or more columns starting at the specified column."""
        try:
            wb = load_workbook(filepath)
            if sheet_name not in wb.sheetnames:
                raise SheetError(f"Sheet '{sheet_name}' not found")
                
            worksheet = wb[sheet_name]
            
            # Validate parameters
            if start_col < 1:
                raise ValidationError("Start column must be 1 or greater")
            if count < 1:
                raise ValidationError("Count must be 1 or greater")
                
            worksheet.insert_cols(start_col, count)
            wb.save(filepath)
            
            return {"message": f"Inserted {count} column(s) starting at column {start_col} in sheet '{sheet_name}'"}
        except (ValidationError, SheetError) as e:
            logger.error(str(e))
            raise
        except Exception as e:
            logger.error(f"Failed to insert columns: {e}")
            raise SheetError(str(e))
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose permissions needed, whether the operation modifies existing data (e.g., shifting cells), error conditions, or output format. The phrase 'starting at the specified column' hints at positional behavior but is insufficient for a mutation tool.

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 front-loads the core action and key parameters ('columns', 'specified column'), making it easy to parse quickly. No extraneous information is included.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 4 parameters with 0% schema coverage, no annotations, but an output schema exists, the description is minimally adequate. It covers the basic operation but lacks details on inputs like file format, sheet existence, or output behavior. The output schema may help, but the description doesn't reference it or provide context for a mutation tool.

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 adds minimal param semantics. It mentions 'one or more columns' (relating to 'count') and 'starting at the specified column' (relating to 'start_col'), but doesn't explain 'filepath' or 'sheet_name' usage, format, or constraints. This partially addresses 2 of 4 parameters.

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 ('Insert') and resource ('one or more columns'), specifying the starting point ('at the specified column'). It distinguishes from sibling tools like 'insert_rows' by focusing on columns, but doesn't explicitly differentiate from other column-related tools like 'delete_sheet_columns'.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context (e.g., Excel file operations), or compare to siblings like 'format_range' or 'copy_range' for column manipulation. 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

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/haris-musa/excel-mcp-server'

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