list_files
Browse and view files and directories in Databricks DBFS to manage data storage and access within the Databricks environment.
Instructions
List files and directories in DBFS
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dbfs_path | No | / |
Implementation Reference
- The MCP tool handler for 'list_files', registered via @mcp.tool() decorator. Calls the underlying dbfs.list_files helper and returns JSON response.
@mcp.tool() async def list_files(dbfs_path: str = "/") -> str: """List files and directories in DBFS""" logger.info(f"Listing files in: {dbfs_path}") try: result = await dbfs.list_files(dbfs_path) return json.dumps(result) except Exception as e: logger.error(f"Error listing files: {str(e)}") return json.dumps({"error": str(e)}) - src/api/dbfs.py:177-192 (helper)Supporting helper function in the DBFS API module that performs the actual Databricks API call to list files in DBFS.
async def list_files(dbfs_path: str) -> Dict[str, Any]: """ List files and directories in a DBFS path. Args: dbfs_path: The path to list Returns: Response containing the directory listing Raises: DatabricksAPIError: If the API request fails """ logger.info(f"Listing files in DBFS path: {dbfs_path}") return make_api_request("GET", "/api/2.0/dbfs/list", params={"path": dbfs_path})