Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

remove_row

Delete a specific row from a CSV file by specifying its zero-based index to manage and clean your data.

Instructions

Remove a specific row from the CSV file.

Args:
    filename: Name of the CSV file
    row_index: Zero-based index of the row to remove

Returns:
    Dictionary with removal results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
row_indexYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'remove_row', registered via @mcp.tool() decorator. Delegates execution to CSVManager instance and handles exceptions.
    @mcp.tool()
    def remove_row(filename: str, row_index: int) -> Dict[str, Any]:
        """
        Remove a specific row from the CSV file.
        
        Args:
            filename: Name of the CSV file
            row_index: Zero-based index of the row to remove
        
        Returns:
            Dictionary with removal results
        """
        try:
            return csv_manager.remove_row(filename, row_index)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core implementation of row removal logic in CSVManager class: validates file, creates backup, loads DataFrame with pandas, drops the specified row, saves back to CSV, returns success info with removed row data.
    def remove_row(self, filename: str, row_index: int) -> Dict[str, Any]:
        """Remove a specific row from the CSV file."""
        filepath = self._get_file_path(filename)
        
        if not filepath.exists():
            raise FileNotFoundError(f"CSV file '{filename}' not found")
        
        # Create backup
        self._create_backup(filepath)
        
        try:
            df = pd.read_csv(filepath)
            
            if row_index >= len(df):
                raise IndexError(f"Row index {row_index} out of range (max: {len(df)-1})")
            
            removed_row = df.iloc[row_index].to_dict()
            df = df.drop(df.index[row_index])
            
            df.to_csv(filepath, index=False)
            
            logger.info(f"Removed row from CSV file: {filepath}")
            return {
                "success": True,
                "filename": filename,
                "removed_row": removed_row,
                "new_total_rows": len(df)
            }
        except Exception as e:
            logger.error(f"Failed to remove row: {e}")
            raise
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 a row and returns a dictionary with results, but lacks details on permissions needed, whether changes are permanent or reversible, error handling (e.g., invalid index), or rate limits. For a destructive operation with zero annotation coverage, this is inadequate.

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 well-structured and front-loaded with the core purpose, followed by clear sections for Args and Returns. Every sentence earns its place with no wasted words, making it efficient and easy to parse.

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 (destructive operation with 2 parameters), no annotations, and an output schema present (which handles return values), the description is minimally adequate. It covers basic purpose and parameters but lacks behavioral context like safety warnings or usage guidelines, leaving the agent with incomplete information for reliable invocation.

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 0%, so the description must compensate. It adds semantic meaning by explaining 'row_index' as 'zero-based index of the row to remove' and 'filename' as 'Name of the CSV file', which clarifies beyond the bare schema. However, it doesn't cover constraints (e.g., file must exist, index bounds) or formats, leaving gaps.

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 with a specific verb ('Remove') and resource ('row from the CSV file'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'delete_csv' (which deletes entire files) or 'filter_data' (which might exclude rows without removing them), missing full sibling distinction.

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. With siblings like 'delete_csv' (for entire file deletion) and 'filter_data' (for data manipulation), the agent lacks explicit direction on appropriate contexts, prerequisites, or exclusions for row removal.

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/NovaAI-innovation/csv-mcp-server'

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