Skip to main content
Glama

remove_columns

Remove specified columns from a dataframe to clean data, reduce clutter, or prepare datasets for analysis by eliminating unnecessary fields.

Instructions

Remove columns from the dataframe.

Returns: ColumnOperationResult with removal details

Examples: # Remove single column remove_columns(ctx, ["temp_column"])

# Remove multiple columns
remove_columns(ctx, ["col1", "col2", "col3"])

# Clean up after analysis
remove_columns(ctx, ["_temp", "_backup", "old_value"])

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnsYesList of column names to remove from the dataframe

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 core handler function implementing the remove_columns tool. Validates column existence, drops the specified columns from the session's dataframe, and returns a ColumnOperationResult with operation details.
    async def remove_columns(
        ctx: Annotated[Context, Field(description="FastMCP context for session access")],
        columns: Annotated[
            list[str],
            Field(description="List of column names to remove from the dataframe"),
        ],
    ) -> ColumnOperationResult:
        """Remove columns from the dataframe.
    
        Returns:
            ColumnOperationResult with removal details
    
        Examples:
            # Remove single column
            remove_columns(ctx, ["temp_column"])
    
            # Remove multiple columns
            remove_columns(ctx, ["col1", "col2", "col3"])
    
            # Clean up after analysis
            remove_columns(ctx, ["_temp", "_backup", "old_value"])
    
        """
        # Get session_id from FastMCP context
        session_id = ctx.session_id
        session, df = get_session_data(session_id)
    
        # Validate columns exist
        missing_cols = [col for col in columns if col not in df.columns]
        if missing_cols:
            raise ColumnNotFoundError(str(missing_cols[0]), df.columns.tolist())
    
        session.df = df.drop(columns=columns)
        # No longer recording operations (simplified MCP architecture)
    
        return ColumnOperationResult(
            operation="remove",
            rows_affected=len(df),
            columns_affected=columns,
        )
  • Registers the remove_columns handler as an MCP tool on the column_server FastMCP instance, specifying the tool name.
    column_server.tool(name="remove_columns")(remove_columns)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool removes columns and returns a 'ColumnOperationResult with removal details,' which gives some behavioral insight. However, it lacks critical details: it doesn't specify if the removal is permanent or reversible, mention error handling for non-existent columns, or describe the format of the result details. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is well-structured and appropriately sized. It starts with a clear purpose statement, followed by return details and examples. The examples are relevant and demonstrate common use cases without unnecessary elaboration. There is no wasted text, and the information is front-loaded, making it easy to understand quickly.

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

Completeness3/5

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

Given the tool's complexity (a mutation operation with one parameter) and the presence of an output schema (implied by 'Has output schema: true'), the description is moderately complete. It covers the basic purpose and provides examples, but lacks behavioral details like error handling or permanence of changes. The output schema likely documents the 'ColumnOperationResult,' reducing the need for return value explanation, but the description could benefit from more context on usage and alternatives.

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?

The input schema has 100% description coverage, with the 'columns' parameter clearly documented as 'List of column names to remove from the dataframe.' The description adds minimal value beyond this, as it doesn't provide additional semantics like constraints or examples of valid column names. However, the examples illustrate usage with single and multiple columns, offering some practical context. Given the high schema coverage, a baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Remove columns from the dataframe.' It specifies the verb ('Remove') and resource ('columns from the dataframe'), making the action explicit. However, it doesn't explicitly differentiate from sibling tools like 'rename_columns' or 'select_columns', which also manipulate columns but serve different purposes.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It includes examples but doesn't mention when to choose this over sibling tools like 'rename_columns' or 'select_columns', nor does it discuss prerequisites or exclusions. The examples imply cleanup scenarios, but this is not stated as explicit usage advice.

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