write_cell
Write a value to a specific spreadsheet cell, automatically converting numeric strings to numbers and text to strings.
Instructions
Write a single value to a cell.
Overwrites any existing value. The value is type-coerced: numeric strings become numbers, all else is text.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| cell | Yes | Target cell in A1 notation, e.g. 'B3' | |
| value | Yes | Value to write. Numeric strings are coerced to numbers, everything else is stored as text. | |
| sheet | No | Sheet name. Defaults to the first sheet if omitted. |
Implementation Reference
- The implementation of the write_cell tool, which updates a specific cell in a spreadsheet file.
def write_cell( file: Annotated[str, Field(description="Path to the spreadsheet file")], cell: Annotated[str, Field(description="Target cell in A1 notation, e.g. 'B3'")], value: Annotated[object, Field(description="Value to write. Numeric strings are coerced to numbers, everything else is stored as text.")], sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None, ) -> str: """Write a single value to a cell. Overwrites any existing value. The value is type-coerced: numeric strings become numbers, all else is text. """ wb = load_workbook(file) ws = _resolve_sheet(wb, sheet) row, col = parse_cell(cell) ws.set_cell(row, col, coerce_value(value)) wb.save(file) return f"Wrote to {cell}" - src/mcp_server_spreadsheet/server.py:277-277 (registration)Registration of the write_cell tool using the @mcp.tool() decorator.
@mcp.tool()