Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

add_row

Add a new row of data to a CSV file by specifying column names and values. This tool inserts records into CSV files for data management.

Instructions

Add a new row to the CSV file.

Args:
    filename: Name of the CSV file
    row_data: Dictionary mapping column names to values

Returns:
    Dictionary with addition results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
row_dataYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'add_row': decorated with @mcp.tool(), defines input schema via type hints and docstring, delegates execution to CSVManager.add_row with error handling.
    @mcp.tool()
    def add_row(filename: str, row_data: Dict[str, Any]) -> Dict[str, Any]:
        """
        Add a new row to the CSV file.
        
        Args:
            filename: Name of the CSV file
            row_data: Dictionary mapping column names to values
        
        Returns:
            Dictionary with addition results
        """
        try:
            return csv_manager.add_row(filename, row_data)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core logic implementation in CSVManager.add_row: loads CSV with pandas, creates new row from dict, appends it, saves with backup and size validation.
    def add_row(self, filename: str, row_data: Dict[str, Any]) -> Dict[str, Any]:
        """Add a new row to 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)
            
            # Create new row DataFrame
            new_row = pd.DataFrame([row_data])
            
            # Append the new row
            df = pd.concat([df, new_row], ignore_index=True)
            
            df.to_csv(filepath, index=False)
            self._validate_file_size(filepath)
            
            logger.info(f"Added row to CSV file: {filepath}")
            return {
                "success": True,
                "filename": filename,
                "row_added": row_data,
                "new_total_rows": len(df)
            }
        except Exception as e:
            logger.error(f"Failed to add row: {e}")
            raise
  • Registration of the 'add_row' tool via FastMCP @mcp.tool() decorator.
    @mcp.tool()
  • Input schema defined by function signature: filename (str), row_data (Dict[str, Any]); output Dict[str, Any].
    def add_row(filename: str, row_data: Dict[str, Any]) -> Dict[str, Any]:
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. It states the action ('Add a new row') and return type ('Dictionary with addition results'), but lacks critical behavioral details: whether this modifies files in-place, requires specific permissions, handles errors (e.g., missing files or invalid data), or has side effects like appending versus inserting.

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 appropriately sized and front-loaded, with the core purpose stated first. The Args and Returns sections are structured for clarity, though the 'Returns' line is somewhat vague ('Dictionary with addition results'). No wasted sentences, but minor room for improvement in specificity.

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 2 parameters with 0% schema coverage, an output schema exists (which helps), and no annotations, the description is minimally adequate. It covers the basic action and parameters but lacks context on file handling, error behavior, or sibling differentiation, making it incomplete for safe and effective use.

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 explains 'filename' as 'Name of the CSV file' and 'row_data' as 'Dictionary mapping column names to values', adding basic meaning beyond the schema's generic titles. However, it doesn't clarify constraints (e.g., file format, data types) or examples, leaving gaps in understanding.

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: 'Add a new row to the CSV file.' This specifies the verb ('Add') and resource ('CSV file'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'create_csv' or 'update_csv', 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 siblings like 'create_csv' (for creating new files) and 'update_csv' (which might modify existing rows), there's no indication of when 'add_row' is appropriate versus those tools or prerequisites like file existence.

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