list_files
Retrieve a list of files and directories within a specified DBFS path on Databricks MCP Server to manage and access Databricks resources efficiently.
Instructions
List files and directories in a DBFS path with parameter: dbfs_path (required)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- src/server/databricks_mcp_server.py:179-182 (registration)Registration of the 'list_files' tool using the FastMCP decorator, specifying name and description (implicit schema).@self.tool( name="list_files", description="List files and directories in a DBFS path with parameter: dbfs_path (required)", )
- The MCP tool handler function that processes params, calls the dbfs helper, and returns TextContent.async def list_files(params: Dict[str, Any]) -> List[TextContent]: logger.info(f"Listing files with params: {params}") try: result = await dbfs.list_files(params.get("dbfs_path")) return [{"text": json.dumps(result)}] except Exception as e: logger.error(f"Error listing files: {str(e)}") return [{"text": json.dumps({"error": str(e)})}]
- src/api/dbfs.py:177-191 (helper)Core helper function implementing the DBFS list API call via make_api_request.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})