append_rows
Add new rows to the end of a spreadsheet sheet. Use this tool to efficiently append data like [['Alice', 30], ['Bob', 25]] after the last used row.
Instructions
Append one or more rows after the last used row in the sheet.
Values are type-coerced (numeric strings to numbers). This is the most efficient way to add data to the end of a sheet.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| data | Yes | List of rows to append, e.g. [['Alice', 30], ['Bob', 25]]. Each inner list is one row. | |
| sheet | No | Sheet name. Defaults to the first sheet if omitted. |
Implementation Reference
- The implementation of the `append_rows` tool, which uses `@mcp.tool()` to register it and handles appending rows to a spreadsheet.
@mcp.tool() def append_rows( file: Annotated[str, Field(description="Path to the spreadsheet file")], data: Annotated[list[list], Field(description="List of rows to append, e.g. [['Alice', 30], ['Bob', 25]]. Each inner list is one row.")], sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None, ) -> str: """Append one or more rows after the last used row in the sheet. Values are type-coerced (numeric strings to numbers). This is the most efficient way to add data to the end of a sheet. """ wb = load_workbook(file) ws = _resolve_sheet(wb, sheet) for row in data: ws.append([coerce_value(v) for v in row]) wb.save(file) return f"Appended {len(data)} rows"