Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

validate_data

Check CSV data integrity and format to identify issues and warnings for reliable analysis.

Instructions

Validate CSV data integrity and format.

Args:
    filename: Name of the CSV file

Returns:
    Dictionary with validation results, issues, and warnings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'validate_data'. Registers the tool and delegates execution to CSVManager's validate_data method, handling exceptions.
    @mcp.tool()
    def validate_data(filename: str) -> Dict[str, Any]:
        """
        Validate CSV data integrity and format.
        
        Args:
            filename: Name of the CSV file
        
        Returns:
            Dictionary with validation results, issues, and warnings
        """
        try:
            return csv_manager.validate_data(filename)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core implementation of the validate_data functionality in CSVManager class. Performs comprehensive validation including checks for empty rows, duplicates, missing values, mixed data types, and long text values.
    def validate_data(self, filename: str) -> Dict[str, Any]:
        """Validate CSV data integrity and format."""
        filepath = self._get_file_path(filename)
        
        if not filepath.exists():
            raise FileNotFoundError(f"CSV file '{filename}' not found")
        
        try:
            df = pd.read_csv(filepath)
            
            validation_results = {
                "success": True,
                "filename": filename,
                "total_rows": len(df),
                "total_columns": len(df.columns),
                "issues": [],
                "warnings": []
            }
            
            # Check for empty rows
            empty_rows = df.isnull().all(axis=1).sum()
            if empty_rows > 0:
                validation_results["issues"].append(f"Found {empty_rows} completely empty rows")
            
            # Check for duplicate rows
            duplicate_rows = df.duplicated().sum()
            if duplicate_rows > 0:
                validation_results["warnings"].append(f"Found {duplicate_rows} duplicate rows")
            
            # Check for missing values by column
            null_counts = df.isnull().sum()
            for col, null_count in null_counts.items():
                if null_count > 0:
                    percentage = (null_count / len(df)) * 100
                    validation_results["warnings"].append(f"Column '{col}' has {null_count} missing values ({percentage:.1f}%)")
            
            # Check for columns with mixed data types (if possible)
            for col in df.columns:
                if df[col].dtype == 'object':
                    # Try to detect mixed numeric/text data
                    numeric_count = pd.to_numeric(df[col], errors='coerce').notna().sum()
                    if 0 < numeric_count < len(df):
                        validation_results["warnings"].append(f"Column '{col}' appears to have mixed data types")
            
            # Check for unusually long text values
            for col in df.select_dtypes(include=['object']).columns:
                max_length = df[col].astype(str).str.len().max()
                if max_length > 1000:
                    validation_results["warnings"].append(f"Column '{col}' has very long text values (max: {max_length} characters)")
            
            validation_results["is_valid"] = len(validation_results["issues"]) == 0
            
            return validation_results
        except Exception as e:
            logger.error(f"Failed to validate data: {e}")
            raise
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions validation of 'integrity and format', it doesn't specify what constitutes validation failures, whether the tool modifies the file, what permissions are required, or how warnings differ from issues. For a validation tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Each sentence serves a distinct purpose without redundancy. However, the 'Args' and 'Returns' labels are somewhat redundant with the structured schema fields, and the description could be slightly more front-loaded with the most critical information.

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 (validation operation), no annotations, and the presence of an output schema (which handles return value documentation), the description is minimally adequate. It covers the basic purpose and parameters but lacks important context about validation criteria, error handling, and usage scenarios. The output schema existence prevents this from being a complete failure, but more behavioral context would be helpful.

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 explicitly documents the single parameter ('filename: Name of the CSV file'), which is valuable since schema description coverage is 0%. While it doesn't elaborate on format requirements (e.g., path inclusion, file extensions), it provides the essential semantic meaning. With only one parameter, the description adequately compensates for the schema's lack of descriptions.

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 as 'Validate CSV data integrity and format' - a specific verb (validate) applied to a specific resource (CSV data). It distinguishes itself from sibling tools like 'read_csv' or 'filter_data' by focusing on validation rather than data manipulation or retrieval. However, it doesn't explicitly differentiate from all siblings (e.g., 'get_statistics' might also involve data analysis).

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 'read_csv', 'filter_data', and 'get_statistics' available, there's no indication whether validation should precede or follow these operations, or when validation is specifically needed. The description only states what the tool does, not when it should be used.

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