ks_get_cluster
Retrieve details of a specific Kubernetes cluster by providing the cluster ID or name.
Instructions
Get cluster details
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster | Yes | Cluster ID or name |
Implementation Reference
- src/tools/kubernetes/index.ts:14-16 (registration)Registration of the 'ks_get_cluster' tool via server.tool(), with schema definition (cluster param as Zod string) and inline handler that calls client.get to the Kubernetes API endpoint '/v2/getCluster'.
server.tool("ks_get_cluster", "Get cluster details", { cluster: z.string().describe("Cluster ID or name"), }, async (p) => safeTool(() => client.get(`${base}/v2/getCluster`, {cluster: p.cluster}))); - src/tools/kubernetes/index.ts:14-16 (handler)The handler function for 'ks_get_cluster'. It takes {cluster} input, invokes the IBMCloudAPIClient GET request to the Kubernetes API base URL with path '/v2/getCluster' and the cluster query parameter. The response is wrapped via safeTool which formats success/error content for MCP.
server.tool("ks_get_cluster", "Get cluster details", { cluster: z.string().describe("Cluster ID or name"), }, async (p) => safeTool(() => client.get(`${base}/v2/getCluster`, {cluster: p.cluster}))); - src/tools/kubernetes/index.ts:14-16 (schema)Input schema for 'ks_get_cluster': a single required 'cluster' parameter (string) described as 'Cluster ID or name', validated via Zod.
server.tool("ks_get_cluster", "Get cluster details", { cluster: z.string().describe("Cluster ID or name"), }, async (p) => safeTool(() => client.get(`${base}/v2/getCluster`, {cluster: p.cluster}))); - src/lib/utils.ts:70-77 (helper)The safeTool utility wraps the handler call, catching errors and returning either successContent or errorContent formatted MCP responses.
export async function safeTool<T>(fn: () => Promise<T>): Promise<ReturnType<typeof successContent> | ReturnType<typeof errorContent>> { try { const result = await fn(); return successContent(result); } catch (error) { return errorContent(error); } } - src/lib/api-client.ts:128-130 (helper)The IBMCloudAPIClient.get() convenience method, which is the actual HTTP mechanism invoked by the tool handler to call the Kubernetes API.
async get<T = unknown>(url: string, queryParams?: Record<string, string | number | boolean | undefined>): Promise<T> { return this.request<T>(url, { method: "GET", queryParams }); }