list_csv_files
Browse and identify CSV files stored in your directory with their metadata to quickly locate and access your data files.
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 executes the list_csv_files logic by delegating to 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 path using glob, collecting metadata for each file.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