list-gke-clusters
Retrieve all Google Kubernetes Engine (GKE) clusters within a specified project. Optionally filter by region or zone to streamline cluster management and monitoring.
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:563-590 (handler)Handler function for 'list-gke-clusters' tool that lists GKE clusters using ClusterManagerClient, optionally filtered by location, requires selected project.} 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}`); }
- index.ts:241-243 (schema)Zod schema for validating input arguments to the list-gke-clusters tool, with optional location parameter.const ListGKEClustersSchema = z.object({ location: z.string().optional(), });
- index.ts:171-184 (registration)Registration of the 'list-gke-clusters' tool 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: [], }, },