Skip to main content
Glama

delete_row

Remove a specific row from CSV data while preserving deleted information for potential restoration. This tool tracks changes and provides operation statistics for data management.

Instructions

Delete row at specified index with comprehensive tracking.

Captures deleted data for undo operations. Returns operation result with before/after statistics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
row_indexYesRow index (0-based) to delete

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
successNoWhether operation completed successfully
operationNoOperation type identifierdelete_row
row_indexYesIndex of deleted row
rows_afterYesRow count after deletion
rows_beforeYesRow count before deletion
deleted_dataYesData from the deleted row

Implementation Reference

  • The core handler function implementing the delete_row tool. It validates the row index, captures the deleted row's data, removes the row from the DataFrame, updates the session, and returns a detailed result.
    def delete_row(
        ctx: Annotated[Context, Field(description="FastMCP context for session access")],
        row_index: Annotated[int, Field(description="Row index (0-based) to delete")],
    ) -> DeleteRowResult:
        """Delete row at specified index with comprehensive tracking.
    
        Captures deleted data for undo operations. Returns operation result with before/after
        statistics.
        """
        session_id = ctx.session_id
        session, df = get_session_data(session_id)
        rows_before = len(df)
    
        # 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)
    
        # Get the data that will be deleted for tracking
        deleted_data = df.iloc[row_index].to_dict()
    
        # Handle pandas/numpy types for JSON serialization
        for key, value in deleted_data.items():
            if pd.isna(value):
                deleted_data[key] = None
            elif hasattr(value, "item"):  # numpy scalar
                deleted_data[key] = value.item()
    
        # Delete the row
        df_new = df.drop(df.index[row_index]).reset_index(drop=True)
    
        # Update session data
        session.df = df_new
    
        # No longer recording operations (simplified MCP architecture)
    
        return DeleteRowResult(
            row_index=row_index,
            rows_before=rows_before,
            rows_after=len(df_new),
            deleted_data=deleted_data,
        )
  • Pydantic model defining the output schema and structure for the delete_row tool response.
    class DeleteRowResult(BaseToolResponse):
        """Response model for row deletion operations."""
    
        operation: str = Field(default="delete_row", description="Operation type identifier")
        row_index: int = Field(description="Index of deleted row")
        rows_before: int = Field(description="Row count before deletion")
        rows_after: int = Field(description="Row count after deletion")
        deleted_data: dict[str, CsvCellValue] = Field(description="Data from the deleted row")
  • Registers the delete_row function as an MCP tool with the name 'delete_row' on the row_operations_server.
    row_operations_server.tool(name="delete_row")(delete_row)
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively adds context beyond basic deletion by mentioning 'comprehensive tracking', 'captures deleted data for undo operations', and 'returns operation result with before/after statistics'. This covers key behavioral traits like data recovery and result format, though it could detail error handling or side effects.

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 efficiently structured in three sentences, each adding value: the first states the core action, the second explains tracking for undo, and the third specifies the return format. There is no wasted text, and information is front-loaded with the primary purpose, making it highly concise and well-organized.

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 a destructive operation with no annotations but an output schema (implied by 'Has output schema: true'), the description is reasonably complete. It covers the action, tracking for undo, and return statistics, which compensates for missing annotation details. However, it could improve by addressing potential errors or dependencies, though the output schema may handle return values.

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 'row_index' clearly documented as 'Row index (0-based) to delete'. The description adds no additional parameter semantics beyond this, such as valid ranges or constraints. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema handles the heavy lifting.

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 verb 'Delete' and resource 'row at specified index', making the purpose unambiguous. It distinguishes from siblings like 'remove_columns' or 'remove_duplicates' by focusing on a single row deletion. However, it doesn't explicitly differentiate from 'update_row' which might also modify rows, leaving slight room for improvement.

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 like 'remove_columns' or 'filter_rows'. It mentions 'undo operations' but doesn't specify prerequisites or exclusions, such as whether it requires specific permissions or data states. This lack of contextual direction leaves the agent to infer usage scenarios.

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