Skip to main content
Glama

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
NameRequiredDescriptionDefault
context_nameYes
namespaceYes

Implementation Reference

  • 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)}"})

Other Tools

Related Tools

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/bourbonkk/k8s-pilot'

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