Skip to main content
Glama

get_current_context

Retrieve the active Kubernetes cluster context to identify and manage resources within the targeted environment using the MCP Kubernetes Server.

Instructions

Get the current Kubernetes context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that implements the logic for the 'get_current_context' tool by executing 'kubectl config current-context' and returning the current Kubernetes context or an error.
    async def get_current_context() -> dict: """Get the current Kubernetes context""" try: cmd = ["kubectl", "config", "current-context"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"current_context": result.stdout.strip()} except subprocess.CalledProcessError as e: return {"error": f"Failed to get current context: {str(e)}"}
  • kubernetes.py:206-206 (registration)
    The @mcp.tool() decorator registers the get_current_context 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/abhijeetka/mcp-k8s-server'

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