Skip to main content
Glama

list_contexts

Lists all available Kubernetes contexts to help users identify and switch between different cluster configurations for managing containerized applications.

Instructions

List all available Kubernetes contexts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_contexts' MCP tool. It executes 'kubectl config get-contexts -o name' to list all available Kubernetes contexts and returns them as a list in a dict.
    @mcp.tool() async def list_contexts() -> dict: """List all available Kubernetes contexts""" try: cmd = ["kubectl", "config", "get-contexts", "-o", "name"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) contexts = result.stdout.strip().split('\n') return {"contexts": contexts} except subprocess.CalledProcessError as e: return {"error": f"Failed to list contexts: {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