list-gke-clusters
Retrieve all Google Kubernetes Engine clusters in your current GCP project to manage containerized applications and resources.
Instructions
List all GKE clusters in the current project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | No | Location (region or zone) to list clusters from (defaults to all locations) |
Implementation Reference
- index.ts:171-184 (registration)Tool registration in the listTools response, including name, description, and input schema.{ name: "list-gke-clusters", description: "List all GKE clusters in the current project", inputSchema: { type: "object", properties: { location: { type: "string", description: "Location (region or zone) to list clusters from (defaults to all locations)", } }, required: [], }, },
- index.ts:241-243 (schema)Zod schema for validating input arguments of the list-gke-clusters tool.const ListGKEClustersSchema = z.object({ location: z.string().optional(), });
- index.ts:563-590 (handler)Executes the list-gke-clusters tool: validates input, lists clusters using ClusterManagerClient.listClusters, formats output as JSON with cluster details.} else if (name === "list-gke-clusters") { const { location } = ListGKEClustersSchema.parse(args); if (!selectedProject) { return createTextResponse("No project selected. Please select a project first."); } try { const containerClient = new ClusterManagerClient(); const parent = location ? `projects/${selectedProject}/locations/${location}` : `projects/${selectedProject}/locations/-`; const [clusters] = await containerClient.listClusters({ parent }); return createTextResponse(JSON.stringify({ clusters: clusters.clusters?.map((cluster: any) => ({ name: cluster.name || null, location: cluster.location || null, status: cluster.status || null, nodeCount: cluster.currentNodeCount || null, k8sVersion: cluster.currentMasterVersion || null })) || [] }, null, 2)); } catch (error: any) { console.error('Error listing GKE clusters:', error); return createTextResponse(`Error listing GKE clusters: ${error.message}`); }