Skip to main content
Glama
warrenzhu25

Dataproc MCP Server

by warrenzhu25

create_cluster

Create a new Dataproc cluster in Google Cloud by specifying cluster name, worker instances, machine type, disk size, and image version.

Instructions

Create a new Dataproc cluster.

Args:
    cluster_name: Name for the new cluster
    project_id: Google Cloud project ID (optional, uses gcloud config default)
    region: Dataproc region (optional, uses gcloud config default)
    num_instances: Number of worker instances
    machine_type: Machine type for cluster nodes
    disk_size_gb: Boot disk size in GB
    image_version: Dataproc image version

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_nameYes
project_idNo
regionNo
num_instancesNo
machine_typeNon1-standard-4
disk_size_gbNo
image_versionNo2.1-debian11

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'create_cluster' decorated with @mcp.tool(). Resolves project and region, instantiates DataprocClient, and delegates to its create_cluster method.
    @mcp.tool()
    async def create_cluster(
        cluster_name: str,
        project_id: str | None = None,
        region: str | None = None,
        num_instances: int = 2,
        machine_type: str = "n1-standard-4",
        disk_size_gb: int = 100,
        image_version: str = "2.1-debian11",
    ) -> str:
        """Create a new Dataproc cluster.
    
        Args:
            cluster_name: Name for the new cluster
            project_id: Google Cloud project ID (optional, uses gcloud config default)
            region: Dataproc region (optional, uses gcloud config default)
            num_instances: Number of worker instances
            machine_type: Machine type for cluster nodes
            disk_size_gb: Boot disk size in GB
            image_version: Dataproc image version
        """
        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.create_cluster(
                project_id=project_id,
                region=region,
                cluster_name=cluster_name,
                num_instances=num_instances,
                machine_type=machine_type,
                disk_size_gb=disk_size_gb,
                image_version=image_version,
            )
            return str(result)
        except Exception as e:
            logger.error("Failed to create cluster", error=str(e))
            return f"Error: {str(e)}"
  • Core implementation of cluster creation in DataprocClient class. Constructs ClusterConfig using provided parameters and invokes the Google Cloud Dataproc API's create_cluster method via run_in_executor.
    async def create_cluster(
        self,
        project_id: str,
        region: str,
        cluster_name: str,
        num_instances: int = 2,
        machine_type: str = "n1-standard-4",
        disk_size_gb: int = 100,
        image_version: str = "2.1-debian11",
    ) -> dict[str, Any]:
        """Create a new Dataproc cluster."""
        try:
            loop = asyncio.get_event_loop()
            client = self._get_cluster_client(region)
    
            # Configure cluster
            cluster_config = types.ClusterConfig(
                master_config=types.InstanceGroupConfig(
                    num_instances=1,
                    machine_type_uri=machine_type,
                    disk_config=types.DiskConfig(
                        boot_disk_type="pd-standard", boot_disk_size_gb=disk_size_gb
                    ),
                ),
                worker_config=types.InstanceGroupConfig(
                    num_instances=num_instances,
                    machine_type_uri=machine_type,
                    disk_config=types.DiskConfig(
                        boot_disk_type="pd-standard", boot_disk_size_gb=disk_size_gb
                    ),
                ),
                software_config=types.SoftwareConfig(image_version=image_version),
            )
    
            cluster = types.Cluster(
                project_id=project_id, cluster_name=cluster_name, config=cluster_config
            )
    
            request = types.CreateClusterRequest(
                project_id=project_id, region=region, cluster=cluster
            )
    
            # Create cluster (this is a long-running operation)
            operation = await loop.run_in_executor(None, client.create_cluster, request)
    
            operation_name = getattr(operation, "name", str(operation))
            return {
                "operation_name": operation_name,
                "cluster_name": cluster_name,
                "status": "CREATING",
                "message": f"Cluster creation initiated. Operation: {operation_name}",
            }
    
        except Exception as e:
            logger.error("Failed to create cluster", error=str(e))
            raise
  • Helper function used by create_cluster handler to resolve project_id and region from inputs or gcloud defaults, returning error string if unresolved.
    def resolve_project_and_region(
        project_id: str | None, region: str | None
    ) -> tuple[str, str] | str:
        """Resolve project_id and region from parameters or gcloud config defaults.
    
        Returns:
            Tuple of (project_id, region) if successful, error message string if failed.
        """
        # Resolve project_id
        if project_id is None:
            project_id = get_default_project()
            if project_id is None:
                return "Error: No project_id provided and no default project configured in gcloud. Run 'gcloud config set project PROJECT_ID' or provide project_id parameter."
    
        # Resolve region
        if region is None:
            region = get_default_region()
            if region is None:
                return "Error: No region provided and no default region configured in gcloud. Run 'gcloud config set compute/region REGION' or provide region parameter."
    
        return project_id, region
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it implies a write operation ('Create'), it doesn't disclose critical traits like required permissions, cost implications, time to provision, whether it's idempotent, error conditions, or what the output contains. The description only lists parameters without behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The parameter documentation is organized in a clear 'Args' section. While efficient, the parameter explanations could be slightly more concise by avoiding repetition of obvious information like 'Name for the new cluster'.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a complex mutation tool (creating cloud infrastructure) with no annotations but with an output schema, the description is moderately complete. It documents all parameters but lacks behavioral context about permissions, costs, or operational characteristics. The output schema existence means return values don't need explanation, but other critical context is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining all 7 parameters in the 'Args' section. It adds meaning beyond schema titles by clarifying optional parameters with default behaviors ('uses gcloud config default') and providing units for disk_size_gb. However, it doesn't explain parameter constraints or valid values.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Create a new Dataproc cluster') with the exact resource type. It distinguishes this tool from sibling tools like 'delete_cluster' or 'get_cluster' by specifying it's for creation rather than deletion or retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication, project setup), when not to use it (e.g., if a cluster already exists), or how it differs from related tools like 'create_batch_job'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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