Skip to main content
Glama

list_files

Browse and view files and directories stored in DBFS paths to manage Databricks data resources.

Instructions

List files and directories in a DBFS path with parameter: dbfs_path (required)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • MCP tool handler for 'list_files' that extracts dbfs_path from params, calls the dbfs.list_files helper, and returns JSON-formatted result as 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)})}]
  • Registers the 'list_files' tool using the FastMCP @tool decorator with name and description specifying the required dbfs_path parameter.
    @self.tool( name="list_files", description="List files and directories in a DBFS path with parameter: dbfs_path (required)", )
  • Core helper function that performs the actual Databricks DBFS /list API request to retrieve files and directories at the given path.
    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})

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JustTryAI/databricks-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server