Skip to main content
Glama
nacos-group

Nacos MCP Server

Official
by nacos-group

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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/nacos-group/nacos-mcp-server'

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