Skip to main content
Glama
samhavens

Databricks MCP Server

by samhavens

create_notebook

Generate a new notebook in Databricks workspace by specifying path, content, language, and overwrite options to organize and execute code efficiently.

Instructions

Create a new notebook in the Databricks workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
languageNoPYTHON
overwriteNo
pathYes

Implementation Reference

  • The primary handler function for the 'create_notebook' MCP tool. It is decorated with @mcp.tool() for registration and executes the tool logic by calling the notebooks.import_notebook helper.
    @mcp.tool() async def create_notebook( path: str, content: str, language: str = "PYTHON", overwrite: bool = False ) -> str: """Create a new notebook in the Databricks workspace""" logger.info(f"Creating notebook at path: {path}") try: result = await notebooks.import_notebook( path=path, content=content, format="SOURCE", language=language.upper(), overwrite=overwrite ) return json.dumps(result) except Exception as e: logger.error(f"Error creating notebook: {str(e)}") return json.dumps({"error": str(e)})
  • Supporting helper function that implements the core logic for creating/importing a notebook via the Databricks Workspace Import API (/api/2.0/workspace/import). Handles base64 encoding and API request.
    async def import_notebook( path: str, content: str, format: str = "SOURCE", language: Optional[str] = None, overwrite: bool = False, ) -> Dict[str, Any]: """ Import a notebook into the workspace. Args: path: The path where the notebook should be stored content: The content of the notebook (base64 encoded) format: The format of the notebook (SOURCE, HTML, JUPYTER, DBC) language: The language of the notebook (SCALA, PYTHON, SQL, R) overwrite: Whether to overwrite an existing notebook Returns: Empty response on success Raises: DatabricksAPIError: If the API request fails """ logger.info(f"Importing notebook to path: {path}") # Ensure content is base64 encoded if not is_base64(content): content = base64.b64encode(content.encode("utf-8")).decode("utf-8") import_data = { "path": path, "format": format, "content": content, "overwrite": overwrite, } if language: import_data["language"] = language return make_api_request("POST", "/api/2.0/workspace/import", data=import_data)

Other Tools

Related 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