Skip to main content
Glama
samhavens

Databricks MCP Server

by samhavens

list_volume_files

List files and directories in a Databricks Unity Catalog volume to view file names, sizes, and modification times for dataset management.

Instructions

List files and directories in a Unity Catalog volume.

Args:
    volume_path: Volume path to list (e.g. '/Volumes/catalog/schema/volume/directory')

Returns:
    JSON with directory listing including file names, sizes, and modification times.
    
Example:
    # List files in volume directory
    files = list_volume_files('/Volumes/kbqa/stark_mas_eval/stark_raw_data/')
    
Note: Returns detailed file information including sizes for managing large datasets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
volume_pathYes

Implementation Reference

  • MCP tool registration and handler for 'list_volume_files'. Uses @mcp.tool() decorator. Includes tool description/docstring that serves as schema. Delegates to volumes.list_volume_files for core logic.
    @mcp.tool()
    async def list_volume_files(volume_path: str) -> str:
        """
        List files and directories in a Unity Catalog volume.
    
        Args:
            volume_path: Volume path to list (e.g. '/Volumes/catalog/schema/volume/directory')
    
        Returns:
            JSON with directory listing including file names, sizes, and modification times.
            
        Example:
            # List files in volume directory
            files = list_volume_files('/Volumes/kbqa/stark_mas_eval/stark_raw_data/')
            
        Note: Returns detailed file information including sizes for managing large datasets.
        """
        logger.info(f"Listing volume files in: {volume_path}")
        try:
            result = volumes.list_volume_files(volume_path)
            return json.dumps(result)
        except Exception as e:
            logger.error(f"Error listing volume files: {str(e)}")
            return json.dumps({"error": str(e)})
  • Core helper function implementing the volume file listing logic using Databricks SDK WorkspaceClient.files.list_directory_contents.
    def list_volume_files(volume_path: str) -> Dict[str, Any]:
        """
        List files and directories in a Unity Catalog volume.
        
        Args:
            volume_path: Volume path to list (e.g. '/Volumes/catalog/schema/volume/directory')
            
        Returns:
            Response containing the directory listing with files and subdirectories
            
        Raises:
            Exception: If the SDK request fails
        """
        logger.info(f"Listing volume files in: {volume_path}")
        
        try:
            w = _get_workspace_client()
            
            # List directory contents using SDK
            files = w.files.list_directory_contents(directory_path=volume_path)
            
            # Convert to dict format similar to REST API response
            file_list = []
            for file_info in files:
                file_list.append({
                    "path": file_info.path,
                    "is_directory": file_info.is_directory,
                    "file_size": file_info.file_size,
                    "last_modified": file_info.last_modified
                })
            
            return {
                "files": file_list,
                "path": volume_path
            }
            
        except Exception as e:
            logger.error(f"Error listing volume files: {str(e)}")
            return {"error": str(e)}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns detailed file information (names, sizes, modification times) and mentions it's useful for managing large datasets, which adds context about output format and scale. However, it doesn't cover potential limitations like pagination, error conditions, or authentication requirements, leaving gaps for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for Args, Returns, Example, and Note, making it easy to scan. It's appropriately sized with no redundant sentences, though the Note slightly overlaps with Returns. Every sentence adds value, such as clarifying the JSON output format and dataset management context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no annotations, no output schema), the description is reasonably complete. It covers purpose, parameter semantics, return format, and an example. However, it lacks details on error handling or performance considerations, which could be useful for a file-listing tool in large datasets.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must fully compensate. It clearly explains the single parameter 'volume_path' with a definition, example format, and usage in the example code. This adds essential meaning beyond the bare schema, making the parameter's purpose and format understandable.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('List files and directories') and resource ('in a Unity Catalog volume'), distinguishing it from siblings like 'list_files' (likely for different storage) and 'upload_file_to_volume' (a write operation). The verb+resource combination is precise and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing volume contents but provides no explicit guidance on when to use this tool versus alternatives like 'list_files' (which might list different storage locations) or 'upload_file_to_volume' (for writing). The example shows a typical use case but lacks comparative context or exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/samhavens/databricks-mcp-server'

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