resize_node_pool
Adjust the node count in a GKE cluster's node pool by specifying the project, cluster, location, node pool, and desired node count.
Instructions
Resize a node pool in a GKE cluster.
Args:
project_id: The ID of the GCP project
cluster_name: The name of the GKE cluster
location: The location (region or zone) of the cluster
node_pool_name: The name of the node pool to resize
node_count: The new node count for the pool
Returns:
Result of the node pool resize operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster_name | Yes | ||
| location | Yes | ||
| node_count | Yes | ||
| node_pool_name | Yes | ||
| project_id | Yes |
Implementation Reference
- The resize_node_pool tool handler. Decorated with @mcp.tool() for registration. Uses Google Cloud Container_v1 client to get node pool details, check autoscaling, and initiate resize operation via set_node_pool_size.@mcp.tool() def resize_node_pool(project_id: str, cluster_name: str, location: str, node_pool_name: str, node_count: int) -> str: """ Resize a node pool in a GKE cluster. Args: project_id: The ID of the GCP project cluster_name: The name of the GKE cluster location: The location (region or zone) of the cluster node_pool_name: The name of the node pool to resize node_count: The new node count for the pool Returns: Result of the node pool resize operation """ try: from google.cloud import container_v1 # Initialize the GKE client client = container_v1.ClusterManagerClient() # Create the node pool path node_pool_path = f"projects/{project_id}/locations/{location}/clusters/{cluster_name}/nodePools/{node_pool_name}" # Get the current node pool node_pool = client.get_node_pool(name=node_pool_path) current_node_count = node_pool.initial_node_count # Check if autoscaling is enabled if node_pool.autoscaling and node_pool.autoscaling.enabled: return f""" Cannot resize node pool {node_pool_name} because autoscaling is enabled. To manually set the node count, you must first disable autoscaling for this node pool. Current autoscaling settings: - Min nodes: {node_pool.autoscaling.min_node_count} - Max nodes: {node_pool.autoscaling.max_node_count} """ # Resize the node pool request = container_v1.SetNodePoolSizeRequest( name=node_pool_path, node_count=node_count ) operation = client.set_node_pool_size(request=request) return f""" Node pool resize operation initiated: - Cluster: {cluster_name} - Location: {location} - Node Pool: {node_pool_name} - Current Node Count: {current_node_count} - New Node Count: {node_count} Operation ID: {operation.name} Status: {operation.status.name if hasattr(operation.status, 'name') else operation.status} """ except Exception as e: return f"Error resizing node pool: {str(e)}"
- src/gcp_mcp/server.py:51-51 (registration)Invocation of register_tools for kubernetes module, which registers the resize_node_pool tool (and others) to the FastMCP server instance.kubernetes_tools.register_tools(mcp)