Skip to main content
Glama
samhavens

Databricks MCP Server

by samhavens

export_notebook

Export a notebook from the Databricks workspace in a specified format, such as Jupyter, using the Databricks MCP Server. Ideal for integrating notebook content into workflows or external systems.

Instructions

Export a notebook from the workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoJUPYTER
pathYes

Implementation Reference

  • MCP tool handler for 'export_notebook' decorated with @mcp.tool(). Calls notebooks.export_notebook API, trims large content, and returns JSON.
    @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)})
  • Core helper function implementing notebook export via Databricks Workspace Export API (/api/2.0/workspace/export). Handles base64 decoding.
    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

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