Skip to main content
Glama

get_namespaces

Retrieve all namespaces within a Kubernetes cluster using the MCP Kubernetes Server, simplifying Kubernetes management through structured API interactions.

Instructions

Get all namespaces in the cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • kubernetes.py:56-56 (registration)
    The @mcp.tool() decorator registers the get_namespaces function as an MCP tool.
    @mcp.tool()
  • The handler function implements the tool logic by executing 'kubectl get namespaces -o json' via subprocess, parsing the JSON output, and returning it or an error dictionary.
    async def get_namespaces() -> dict: """Get all namespaces in the cluster""" try: cmd = ["kubectl", "get", "namespaces", "-o", "json"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return json.loads(result.stdout) except subprocess.CalledProcessError as e: return {"error": f"Failed to get namespaces: {str(e)}"}

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