Skip to main content
Glama
abhijeetka
by abhijeetka

expose_service

Expose Kubernetes resources as services to enable network access. Configure ClusterIP, NodePort, LoadBalancer, or ExternalName service types for pods, deployments, or other resources.

Instructions

Expose a resource as a new kubernetes service k8s_object can be pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs) Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
k8s_objectYes
nameYes
namespaceNodefault
typeNoClusterIP
portNo
target_portNo
protocolNoTCP

Implementation Reference

  • The main handler function for the 'expose_service' tool, decorated with @mcp.tool() for registration. It executes 'kubectl expose' to create a Kubernetes service for the given object.
    @mcp.tool()
    async def expose_service(k8s_object: str, name: str, namespace: str = "default", type: str = "ClusterIP", port: int = 80, target_port: int = 80, protocol: str = "TCP") -> dict:
        """Expose a resource as a new kubernetes service
           k8s_object can be pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)
           Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'.
        """
        try:
            cmd = ["kubectl", "expose", k8s_object, name, "-n", namespace, "--type", type, "--port", str(port), "--target-port", str(target_port),"--protocol", protocol]
            result = subprocess.run(cmd, capture_output=True, text=True, check=True)
            return json.loads(result.stdout)
        except subprocess.CalledProcessError as e:
            return {"error": f"Failed to expose : {str(e)}"}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains what the tool does and lists parameter options, but doesn't cover critical behavioral aspects like whether this is a read-only or destructive operation, what permissions are required, error handling, or what the output looks like. For a tool that creates/modifies Kubernetes resources, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with three sentences that each serve a purpose: stating the tool's function, explaining the 'k8s_object' parameter, and explaining the 'type' parameter. It's front-loaded with the main purpose and wastes no words, though it could be slightly more structured with bullet points for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a Kubernetes service creation tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks information about behavioral traits, usage context, most parameter meanings, and what the tool returns. For a tool that likely modifies cluster state, this level of documentation is inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for two parameters: it explains that 'k8s_object' can be various Kubernetes resource types with abbreviations, and that 'type' has specific service type options with a default. However, with 7 total parameters and 0% schema description coverage, it doesn't cover the semantics of 'name', 'namespace', 'port', 'target_port', or 'protocol'. The baseline is 3 since it adds some value but doesn't fully compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Expose a resource as a new kubernetes service'. It specifies the verb ('expose') and resource ('kubernetes service'), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'create_deployment' or 'get_services', which would require a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It lists valid values for 'k8s_object' and 'type', but doesn't explain scenarios where exposing a service is appropriate compared to other tools like 'create_deployment' or 'get_services'. There's no mention of prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/abhijeetka/mcp-k8s-server'

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