terminate_cluster
Shut down a Databricks cluster to stop resource usage and manage costs. Provide the cluster ID to terminate it.
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() which registers it. Executes by calling clusters.terminate_cluster(), wraps in JSON, handles errors.@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 performs the actual Databricks API call to delete/terminate the 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})
- src/server/simple_databricks_mcp_server.py:63-72 (registration)The @mcp.tool() decorator registers this function as the 'terminate_cluster' MCP tool.@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)})