Skip to main content
Glama

get_cell_value

Retrieve specific cell values from CSV data using row and column coordinates. Supports column names or indexes and returns value with position and data type information for data analysis workflows.

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
NameRequiredDescriptionDefault
row_indexYesRow index (0-based) to retrieve cell from
columnYesColumn name or column index (0-based) to retrieve

Implementation Reference

  • The core handler function that executes the get_cell_value tool logic: validates inputs, retrieves cell from DataFrame using iloc, handles NaN and numpy scalars, extracts data type, and returns structured 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, )
  • Pydantic BaseModel defining the output schema for the get_cell_value tool response, including the cell value, coordinates, and column 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")
  • Registers the get_cell_value handler function as an MCP tool named 'get_cell_value' on the FastMCP row_operations_server instance.
    row_operations_server.tool(name="get_cell_value")(get_cell_value)

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/jonpspri/databeak'

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