Skip to main content
Glama
samhavens

Databricks MCP Server

by samhavens

create_notebook

Create a new notebook in Databricks workspace with specified path, content, and language to organize and execute code.

Instructions

Create a new notebook in the Databricks workspace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
contentYes
languageNoPYTHON
overwriteNo

Implementation Reference

  • MCP tool handler and registration for 'create_notebook'. Wraps the notebooks.import_notebook function to create notebooks in Databricks workspace via API.
    @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)})
  • Core helper function that performs the actual Databricks API call to import/create a notebook using the Workspace Import API.
    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)
Behavior2/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 but offers minimal information. It states the tool creates a notebook but doesn't cover critical aspects like authentication requirements, rate limits, error conditions (e.g., invalid paths), or what happens on success (e.g., returns a notebook ID). For a mutation tool with zero annotation coverage, this is inadequate.

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 parse. Every part of the sentence ('Create a new notebook in the Databricks workspace') directly contributes to understanding the tool's 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 tool's complexity (a mutation operation with 4 parameters), lack of annotations, 0% schema description coverage, and no output schema, the description is incomplete. It doesn't address behavioral traits, parameter meanings, return values, or usage context, leaving significant gaps for an AI agent to invoke it correctly.

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?

The input schema has 0% description coverage, so parameters are undocumented in the schema. The description adds no parameter semantics—it doesn't explain what 'path', 'content', 'language', or 'overwrite' mean, their formats, or constraints (e.g., path syntax, language options). This fails to compensate for the schema gap, leaving parameters largely ambiguous.

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 ('Create a new notebook') and resource ('in the Databricks workspace'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential siblings like 'upload_file_to_dbfs' or 'export_notebook' that might also create notebook-like resources, preventing a perfect score.

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., workspace access), contrast with similar tools (e.g., 'upload_file_to_dbfs' for files vs. notebooks), or specify use cases (e.g., for interactive coding vs. batch jobs). This leaves the agent with minimal context for tool selection.

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