Skip to main content
Glama

service_create

Create a Kubernetes Service to expose pods and manage network access within a cluster namespace.

Instructions

Create a Service in the specified namespace.

Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name selector: A dictionary of labels to select the target pods ports: A list of ports (e.g., [{"port": 80, "target_port": 8080}]) service_type: The type of the Service (default is "ClusterIP")

Returns: Status of the creation operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
namespaceYes
nameYes
selectorYes
portsYes
service_typeNoClusterIP

Implementation Reference

  • The service_create tool handler, decorated with @mcp.tool() for registration, @use_current_context, and @check_readonly_permission. It creates a Kubernetes Service object using kubernetes.client.CoreV1Api and applies it to the specified namespace.
    @mcp.tool() @use_current_context @check_readonly_permission def service_create(context_name: str, namespace: str, name: str, selector: dict, ports: list, service_type: str = "ClusterIP"): """ Create a Service in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name selector: A dictionary of labels to select the target pods ports: A list of ports (e.g., [{"port": 80, "target_port": 8080}]) service_type: The type of the Service (default is "ClusterIP") Returns: Status of the creation operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] service = V1Service( metadata=V1ObjectMeta(name=name), spec=V1ServiceSpec( selector=selector, ports=[V1ServicePort(port=port["port"], target_port=port["target_port"]) for port in ports], type=service_type ) ) created_service = core_v1.create_namespaced_service(namespace=namespace, body=service) return {"name": created_service.metadata.name, "status": "Created"}
  • tools/service.py:27-27 (registration)
    The @mcp.tool() decorator registers the service_create function as an MCP tool.
    @mcp.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/bourbonkk/k8s-pilot'

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