Skip to main content
Glama

strip_column

Remove whitespace or specific 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)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
successNoWhether operation completed successfully
operationYesType of operation performed
transformNoTransform description
part_indexNoPart index for split operations
nulls_filledNoNumber of null values filled
rows_removedNoNumber of rows removed (for remove_duplicates)
rows_affectedYesNumber of rows affected by operation
values_filledNoNumber of values filled (for fill_missing_values)
updated_sampleNoSample values after operation
original_sampleNoSample values before operation
columns_affectedYesNames of columns affected

Implementation Reference

  • The handler function that executes the strip_column tool logic: strips leading/trailing whitespace or specified characters from all values in the given column of the session's dataframe, using pandas str.strip(), and returns a ColumnOperationResult with details on changes made.
    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 as a tool named 'strip_column' on the FastMCP server instance 'column_text_server'.
    column_text_server.tool(name="strip_column")(strip_column)
  • Pydantic-style type annotations with Field descriptions define the input schema for the tool: ctx (Context), column (str), optional chars (str|None). Output is ColumnOperationResult.
    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:
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by specifying the tool returns a 'ColumnOperationResult with strip details', indicating structured output. It clarifies that stripping applies to 'leading/trailing whitespace' by default and can target 'specific characters', though it doesn't cover error handling, performance, or side effects on the dataset.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by a concise returns statement and practical examples that earn their place by demonstrating common use cases. No redundant or verbose sentences; it efficiently communicates key information in a structured format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, 100% schema coverage, output schema present), the description is mostly complete. It covers purpose, output type, and usage examples, but could improve by mentioning sibling tool distinctions or potential impacts on data integrity, though the output schema reduces the need for detailed return value explanations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds minimal value beyond the schema by illustrating parameter usage in examples (e.g., 'phone', '()' for chars), but doesn't explain semantics like character set handling or edge cases beyond what the schema's descriptions already provide.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('strip whitespace or specified characters') and target resource ('from column values'), distinguishing it from siblings like 'replace_in_column' or 'transform_column_case' which perform different transformations. It precisely defines the operation without being tautological.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through examples (e.g., cleaning currency values, removing quotes) but lacks explicit guidance on when to choose this tool over alternatives like 'replace_in_column' for character substitution or 'transform_column_case' for case changes. No when-not-to-use scenarios or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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