Skip to main content
Glama
warrenzhu25

Dataproc MCP Server

by warrenzhu25

list_clusters

Retrieve and display all Dataproc clusters in a specified Google Cloud project and region. Use this tool to monitor cluster status and manage resources.

Instructions

List Dataproc clusters in a project and region.

Args:
    project_id: Google Cloud project ID (optional, uses gcloud config default)
    region: Dataproc region (optional, uses gcloud config default)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNo
regionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'list_clusters' registered via @mcp.tool() decorator. Handles input resolution, calls DataprocClient, and returns result as string.
    @mcp.tool()
    async def list_clusters(
        project_id: str | None = None, region: str | None = None
    ) -> str:
        """List Dataproc clusters in a project and region.
    
        Args:
            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.list_clusters(project_id, region)
            return str(result)
        except Exception as e:
            logger.error("Failed to list clusters", error=str(e))
            return f"Error: {str(e)}"
  • DataprocClient method that performs the actual Google Cloud Dataproc API call to list clusters and formats the response.
    async def list_clusters(self, project_id: str, region: str) -> dict[str, Any]:
        """List clusters in a project and region."""
        try:
            loop = asyncio.get_event_loop()
            client = self._get_cluster_client(region)
    
            request = types.ListClustersRequest(project_id=project_id, region=region)
    
            # Run in thread pool since the client is sync
            response = await loop.run_in_executor(None, client.list_clusters, request)
    
            clusters = []
            for cluster in response:
                clusters.append(
                    {
                        "name": cluster.cluster_name,
                        "status": cluster.status.state.name,
                        "num_instances": cluster.config.worker_config.num_instances,
                        "machine_type": cluster.config.master_config.machine_type_uri.split(
                            "/"
                        )[-1],
                        "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,
                    }
                )
    
            return {
                "clusters": clusters,
                "total_count": len(clusters),
                "project_id": project_id,
                "region": region,
            }
    
        except Exception as e:
            logger.error("Failed to list clusters", error=str(e))
            raise
  • Utility function used by list_clusters handler to resolve project_id and region from inputs or gcloud defaults.
    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?

No annotations are provided, so the description carries full burden. It states the action ('List') but doesn't disclose behavioral traits like read-only nature (implied by 'List'), pagination, rate limits, authentication needs, or error handling. The description is minimal and doesn't add meaningful context beyond the basic action.

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. Every sentence adds value without redundancy, making it efficient and easy to parse.

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 2 parameters with 0% schema coverage and an output schema exists, the description is partially complete. It covers parameter defaults but lacks behavioral details (e.g., pagination, permissions). The output schema likely handles return values, so that gap is acceptable, but overall it's adequate with clear room for improvement.

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?

Schema description coverage is 0%, so the description must compensate. It adds semantics by explaining both parameters are optional and use gcloud config defaults, which isn't in the schema. However, it doesn't detail format constraints (e.g., valid region values) or provide examples, leaving some gaps.

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

Purpose4/5

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

The description clearly states the verb ('List') and resource ('Dataproc clusters'), specifying the scope ('in a project and region'). It distinguishes from siblings like 'get_cluster' (single cluster) and 'create_cluster' (creation), but doesn't explicitly differentiate from 'list_batch_jobs' or 'list_jobs' beyond resource type.

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 for retrieving multiple clusters, but doesn't explicitly state when to use this vs. alternatives like 'get_cluster' (for single cluster details) or 'list_batch_jobs' (for batch jobs). It mentions optional parameters with defaults, providing some context, but lacks explicit guidance on use cases or exclusions.

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