get_info
Retrieve file metadata and structure details for CSV files, including column information and data format specifications.
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
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes |
Implementation Reference
- csv_mcp_server/server.py:146-160 (handler)MCP tool handler for get_info, registered via @mcp.tool() decorator. Handles input validation implicitly via type hints and delegates execution to CSVManager.get_info() with error handling.@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 helper function in CSVManager that implements the get_info logic: loads CSV with pandas, computes metadata (rows, columns, names, dtypes, file stats), returns structured dict.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