read_cell
Extract a single cell's value from spreadsheet files. Returns numbers as integers/floats, text as strings, and empty cells as null.
Instructions
Read the value of a single cell.
Returns the cell's value: numbers as int/float, text as string, and empty cells as null.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| cell | Yes | Cell reference in A1 notation, e.g. 'B3' or '$B$3' | |
| sheet | No | Sheet name. Defaults to the first sheet if omitted. |
Implementation Reference
- The implementation of the 'read_cell' tool, which uses 'load_workbook' and 'parse_cell' to retrieve a cell's value.
@mcp.tool() def read_cell( file: Annotated[str, Field(description="Path to the spreadsheet file")], cell: Annotated[str, Field(description="Cell reference in A1 notation, e.g. 'B3' or '$B$3'")], sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None, ): """Read the value of a single cell. Returns the cell's value: numbers as int/float, text as string, and empty cells as null. """ wb = load_workbook(file) ws = _resolve_sheet(wb, sheet) row, col = parse_cell(cell) return ws.cell_value(row, col)