Skip to main content
Glama
abhijeetka
by abhijeetka

use_context

Switch between Kubernetes cluster contexts to manage different environments using the MCP Kubernetes Server tool.

Instructions

Switch to a specific Kubernetes context Args: context_name: The name of the Kubernetes context to switch to

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes

Implementation Reference

  • The main handler function for the 'use_context' tool. It executes 'kubectl config use-context' via subprocess to switch the Kubernetes context, returning success message or error.
    @mcp.tool()
    async def use_context(context_name: str) -> dict:
        """Switch to a specific Kubernetes context
        Args:
            context_name: The name of the Kubernetes context to switch to
        """
        try:
            cmd = ["kubectl", "config", "use-context", context_name]
            result = subprocess.run(cmd, capture_output=True, text=True, check=True)
            return {"message": f"Switched to context: {context_name}",
                    "details": result.stdout}
        except subprocess.CalledProcessError as e:
            return {"error": f"Failed to switch context: {str(e)}"}
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states the action ('Switch to') implying a state change, but doesn't disclose effects (e.g., whether this affects subsequent commands, if it requires specific permissions, or if it's reversible). More context on operational impact is needed.

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

Conciseness5/5

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

The description is extremely concise and well-structured: a clear purpose statement followed by a parameter explanation. Every sentence earns its place with no redundant information, making it easy to parse.

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

Completeness3/5

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

Given the tool's moderate complexity (state-changing operation), lack of annotations, and no output schema, the description is minimally adequate but incomplete. It covers the basic action and parameter, but misses behavioral details like side effects, error conditions, or dependencies on other tools for context discovery.

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

Parameters4/5

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

The description adds meaningful semantics for the single parameter 'context_name', explaining it as 'The name of the Kubernetes context to switch to'. With 0% schema description coverage and only one parameter, this adequately compensates, though it could specify format or source (e.g., from 'list_contexts').

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 verb ('Switch to') and resource ('a specific Kubernetes context'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_contexts' or 'get_current_context', which prevents a perfect score.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing existing contexts), exclusions, or relationships with siblings like 'list_contexts' (to see available contexts) or 'get_current_context' (to check current state).

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