Skip to main content
Glama
marekrost

mcp-server-spreadsheet

delete_rows

Remove specified rows from a spreadsheet file to clean up data or reorganize content, shifting remaining rows upward automatically.

Instructions

Delete one or more rows, shifting remaining rows up.

All data in the deleted rows is permanently removed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the spreadsheet file
rowYes1-based index of the first row to delete
countNoNumber of consecutive rows to delete starting from row
sheetNoSheet name. Defaults to the first sheet if omitted.

Implementation Reference

  • The 'delete_rows' MCP tool handler, which loads the workbook, resolves the sheet, calls 'delete_rows' on the worksheet, and saves the file.
    @mcp.tool()
    def delete_rows(
        file: Annotated[str, Field(description="Path to the spreadsheet file")],
        row: Annotated[int, Field(description="1-based index of the first row to delete")],
        count: Annotated[int, Field(description="Number of consecutive rows to delete starting from row")] = 1,
        sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None,
    ) -> str:
        """Delete one or more rows, shifting remaining rows up.
    
        All data in the deleted rows is permanently removed.
        """
        wb = load_workbook(file)
        ws = _resolve_sheet(wb, sheet)
        ws.delete_rows(row, count)
        wb.save(file)
        return f"Deleted {count} rows starting at row {row}"

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/marekrost/mcp-server-spreadsheet'

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