Skip to main content
Glama
samhavens

Databricks MCP Server

by samhavens

export_notebook

Export notebooks from Databricks workspace in various formats for sharing, backup, or migration purposes.

Instructions

Export a notebook from the workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
formatNoJUPYTER

Implementation Reference

  • MCP tool handler for 'export_notebook', decorated with @mcp.tool(). Delegates to notebooks.export_notebook API, trims large content for readability, and returns JSON response.
    @mcp.tool()
    async def export_notebook(path: str, format: str = "JUPYTER") -> str:
        """Export a notebook from the workspace"""
        logger.info(f"Exporting notebook: {path} in format: {format}")
        try:
            result = await notebooks.export_notebook(path, format)
            
            # For notebooks, we might want to trim the response for readability
            content = result.get("content", "")
            if len(content) > 1000:
                summary = f"{content[:1000]}... [content truncated, total length: {len(content)} characters]"
                result["content"] = summary
            
            return json.dumps(result)
        except Exception as e:
            logger.error(f"Error exporting notebook: {str(e)}")
            return json.dumps({"error": str(e)})
  • Helper function implementing the Databricks Workspace Export API call (/api/2.0/workspace/export). Handles base64 decoding for SOURCE/JUPYTER formats.
    async def export_notebook(
        path: str,
        format: str = "SOURCE",
    ) -> Dict[str, Any]:
        """
        Export a notebook from the workspace.
        
        Args:
            path: The path of the notebook to export
            format: The format to export (SOURCE, HTML, JUPYTER, DBC)
            
        Returns:
            Response containing the notebook content
            
        Raises:
            DatabricksAPIError: If the API request fails
        """
        logger.info(f"Exporting notebook from path: {path}")
        
        params = {
            "path": path,
            "format": format,
        }
        
        response = make_api_request("GET", "/api/2.0/workspace/export", params=params)
        
        # Optionally decode base64 content
        if "content" in response and format in ["SOURCE", "JUPYTER"]:
            try:
                response["decoded_content"] = base64.b64decode(response["content"]).decode("utf-8")
            except Exception as e:
                logger.warning(f"Failed to decode notebook content: {str(e)}")
                
        return response
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Export' implies a read operation that generates output, but the description doesn't specify what happens (e.g., file download, storage location, format defaults, permissions needed, or error conditions). It lacks critical details for safe and effective use.

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

Conciseness5/5

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

The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to scan. Every word contributes directly to the purpose.

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

Completeness2/5

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

Given the complexity (export operation with 2 parameters), no annotations, 0% schema coverage, and no output schema, the description is incomplete. It doesn't explain parameters, behavioral traits, or output format, leaving significant gaps for the agent to operate effectively.

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

Parameters2/5

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

Schema description coverage is 0%, so the schema provides no parameter details. The description mentions no parameters at all, failing to explain 'path' (e.g., notebook path in workspace) or 'format' (e.g., export formats like JUPYTER). It doesn't compensate for the schema's lack of documentation.

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

Purpose4/5

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

The description clearly states the action ('Export') and resource ('a notebook from the workspace'), making the purpose understandable. However, it doesn't distinguish this tool from potential sibling export operations (none are listed, but it could be confused with general file export tools). The description is specific but lacks sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., notebook must exist), exclusions, or related tools like 'list_notebooks' for finding notebooks to export. The agent must infer usage from context alone.

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