terminate_cluster
Shut down a Databricks cluster by specifying the cluster_id. Ensures resource management and cost optimization for Databricks environments.
Instructions
Terminate a Databricks cluster with parameter: cluster_id (required)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- src/server/databricks_mcp_server.py:76-87 (registration)Registration and handler for the MCP 'terminate_cluster' tool. Delegates to clusters.terminate_cluster API function.@self.tool( name="terminate_cluster", description="Terminate a Databricks cluster with parameter: cluster_id (required)", ) async def terminate_cluster(params: Dict[str, Any]) -> List[TextContent]: logger.info(f"Terminating cluster with params: {params}") try: result = await clusters.terminate_cluster(params.get("cluster_id")) return [{"text": json.dumps(result)}] except Exception as e: logger.error(f"Error terminating cluster: {str(e)}") return [{"text": json.dumps({"error": str(e)})}]
- src/api/clusters.py:31-45 (handler)Core handler function that executes the termination by calling the Databricks Clusters API delete endpoint.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})