get_current_context
Retrieve the active Kubernetes cluster configuration to verify current operational environment before executing management commands.
Instructions
Get the current Kubernetes context
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_current_context"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- kubernetes.py:206-214 (handler)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()