Skip to main content
Glama

delete_sheet_columns

Remove specified columns from an Excel sheet by defining the starting column and count. Simplify data cleanup and reorganization for improved spreadsheet management.

Instructions

Delete 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 function for 'delete_sheet_columns' that resolves file path and delegates to core delete_cols implementation, handles errors and returns message.
    @mcp.tool()
    def delete_sheet_columns(
        filepath: str,
        sheet_name: str,
        start_col: int,
        count: int = 1
    ) -> str:
        """Delete one or more columns starting at the specified column."""
        try:
            full_path = get_excel_path(filepath)
            result = delete_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 deleting columns: {e}")
            raise
  • Core helper function that performs the actual column deletion using openpyxl: loads workbook, validates inputs, calls worksheet.delete_cols(start_col, count), saves the file, and returns success message.
    def delete_cols(filepath: str, sheet_name: str, start_col: int, count: int = 1) -> Dict[str, Any]:
        """Delete 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")
            if start_col > worksheet.max_column:
                raise ValidationError(f"Start column {start_col} exceeds worksheet bounds (max column: {worksheet.max_column})")
                
            worksheet.delete_cols(start_col, count)
            wb.save(filepath)
            
            return {"message": f"Deleted {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 delete 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 only states the basic action. It doesn't disclose whether this operation is destructive (implied by 'Delete' but not explicit), what permissions are needed, how it affects spreadsheet structure, error conditions, or what the output contains. Critical behavioral details are missing 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 that front-loads the core action. Every word contributes directly to understanding what the tool does without any fluff or redundant information.

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 this is a destructive mutation tool with 4 parameters (0% schema coverage) but with an output schema present, the description is minimally adequate. It covers the basic purpose but lacks crucial context about behavior, alternatives, and parameter meanings. The output schema may help with return values, but the description doesn't prepare the agent for successful invocation.

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 0%, so the description must compensate but only partially does. It mentions 'starting at the specified column' which clarifies start_col, and 'one or more columns' which relates to count, but doesn't explain filepath or sheet_name parameters. The description adds some meaning but leaves two parameters completely unexplained.

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 ('Delete') and target ('one or more columns'), specifying the starting point ('starting at the specified column'). It distinguishes from sibling delete_sheet_rows by targeting columns instead of rows, but doesn't explicitly differentiate from delete_range or delete_worksheet which handle different scopes of deletion.

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 like delete_range (for arbitrary ranges), delete_worksheet (for entire sheets), or delete_sheet_rows (for rows). The description implies column-specific deletion but offers no context about prerequisites, constraints, or typical use cases.

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