get_cell_value
Retrieve specific cell values from CSV data using row and column coordinates, returning data with type information for analysis.
Instructions
Get value of specific cell with coordinate targeting.
Supports column name or index targeting. Returns value with coordinates and data type information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| row_index | Yes | Row index (0-based) to retrieve cell from | |
| column | Yes | Column name or column index (0-based) to retrieve |
Implementation Reference
- The handler function that executes the get_cell_value tool logic: retrieves cell value from DataFrame, validates indices, handles column name/index, converts pandas types, returns CellValueResult.def get_cell_value( ctx: Annotated[Context, Field(description="FastMCP context for session access")], row_index: Annotated[int, Field(description="Row index (0-based) to retrieve cell from")], column: Annotated[ str | int, Field(description="Column name or column index (0-based) to retrieve"), ], ) -> CellValueResult: """Get value of specific cell with coordinate targeting. Supports column name or index targeting. Returns value with coordinates and data type information. """ session_id = ctx.session_id _session, df = get_session_data(session_id) # Validate row index if row_index < 0 or row_index >= len(df): msg = f"Row index {row_index} out of range (0-{len(df) - 1})" raise ToolError(msg) # Handle column specification if isinstance(column, int): # Column index if column < 0 or column >= len(df.columns): msg = f"Column index {column} out of range (0-{len(df.columns) - 1})" raise ToolError(msg) column_name = df.columns[column] else: # Column name if column not in df.columns: raise ColumnNotFoundError(column, list(df.columns)) column_name = column # Get the cell value value = df.iloc[row_index, df.columns.get_loc(column_name)] # type: ignore[index] # Handle pandas/numpy types for JSON serialization if pd.isna(value): value = None elif hasattr(value, "item"): # numpy scalar value = value.item() # type: ignore[assignment] # Get column data type data_type = str(df[column_name].dtype) # No longer recording operations (simplified MCP architecture) return CellValueResult( value=value, coordinates={"row": row_index, "column": column_name}, data_type=data_type, )
- src/databeak/servers/row_operations_server.py:645-645 (registration)Registers the get_cell_value function as a tool with name 'get_cell_value' on the FastMCP row_operations_server instance.row_operations_server.tool(name="get_cell_value")(get_cell_value)
- Pydantic model for the output response of the get_cell_value tool, including value, coordinates, and data_type.class CellValueResult(BaseToolResponse): """Response model for cell value operations.""" value: str | int | float | bool | None = Field(description="Cell value (None if null/missing)") coordinates: dict[str, str | int] = Field( description="Cell coordinates with row index and column name", ) data_type: str = Field(description="Pandas data type of the column")