create_kubernetes_cluster
Create a new Kubernetes cluster on Civo cloud platform by specifying cluster name, region, network, node count, size, and Kubernetes version.
Instructions
Create a new Kubernetes cluster on Civo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kubernetes_version | Yes | Kubernetes version | |
| name | Yes | Cluster name | |
| network_id | Yes | Network ID | |
| node_size | Yes | Node size | |
| nodes | Yes | Number of nodes | |
| region | Yes | Region identifier |
Implementation Reference
- src/index.ts:490-523 (handler)Main tool handler: validates input arguments according to schema and calls the createCluster API function to execute the cluster creation.case 'create_kubernetes_cluster': { if ( typeof args !== 'object' || args === null || typeof args.name !== 'string' || typeof args.region !== 'string' || typeof args.network_id !== 'string' || typeof args.nodes !== 'number' || typeof args.node_size !== 'string' || typeof args.kubernetes_version !== 'string' ) { throw new Error('Invalid arguments for create_kubernetes_cluster'); } const cluster = await createCluster( args as { name: string; region: string; network_id: string; nodes: number; node_size: string; kubernetes_version: string; } ); return { content: [ { type: 'text', text: `Created Kubernetes cluster ${cluster.name} (ID: ${cluster.id})`, }, ], isError: false, }; }
- src/tools/kubernetes.ts:17-57 (schema)Tool definition with input schema specifying required parameters for creating a Kubernetes cluster.export const CREATE_KUBERNETES_CLUSTER_TOOL: Tool = { name: 'create_kubernetes_cluster', description: 'Create a new Kubernetes cluster on Civo', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Cluster name', }, region: { type: 'string', description: 'Region identifier', }, network_id: { type: 'string', description: 'Network ID', }, nodes: { type: 'number', description: 'Number of nodes', }, node_size: { type: 'string', description: 'Node size', }, kubernetes_version: { type: 'string', description: 'Kubernetes version', }, }, required: [ 'name', 'region', 'network_id', 'nodes', 'node_size', 'kubernetes_version', ], }, };
- src/api/kubernetes.ts:33-67 (helper)Core helper function that sends POST request to Civo Kubernetes API to create the cluster.export async function createCluster(params: { name: string; region: string; network_id: string; nodes: number; node_size: string; kubernetes_version: string; }): Promise<CivoKubernetesCluster> { checkRateLimit(); const url = `${CIVO_API_URL}/kubernetes/clusters`; const response = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${CIVO_API_KEY}`, 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ name: params.name, region: params.region, network_id: params.network_id, nodes: params.nodes.toString(), node_size: params.node_size, kubernetes_version: params.kubernetes_version, }), }); if (!response.ok) { throw new Error( `Civo API error: ${response.status} ${response.statusText}` ); } return response.json(); }
- src/index.ts:70-90 (registration)Registration of the create_kubernetes_cluster tool in the MCP server capabilities.tools map.tools: { [CREATE_INSTANCE_TOOL.name]: CREATE_INSTANCE_TOOL, [LIST_INSTANCES_TOOL.name]: LIST_INSTANCES_TOOL, [REBOOT_INSTANCE_TOOL.name]: REBOOT_INSTANCE_TOOL, [SHUTDOWN_INSTANCE_TOOL.name]: SHUTDOWN_INSTANCE_TOOL, [START_INSTANCE_TOOL.name]: START_INSTANCE_TOOL, [RESIZE_INSTANCE_TOOL.name]: RESIZE_INSTANCE_TOOL, [DELETE_INSTANCE_TOOL.name]: DELETE_INSTANCE_TOOL, [LIST_DISK_IMAGES_TOOL.name]: LIST_DISK_IMAGES_TOOL, [GET_DISK_IMAGE_TOOL.name]: GET_DISK_IMAGE_TOOL, [LIST_SIZES_TOOL.name]: LIST_SIZES_TOOL, [LIST_REGIONS_TOOL.name]: LIST_REGIONS_TOOL, [LIST_NETWORKS_TOOL.name]: LIST_NETWORKS_TOOL, [CREATE_NETWORK_TOOL.name]: CREATE_NETWORK_TOOL, [RENAME_NETWORK_TOOL.name]: RENAME_NETWORK_TOOL, [DELETE_NETWORK_TOOL.name]: DELETE_NETWORK_TOOL, [LIST_KUBERNETES_CLUSTERS_TOOL.name]: LIST_KUBERNETES_CLUSTERS_TOOL, [CREATE_KUBERNETES_CLUSTER_TOOL.name]: CREATE_KUBERNETES_CLUSTER_TOOL, [DELETE_KUBERNETES_CLUSTER_TOOL.name]: DELETE_KUBERNETES_CLUSTER_TOOL, [LIST_KUBERNETES_VERSIONS_TOOL.name]: LIST_KUBERNETES_VERSIONS_TOOL, },
- src/index.ts:113-116 (registration)Inclusion of the tool in the ListTools response.LIST_KUBERNETES_CLUSTERS_TOOL, CREATE_KUBERNETES_CLUSTER_TOOL, DELETE_KUBERNETES_CLUSTER_TOOL, LIST_KUBERNETES_VERSIONS_TOOL,