list_csv_files
Discover and access CSV files stored in your directory with metadata details for data management workflows.
Instructions
List all CSV files in the storage directory.
Returns:
Dictionary with list of CSV files and their metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- csv_mcp_server/server.py:288-299 (handler)MCP tool handler decorated with @mcp.tool() that handles the list_csv_files tool call by delegating to the CSVManager instance.@mcp.tool() def list_csv_files() -> Dict[str, Any]: """ List all CSV files in the storage directory. Returns: Dictionary with list of CSV files and their metadata """ try: return csv_manager.list_csv_files() except Exception as e: return {"success": False, "error": str(e)}
- Core helper method in CSVManager class that implements the logic to list all CSV files in the storage directory using glob, collects metadata, and returns structured results.def list_csv_files(self) -> Dict[str, Any]: """List all CSV files in the storage directory.""" try: csv_files = [] for filepath in self.storage_path.glob("*.csv"): if filepath.is_file(): stat = filepath.stat() csv_files.append({ "filename": filepath.name, "size_bytes": stat.st_size, "size_mb": round(stat.st_size / (1024 * 1024), 2), "modified_time": datetime.fromtimestamp(stat.st_mtime).isoformat() }) return { "success": True, "csv_files": csv_files, "total_files": len(csv_files), "storage_path": str(self.storage_path) } except Exception as e: logger.error(f"Failed to list CSV files: {e}") raise