Skip to main content
Glama

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)}"}

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