Skip to main content
Glama
tao12345666333

Civo MCP Server

create_kubernetes_cluster

Create a new Kubernetes cluster on Civo cloud platform by specifying name, region, network, node count, size, and Kubernetes version.

Instructions

Create a new Kubernetes cluster on Civo

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCluster name
regionYesRegion identifier
network_idYesNetwork ID
nodesYesNumber of nodes
node_sizeYesNode size
kubernetes_versionYesKubernetes version

Implementation Reference

  • Handler for the 'create_kubernetes_cluster' tool: validates arguments and calls createCluster to make the API request.
    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,
      };
    }
  • Tool schema definition including input validation schema for create_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',
        ],
      },
    };
  • Core helper function that performs the HTTP POST request to Civo API to create the Kubernetes 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:69-92 (registration)
    Registers the create_kubernetes_cluster tool in the MCP server capabilities.tools dictionary.
      capabilities: {
        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:97-118 (registration)
    Registers the create_kubernetes_cluster tool in the ListTools response.
      tools: [
        CREATE_INSTANCE_TOOL,
        LIST_INSTANCES_TOOL,
        REBOOT_INSTANCE_TOOL,
        SHUTDOWN_INSTANCE_TOOL,
        START_INSTANCE_TOOL,
        RESIZE_INSTANCE_TOOL,
        DELETE_INSTANCE_TOOL,
        LIST_DISK_IMAGES_TOOL,
        GET_DISK_IMAGE_TOOL,
        LIST_SIZES_TOOL,
        LIST_REGIONS_TOOL,
        LIST_NETWORKS_TOOL,
        CREATE_NETWORK_TOOL,
        RENAME_NETWORK_TOOL,
        DELETE_NETWORK_TOOL,
        LIST_KUBERNETES_CLUSTERS_TOOL,
        CREATE_KUBERNETES_CLUSTER_TOOL,
        DELETE_KUBERNETES_CLUSTER_TOOL,
        LIST_KUBERNETES_VERSIONS_TOOL,
      ],
    }));

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tao12345666333/civo-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server