Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

update_csv

Modify specific data points in CSV files by updating individual cells with new values, enabling precise data correction and maintenance.

Instructions

Update a specific cell in the CSV file.

Args:
    filename: Name of the CSV file to update
    row_index: Zero-based index of the row to update
    column: Name of the column to update
    value: New value for the cell

Returns:
    Dictionary with update results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
row_indexYes
columnYes
valueYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'update_csv'. Registers the tool and delegates execution to CSVManager.update_csv, with error handling. The function signature defines the input schema.
    @mcp.tool()
    def update_csv(
        filename: str,
        row_index: int,
        column: str,
        value: Any
    ) -> Dict[str, Any]:
        """
        Update a specific cell in the CSV file.
        
        Args:
            filename: Name of the CSV file to update
            row_index: Zero-based index of the row to update
            column: Name of the column to update
            value: New value for the cell
        
        Returns:
            Dictionary with update results
        """
        try:
            return csv_manager.update_csv(filename, row_index, column, value)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core implementation of CSV update logic in CSVManager class. Handles file path resolution, backup creation, pandas DataFrame loading, cell update, saving, validation, and returns detailed results.
    def update_csv(self, filename: str, row_index: int, column: str, value: Any) -> Dict[str, Any]:
        """Update a specific cell in 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})")
            
            if column not in df.columns:
                raise ValueError(f"Column '{column}' not found in CSV")
            
            old_value = df.loc[row_index, column]
            df.loc[row_index, column] = value
            
            df.to_csv(filepath, index=False)
            self._validate_file_size(filepath)
            
            logger.info(f"Updated CSV file: {filepath}")
            return {
                "success": True,
                "filename": filename,
                "row_index": row_index,
                "column": column,
                "old_value": old_value,
                "new_value": value
            }
        except Exception as e:
            logger.error(f"Failed to update CSV: {e}")
            raise
  • The @mcp.tool() decorator registers the update_csv function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'Update a specific cell' implies a mutation operation, the description doesn't address critical behavioral aspects: whether the file must exist, if updates are atomic or batched, error handling for invalid indices/columns, or permission requirements. The mention of 'Dictionary with update results' hints at a response format but lacks detail on success/failure indicators.

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 concise. It opens with the core purpose, then lists parameters with brief explanations, and concludes with return information. Every sentence adds value, with no redundant or vague phrasing. The bullet-point style for Args/Returns enhances readability without unnecessary verbosity.

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 moderate complexity (4 parameters, mutation operation) and lack of annotations, the description is partially complete. It covers parameters and hints at returns, but with an output schema present, the return value explanation is redundant. However, it misses behavioral context like prerequisites, side effects, or error conditions, which are crucial for a mutation tool without annotations.

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

Parameters4/5

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

The description provides clear semantic explanations for all four parameters in the 'Args' section, mapping each to its role in the update operation. With 0% schema description coverage (titles only, no descriptions), this compensates well by explaining what each parameter represents. However, it doesn't specify format constraints (e.g., filename extensions, column name case-sensitivity) or value type expectations beyond the schema.

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: 'Update a specific cell in the CSV file.' It specifies the verb ('update') and resource ('specific cell in CSV file'), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'add_row' or 'remove_row' that also modify CSV files, which prevents a perfect score.

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 sibling tools like 'add_row', 'remove_row', and 'update_csv' (if this is the only update tool), there's no indication of when cell-level updates are preferred over row-level operations or other CSV modifications. This lack of context leaves the agent without usage direction.

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