Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

create_csv_at_path

Create a CSV file at a specified location with custom headers and optional data rows for structured data storage.

Instructions

Create a new CSV file at a specific path (absolute or relative).

Args:
    filepath: Full path where the CSV file should be created
    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
filepathYes
headersYes
dataNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main tool handler function for 'create_csv_at_path', decorated with @mcp.tool(). It delegates the core logic to CSVManager.create_csv while providing error handling and tool interface.
    @mcp.tool()
    def create_csv_at_path(
        filepath: str,
        headers: List[str],
        data: Optional[List[List[Any]]] = None
    ) -> Dict[str, Any]:
        """
        Create a new CSV file at a specific path (absolute or relative).
        
        Args:
            filepath: Full path where the CSV file should be created
            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(filepath, headers, data)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core implementation of CSV creation logic in CSVManager class. Handles path resolution (relative/absolute), directory creation, DataFrame setup, CSV writing, size validation, and returns detailed results.
    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?

With no annotations provided, the description carries full burden but lacks critical behavioral details. It doesn't disclose whether the tool overwrites existing files, requires specific permissions, handles errors, or has rate limits. The mention of 'absolute or relative' paths adds some context but is insufficient for a mutation tool.

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?

Front-loaded with the core purpose, followed by structured Args and Returns sections. Every sentence adds value: the first defines the tool, and the subsequent bullets clarify parameters and output without redundancy.

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 (file creation with data), lack of annotations, and presence of an output schema, the description is moderately complete. It covers parameters and return intent but misses behavioral aspects like overwriting rules or error handling, which are crucial for safe usage.

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 meaningful semantics for all three parameters beyond the 0% schema coverage: 'filepath' as the creation location, 'headers' as column headers, and 'data' as optional rows with value lists. This compensates well for the lack of schema descriptions, though it doesn't detail format constraints (e.g., CSV escaping).

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 action ('Create a new CSV file') and resource ('at a specific path'), distinguishing it from sibling tools like 'create_csv' (which likely has different parameters) and 'add_row' (which modifies existing files). However, it doesn't explicitly contrast with all siblings, such as 'update_csv'.

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?

No explicit guidance on when to use this tool versus alternatives like 'create_csv' or 'update_csv'. The description mentions path specification but doesn't provide context about prerequisites, file overwriting behavior, or comparisons to other creation/modification tools.

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