list_namespaces
Retrieve all namespaces in a Nacos cluster to manage service discovery and configuration access.
Instructions
Retrieves the list of namespaces in the current Nacos cluster.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_server_nacos/server.py:92-95 (handler)Handler for the 'list_namespaces' tool call: retrieves the Nacos API URL from the tool definition and executes a GET request via NacosServer.get with provided arguments.case nacos_tools.NacosToolNames.LIST_NAMESPACES: url = nacos_tools.NacosListNamespacesTool().url result = nacos.get(name, url, arguments) return [types.TextContent(type="text", text=result)]
- Defines the tool metadata including name 'list_namespaces', description, empty input schema (no parameters required), and the target Nacos API endpoint URL.class NacosListNamespacesTool(NacosTool): def __init__(self): super().__init__( name=NacosToolNames.LIST_NAMESPACES, description="Retrieves the list of namespaces in the current Nacos cluster.", inputSchema={ "type": "object", "properties": {} }, url="/nacos/v3/admin/core/namespace/list" )
- src/mcp_server_nacos/server.py:71-86 (registration)Registers the 'list_namespaces' tool by instantiating NacosListNamespacesTool and including it in the list of available tools returned by the MCP server's list_tools method.@server.list_tools() async def handle_list_tools() -> list[types.Tool]: """List available tools""" return [ nacos_tools.NacosListNamespacesTool(), nacos_tools.NacosListServices(), nacos_tools.NacosGetService(), nacos_tools.NacosListInstances(), nacos_tools.NacosListServiceSubscribers(), nacos_tools.NacosListConfigs(), nacos_tools.NacosGetConfig(), nacos_tools.NacosListConfigHistory(), nacos_tools.NacosGetConfigHistory(), nacos_tools.NacosListConfigListeners(), nacos_tools.NacosListListenedConfigs(), ]
- Enum definition for the 'list_namespaces' tool name constant used in tool definition and dispatching.LIST_NAMESPACES = "list_namespaces",