Skip to main content
Glama
warrenzhu25

Dataproc MCP Server

by warrenzhu25

get_cluster

Retrieve detailed information about a specific Dataproc cluster, including its configuration, status, and operational metrics, to monitor and manage Google Cloud data processing resources.

Instructions

Get details of a specific Dataproc cluster.

Args:
    cluster_name: Name of the cluster
    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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool registration and handler for 'get_cluster'. Resolves project/region, creates DataprocClient, calls client.get_cluster, handles errors, and returns stringified result.
    @mcp.tool()
    async def get_cluster(
        cluster_name: str, project_id: str | None = None, region: str | None = None
    ) -> str:
        """Get details of a specific Dataproc cluster.
    
        Args:
            cluster_name: Name of the cluster
            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.get_cluster(project_id, region, cluster_name)
            return str(result)
        except Exception as e:
            logger.error("Failed to get cluster", error=str(e))
            return f"Error: {str(e)}"
  • Helper method in DataprocClient that performs the actual Google Cloud Dataproc get_cluster API call, processes the response into a structured dict.
    async def get_cluster(
        self, project_id: str, region: str, cluster_name: str
    ) -> dict[str, Any]:
        """Get details of a specific cluster."""
        try:
            loop = asyncio.get_event_loop()
            client = self._get_cluster_client(region)
    
            request = types.GetClusterRequest(
                project_id=project_id, region=region, cluster_name=cluster_name
            )
    
            cluster = await loop.run_in_executor(None, client.get_cluster, request)
    
            return {
                "name": cluster.cluster_name,
                "status": cluster.status.state.name,
                "status_detail": cluster.status.detail,
                "num_instances": cluster.config.worker_config.num_instances,
                "master_machine_type": cluster.config.master_config.machine_type_uri.split(
                    "/"
                )[-1],
                "worker_machine_type": cluster.config.worker_config.machine_type_uri.split(
                    "/"
                )[-1],
                "disk_size_gb": cluster.config.master_config.disk_config.boot_disk_size_gb,
                "image_version": cluster.config.software_config.image_version,
                "creation_time": cluster.status.state_start_time.isoformat()
                if cluster.status.state_start_time
                else None,
                "zone": cluster.config.gce_cluster_config.zone_uri.split("/")[-1]
                if cluster.config.gce_cluster_config.zone_uri
                else None,
                "metrics": {
                    "hdfs_capacity_mb": getattr(
                        cluster.metrics.hdfs_metrics, "capacity_mb", None
                    )
                    if cluster.metrics and cluster.metrics.hdfs_metrics
                    else None,
                    "yarn_allocated_memory_mb": getattr(
                        cluster.metrics.yarn_metrics, "allocated_memory_mb", None
                    )
                    if cluster.metrics and cluster.metrics.yarn_metrics
                    else None,
                },
            }
    
        except Exception as e:
            logger.error("Failed to get cluster", error=str(e))
            raise
  • Supporting method to create the regional ClusterControllerClient used by get_cluster.
    def _get_cluster_client(self, region: str) -> dataproc_v1.ClusterControllerClient:
        """Get cluster controller client with regional endpoint."""
        # Configure regional endpoint
        regional_endpoint = f"{region}-dataproc.googleapis.com"
        client_opts = client_options.ClientOptions(api_endpoint=regional_endpoint)
    
        return dataproc_v1.ClusterControllerClient(
            credentials=self._credentials, client_options=client_opts
        )
  • Input schema defined by function parameters and type annotations for the MCP tool.
    async def get_cluster(
        cluster_name: str, project_id: str | None = None, region: str | None = None
    ) -> str:
        """Get details of a specific Dataproc cluster.
    
        Args:
            cluster_name: Name of the cluster
            project_id: Google Cloud project ID (optional, uses gcloud config default)
            region: Dataproc region (optional, uses gcloud config default)
        """
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool retrieves details but doesn't disclose behavioral traits such as whether it's a read-only operation, potential authentication requirements, rate limits, error conditions, or what 'details' include. The description is minimal and misses key operational context.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded: the first sentence states the purpose clearly, followed by a structured Args section that efficiently documents parameters. Every sentence earns its place with no redundant or verbose content.

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 the tool has an output schema (which handles return values), the description covers the purpose and parameters adequately. However, as a tool with no annotations and moderate complexity (3 parameters, 1 required), it lacks behavioral context like safety, permissions, or error handling. The description is complete for basic use but misses advanced operational details.

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?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that cluster_name is required and identifies the resource, clarifies that project_id and region are optional with default behaviors (using gcloud config defaults), and provides context about Google Cloud and Dataproc. This compensates well for the low schema coverage.

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 ('Get details') and resource ('a specific Dataproc cluster'), distinguishing it from siblings like list_clusters (which lists multiple clusters) and get_batch_job (which targets batch jobs rather than clusters). The verb 'Get details' is precise and unambiguous.

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

Usage Guidelines3/5

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

The description implies usage by specifying it retrieves details for a 'specific' cluster, suggesting it should be used when the cluster name is known. However, it lacks explicit guidance on when to use this versus alternatives like list_clusters or when not to use it (e.g., for batch jobs). The context is clear but alternatives are not named.

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