terminate_cluster
Terminate a Databricks cluster by specifying its cluster_id to shut down resources, ensuring efficient cluster management and cost control.
Instructions
Terminate a Databricks cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster_id | Yes |
Implementation Reference
- MCP tool handler for 'terminate_cluster' decorated with @mcp.tool(). Delegates to the clusters API module to perform the termination and returns JSON response.@mcp.tool() async def terminate_cluster(cluster_id: str) -> str: """Terminate a Databricks cluster""" logger.info(f"Terminating cluster: {cluster_id}") try: result = await clusters.terminate_cluster(cluster_id) return json.dumps(result) except Exception as e: logger.error(f"Error terminating cluster: {str(e)}") return json.dumps({"error": str(e)})
- src/api/clusters.py:31-45 (helper)Core helper function that makes the actual Databricks API request (POST /api/2.0/clusters/delete) to terminate the specified cluster.async def terminate_cluster(cluster_id: str) -> Dict[str, Any]: """ Terminate a Databricks cluster. Args: cluster_id: ID of the cluster to terminate Returns: Empty response on success Raises: DatabricksAPIError: If the API request fails """ logger.info(f"Terminating cluster: {cluster_id}") return make_api_request("POST", "/api/2.0/clusters/delete", data={"cluster_id": cluster_id})