Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

create_csv

Create CSV files with headers and optional initial data for structured data storage and management.

Instructions

Create a new CSV file with headers and optional initial data.

Args:
    filename: Name of the CSV file to create (without .csv extension)
    headers: List of column headers
    data: Optional list of rows, where each row is a list of values

Returns:
    Dictionary with creation results and file information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
headersYes
dataNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function for 'create_csv', registered via @mcp.tool() decorator. Defines input schema via type annotations and delegates execution to CSVManager.create_csv.
    @mcp.tool()
    def create_csv(
        filename: str,
        headers: List[str],
        data: Optional[List[List[Any]]] = None
    ) -> Dict[str, Any]:
        """
        Create a new CSV file with headers and optional initial data.
        
        Args:
            filename: Name of the CSV file to create (without .csv extension)
            headers: List of column headers
            data: Optional list of rows, where each row is a list of values
        
        Returns:
            Dictionary with creation results and file information
        """
        try:
            return csv_manager.create_csv(filename, headers, data)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core helper method in CSVManager class that implements the CSV file creation logic using pandas, including path validation, DataFrame creation, and file writing.
    def create_csv(self, filename: str, headers: List[str], data: Optional[List[List[Any]]] = None) -> Dict[str, Any]:
        """Create a new CSV file with headers and optional initial data."""
        filepath = self._get_file_path(filename)
        
        if filepath.exists():
            raise FileExistsError(f"CSV file '{filename}' already exists")
        
        try:
            # Ensure directory exists for absolute paths
            self._ensure_directory_exists(filepath)
            
            # Create DataFrame
            df = pd.DataFrame(columns=headers)
            if data:
                df = pd.DataFrame(data, columns=headers)
            
            # Save to CSV
            df.to_csv(filepath, index=False)
            self._validate_file_size(filepath)
            
            logger.info(f"Created CSV file: {filepath}")
            return {
                "success": True,
                "filename": filename,
                "filepath": str(filepath),
                "rows_created": len(df),
                "columns": headers
            }
        except Exception as e:
            logger.error(f"Failed to create CSV: {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 this creates a new file, implying a write operation, but doesn't mention permissions, file system location, overwrite behavior, error conditions, or rate limits. The return format is vaguely described as a 'Dictionary with creation results and file information', lacking specifics on structure or success 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 appropriately sized and front-loaded: the first sentence states the core purpose, followed by clear sections for Args and Returns. Each sentence earns its place, with no redundant information. The structure is logical, though the formatting with quotes and line breaks could be slightly cleaner.

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 (3 parameters, write operation) and the presence of an output schema (which handles return values), the description is partially complete. It covers the basic purpose and parameters but lacks behavioral details like error handling or file system implications. With no annotations, it should provide more context for a mutation tool.

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?

With 0% schema description coverage, the description compensates well by explaining all three parameters: 'filename' (name without .csv extension), 'headers' (list of column headers), and 'data' (optional list of rows). It adds meaningful context beyond the bare schema, clarifying the filename format and data structure. However, it doesn't detail constraints like filename length or header/data validation.

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: 'Create a new CSV file with headers and optional initial data.' It specifies the verb ('Create') and resource ('CSV file'), distinguishing it from siblings like 'read_csv' or 'update_csv'. However, it doesn't explicitly differentiate from 'create_csv_at_path', which appears to be a similar creation tool.

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_at_path', 'add_row', and 'update_csv', there's no indication of when this specific creation method is preferred, what prerequisites exist, or any exclusions. The usage context is implied but not stated.

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