delete_kubernetes_cluster
Delete a Kubernetes cluster by specifying its ID and region to free up resources.
Instructions
Delete a Kubernetes cluster on Civo
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Cluster ID | |
| region | Yes | Region identifier |
Implementation Reference
- src/index.ts:525-547 (handler)The handler (switch case) that executes the delete_kubernetes_cluster tool logic. Validates args (id, region), calls deleteCluster API, and returns the result.
case 'delete_kubernetes_cluster': { if ( typeof args !== 'object' || args === null || typeof args.id !== 'string' || typeof args.region !== 'string' ) { throw new Error('Invalid arguments for delete_kubernetes_cluster'); } const result = await deleteCluster( args as { id: string; region: string } ); return { content: [ { type: 'text', text: `Deleted Kubernetes cluster ${args.id}: ${result.result}`, }, ], isError: false, }; } - src/api/kubernetes.ts:69-92 (helper)The API helper function 'deleteCluster' that sends a DELETE request to Civo API endpoint /v2/kubernetes/clusters/{id} with region parameter.
export async function deleteCluster(params: { id: string; region: string; }): Promise<any> { checkRateLimit(); const url = new URL(`${CIVO_API_URL}/kubernetes/clusters/${params.id}`); url.searchParams.set('region', params.region); const response = await fetch(url.toString(), { method: 'DELETE', headers: { Authorization: `Bearer ${CIVO_API_KEY}`, }, }); if (!response.ok) { throw new Error( `Civo API error: ${response.status} ${response.statusText}` ); } return response.json(); } - src/tools/kubernetes.ts:59-76 (schema)The tool schema definition (Tool object) for delete_kubernetes_cluster, defining name, description, and inputSchema with required 'id' and 'region' string fields.
export const DELETE_KUBERNETES_CLUSTER_TOOL: Tool = { name: 'delete_kubernetes_cluster', description: 'Delete a Kubernetes cluster on Civo', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Cluster ID', }, region: { type: 'string', description: 'Region identifier', }, }, required: ['id', 'region'], }, }; - src/index.ts:88-90 (registration)Registration of the tool in the server's capabilities.tools map.
[DELETE_KUBERNETES_CLUSTER_TOOL.name]: DELETE_KUBERNETES_CLUSTER_TOOL, [LIST_KUBERNETES_VERSIONS_TOOL.name]: LIST_KUBERNETES_VERSIONS_TOOL, }, - src/index.ts:115-118 (registration)Registration of the tool in the ListToolsRequestSchema handler (returned as one of the available tools).
DELETE_KUBERNETES_CLUSTER_TOOL, LIST_KUBERNETES_VERSIONS_TOOL, ], }));