Skip to main content
Glama

get_current_context

Retrieve the active Kubernetes cluster configuration to verify current operational environment before executing management commands.

Instructions

Get the current Kubernetes context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_current_context' tool. Decorated with @mcp.tool() for registration and implements the logic to retrieve the current Kubernetes context using 'kubectl config current-context' command.
    @mcp.tool() 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