Skip to main content
Glama

get_namespaces

Retrieve all namespaces in a Kubernetes cluster to manage resources and organize workloads effectively.

Instructions

Get all namespaces in the cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool handler function for 'get_namespaces'. It uses kubectl to fetch all namespaces in JSON format and returns the parsed JSON or an error dictionary.
    @mcp.tool() 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