get_namespace_details
Retrieve comprehensive details about a specific Kubernetes namespace in JSON format by providing the context name and namespace. Use this tool to manage and monitor namespace configurations across clusters efficiently.
Instructions
Get detailed information about a specific namespace.
Args: context_name: The Kubernetes context name namespace: The name of the namespace to get details for
Returns: JSON string containing detailed information about the namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/namespace.py:31-65 (handler)The core handler function for the 'get_namespace_details' MCP tool. It is registered via the @mcp.tool() decorator and implements the logic to fetch and return detailed Kubernetes namespace information (name, status, labels, annotations, creation time) as JSON, handling 404 and other API errors.@mcp.tool() @use_current_context def get_namespace_details(context_name: str, namespace: str): """ Get detailed information about a specific namespace. Args: context_name: The Kubernetes context name namespace: The name of the namespace to get details for Returns: JSON string containing detailed information about the namespace """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] try: ns = core_v1.read_namespace(namespace) # Extract useful information result = { "name": ns.metadata.name, "status": ns.status.phase, "labels": ns.metadata.labels if ns.metadata.labels else {}, "annotations": ns.metadata.annotations if ns.metadata.annotations else {}, "created": ns.metadata.creation_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") if ns.metadata.creation_timestamp else None } return json.dumps(result) except ApiException as e: if e.status == 404: return json.dumps({"error": f"Namespace '{namespace}' not found"}) else: return json.dumps({"error": f"API error: {str(e)}"})