Skip to main content
Glama

delete_sheet_rows

Remove specified rows from an Excel sheet by defining the start row and count. Streamlines data cleanup and restructuring within workbooks for improved organization.

Instructions

Delete one or more rows starting at the specified row.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNo
filepathYes
sheet_nameYes
start_rowYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for delete_sheet_rows, decorated with @mcp.tool() for registration and execution. Delegates to delete_rows helper.
    @mcp.tool()
    def delete_sheet_rows(
        filepath: str,
        sheet_name: str,
        start_row: int,
        count: int = 1
    ) -> str:
        """Delete one or more rows starting at the specified row."""
        try:
            full_path = get_excel_path(filepath)
            result = delete_rows(full_path, sheet_name, start_row, count)
            return result["message"]
        except (ValidationError, SheetError) as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error deleting rows: {e}")
            raise
  • Core helper function implementing row deletion using openpyxl's worksheet.delete_rows method.
    def delete_rows(filepath: str, sheet_name: str, start_row: int, count: int = 1) -> Dict[str, Any]:
        """Delete one or more rows starting at the specified row."""
        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_row < 1:
                raise ValidationError("Start row must be 1 or greater")
            if count < 1:
                raise ValidationError("Count must be 1 or greater")
            if start_row > worksheet.max_row:
                raise ValidationError(f"Start row {start_row} exceeds worksheet bounds (max row: {worksheet.max_row})")
                
            worksheet.delete_rows(start_row, count)
            wb.save(filepath)
            
            return {"message": f"Deleted {count} row(s) starting at row {start_row} in sheet '{sheet_name}'"}
        except (ValidationError, SheetError) as e:
            logger.error(str(e))
            raise
        except Exception as e:
            logger.error(f"Failed to delete rows: {e}")
            raise SheetError(str(e))
  • Tool registration via @mcp.tool() decorator in server.py.
    @mcp.tool()
    def delete_sheet_rows(
        filepath: str,
        sheet_name: str,
        start_row: int,
        count: int = 1
    ) -> str:
        """Delete one or more rows starting at the specified row."""
        try:
            full_path = get_excel_path(filepath)
            result = delete_rows(full_path, sheet_name, start_row, count)
            return result["message"]
        except (ValidationError, SheetError) as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error deleting rows: {e}")
            raise
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. While 'Delete' implies a destructive operation, it doesn't specify whether deletion is permanent/reversible, what permissions are required, how it affects formulas/references, or error handling. The description lacks critical behavioral context for a destructive 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 communicates the core functionality without unnecessary words. It's appropriately sized for a straightforward deletion operation and front-loads the key action.

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?

For a destructive tool with 4 parameters (0% schema coverage) and no annotations, the description is insufficient. While an output schema exists, the description doesn't address critical behavioral aspects like permanence, permissions, or error conditions that an agent needs to use this tool safely and effectively.

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 parameter context. It mentions 'starting at the specified row' (hinting at start_row) and 'one or more rows' (hinting at count), but doesn't explain filepath or sheet_name parameters. For 4 parameters with no schema descriptions, this is inadequate.

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 rows'), specifying the starting point ('starting at the specified row'). It distinguishes from sibling tools like 'delete_range' and 'delete_sheet_columns' by focusing specifically on rows, but doesn't explicitly differentiate from 'delete_worksheet' or other deletion 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?

No guidance is provided on when to use this tool versus alternatives like 'delete_range', 'delete_sheet_columns', or 'delete_worksheet'. The description only states what the tool does, not when it's appropriate or what prerequisites might be needed.

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