Skip to main content
Glama
NovaAI-innovation

CSV MCP Server

get_info

Retrieve metadata and structure details for CSV files to understand data organization and format before processing or analysis.

Instructions

Get basic information about a CSV file.

Args:
    filename: Name of the CSV file

Returns:
    Dictionary with file metadata and structure information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes

Implementation Reference

  • MCP tool handler for 'get_info' decorated with @mcp.tool(). Delegates to csv_manager.get_info and handles errors. Includes input/output schema via type hints and docstring.
    @mcp.tool()
    def get_info(filename: str) -> Dict[str, Any]:
        """
        Get basic information about a CSV file.
        
        Args:
            filename: Name of the CSV file
        
        Returns:
            Dictionary with file metadata and structure information
        """
        try:
            return csv_manager.get_info(filename)
        except Exception as e:
            return {"success": False, "error": str(e)}
  • Core logic implementation of get_info in CSVManager class. Reads CSV file using pandas and computes metadata including row count, column info, file stats, data types, and memory usage.
    def get_info(self, filename: str) -> Dict[str, Any]:
        """Get basic information about a CSV file."""
        filepath = self._get_file_path(filename)
        
        if not filepath.exists():
            raise FileNotFoundError(f"CSV file '{filename}' not found")
        
        try:
            df = pd.read_csv(filepath)
            file_stat = filepath.stat()
            
            return {
                "success": True,
                "filename": filename,
                "filepath": str(filepath),
                "size_bytes": file_stat.st_size,
                "size_mb": round(file_stat.st_size / (1024 * 1024), 2),
                "modified_time": datetime.fromtimestamp(file_stat.st_mtime).isoformat(),
                "rows": len(df),
                "columns": len(df.columns),
                "column_names": list(df.columns),
                "dtypes": {col: str(dtype) for col, dtype in df.dtypes.items()},
                "memory_usage": df.memory_usage(deep=True).sum()
            }
        except Exception as e:
            logger.error(f"Failed to get CSV info: {e}")
            raise

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