Skip to main content
Glama

strip_column

Remove whitespace or specified characters from column values in CSV data to clean and standardize text fields for analysis.

Instructions

Strip whitespace or specified characters from column values.

Returns: ColumnOperationResult with strip details

Examples: # Remove leading/trailing whitespace strip_column(ctx, "name")

# Remove specific characters strip_column(ctx, "phone", "()") # Clean currency values strip_column(ctx, "price", "$,") # Remove quotes strip_column(ctx, "quoted_text", "'\"")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnYesColumn name to strip characters from
charsNoCharacters to strip (None for whitespace, string for specific chars)

Implementation Reference

  • The core handler function for the 'strip_column' tool. It strips leading and trailing whitespace or specified characters from all values in the given column of the current session's dataframe, updates the dataframe in place, and returns a result indicating the number of rows affected.
    async def strip_column( ctx: Annotated[Context, Field(description="FastMCP context for session access")], column: Annotated[str, Field(description="Column name to strip characters from")], chars: Annotated[ str | None, Field(description="Characters to strip (None for whitespace, string for specific chars)"), ] = None, ) -> ColumnOperationResult: r"""Strip whitespace or specified characters from column values. Returns: ColumnOperationResult with strip details Examples: # Remove leading/trailing whitespace strip_column(ctx, "name") # Remove specific characters strip_column(ctx, "phone", "()") # Clean currency values strip_column(ctx, "price", "$,") # Remove quotes strip_column(ctx, "quoted_text", "'\"") """ # Get session_id from FastMCP context session_id = ctx.session_id _session, df = get_session_data(session_id) _validate_column_exists(column, df) # Store original for comparison original_data = df[column].copy() # Apply strip operation if chars is None: # Strip whitespace df[column] = df[column].astype(str).str.strip() else: # Strip specified characters df[column] = df[column].astype(str).str.strip(chars) # Count changes made changes_made = _count_column_changes(original_data, df[column]) return ColumnOperationResult( operation=f"strip_{'whitespace' if chars is None else 'chars'}", rows_affected=changes_made, columns_affected=[column], )
  • Registers the strip_column handler function as an MCP tool named 'strip_column' on the column_text_server FastMCP instance.
    column_text_server.tool(name="strip_column")(strip_column)
  • Pydantic schema for the strip_column tool inputs and output defined via Annotated types and Field descriptions in the function signature.
    async def strip_column( ctx: Annotated[Context, Field(description="FastMCP context for session access")], column: Annotated[str, Field(description="Column name to strip characters from")], chars: Annotated[ str | None, Field(description="Characters to strip (None for whitespace, string for specific chars)"), ] = None, ) -> ColumnOperationResult:

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