create_cluster
Provision a new Databricks cluster with specified Spark version, node type, and worker count for data processing and analytics workloads.
Instructions
Create a new Databricks cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster_name | Yes | ||
| spark_version | Yes | ||
| node_type_id | Yes | ||
| num_workers | No |
Implementation Reference
- MCP tool handler function for 'create_cluster', registered with @mcp.tool() decorator. Constructs cluster configuration from parameters and delegates to the core API function.@mcp.tool() async def create_cluster( cluster_name: str, spark_version: str, node_type_id: str, num_workers: int = 1 ) -> str: """Create a new Databricks cluster""" logger.info(f"Creating cluster: {cluster_name}") try: cluster_config = { "cluster_name": cluster_name, "spark_version": spark_version, "node_type_id": node_type_id, "num_workers": num_workers, "enable_elastic_disk": True } result = await clusters.create_cluster(cluster_config) return json.dumps(result) except Exception as e: logger.error(f"Error creating cluster: {str(e)}") return json.dumps({"error": str(e)})
- src/api/clusters.py:14-28 (helper)Core helper function that performs the actual Databricks API call to create a cluster using make_api_request.async def create_cluster(cluster_config: Dict[str, Any]) -> Dict[str, Any]: """ Create a new Databricks cluster. Args: cluster_config: Cluster configuration Returns: Response containing the cluster ID Raises: DatabricksAPIError: If the API request fails """ logger.info("Creating new cluster") return make_api_request("POST", "/api/2.0/clusters/create", data=cluster_config)