Skip to main content
Glama
warrenzhu25

Dataproc MCP Server

by warrenzhu25

delete_cluster

Remove a Dataproc cluster to manage Google Cloud resources by specifying cluster name, project ID, and region parameters.

Instructions

Delete a Dataproc cluster.

Args:
    cluster_name: Name of the cluster to delete
    project_id: Google Cloud project ID (optional, uses gcloud config default)
    region: Dataproc region (optional, uses gcloud config default)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_nameYes
project_idNo
regionNo

Implementation Reference

  • MCP tool handler for 'delete_cluster'. This is the main entrypoint for the tool, decorated with @mcp.tool() for registration. It handles input validation via type hints, resolves defaults, and delegates to the DataprocClient.
    @mcp.tool()
    async def delete_cluster(
        cluster_name: str, project_id: str | None = None, region: str | None = None
    ) -> str:
        """Delete a Dataproc cluster.
    
        Args:
            cluster_name: Name of the cluster to delete
            project_id: Google Cloud project ID (optional, uses gcloud config default)
            region: Dataproc region (optional, uses gcloud config default)
        """
        resolved = resolve_project_and_region(project_id, region)
        if isinstance(resolved, str):  # Error message
            return resolved
        project_id, region = resolved
    
        client = DataprocClient()
        try:
            result = await client.delete_cluster(project_id, region, cluster_name)
            return str(result)
        except Exception as e:
            logger.error("Failed to delete cluster", error=str(e))
            return f"Error: {str(e)}"
  • Core implementation of cluster deletion in the DataprocClient class. This method constructs the DeleteClusterRequest and calls the Google Cloud Dataproc ClusterControllerClient.delete_cluster API via a thread executor.
    async def delete_cluster(
        self, project_id: str, region: str, cluster_name: str
    ) -> dict[str, Any]:
        """Delete a Dataproc cluster."""
        try:
            loop = asyncio.get_event_loop()
            client = self._get_cluster_client(region)
    
            request = types.DeleteClusterRequest(
                project_id=project_id, region=region, cluster_name=cluster_name
            )
    
            operation = await loop.run_in_executor(None, client.delete_cluster, request)
    
            operation_name = getattr(operation, "name", str(operation))
            return {
                "operation_name": operation_name,
                "cluster_name": cluster_name,
                "status": "DELETING",
                "message": f"Cluster deletion initiated. Operation: {operation_name}",
            }
    
        except Exception as e:
            logger.error("Failed to delete cluster", error=str(e))
            raise

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/warrenzhu25/dataproc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server