list_config_listeners
Retrieve listeners subscribed to a specific Nacos configuration by providing groupName and dataId parameters. This tool helps monitor which clients are actively receiving configuration updates.
Instructions
This interface retrieves the list of listeners subscribed to a specific configuration.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespaceId | No | The namespaceId of configs, default is `public` if missing | |
| groupName | Yes | The groupName of config, Required. | |
| dataId | Yes | The dataId of config, Required. | |
| aggregation | No | Whether aggregation from whole cluster, if `false`, only get listeners from requested node, default `true` if missing |
Implementation Reference
- src/mcp_server_nacos/server.py:128-131 (handler)The specific case handler in the call_tool function that retrieves the tool URL and executes the Nacos API request for listing configuration listeners.case nacos_tools.NacosToolNames.LIST_CONFIG_LISTENERS: url = nacos_tools.NacosListConfigListeners().url result = nacos.get(name, url, arguments) return [types.TextContent(type="text", text=result)]
- Class defining the tool schema, including input parameters (namespaceId, groupName, dataId, aggregation), description, and the Nacos API endpoint URL.class NacosListConfigListeners(NacosTool): def __init__(self): super().__init__( name=NacosToolNames.LIST_CONFIG_LISTENERS, description="This interface retrieves the list of listeners subscribed to a specific configuration.", inputSchema={ "type": "object", "properties": { "namespaceId": {"type": "string", "description": "The namespaceId of configs, default is `public` if missing"}, "groupName": {"type": "string", "description": "The groupName of config, Required."}, "dataId": {"type": "string", "description": "The dataId of config, Required."}, "aggregation": {"type": "bool", "description": "Whether aggregation from whole cluster, if `false`, only get listeners from requested node, default `true` if missing"} }, "required": ["groupName", "dataId"], }, url="/nacos/v3/admin/cs/config/listener" )
- src/mcp_server_nacos/server.py:71-86 (registration)Tool registration in the list_tools handler, where an instance of NacosListConfigListeners is returned as part of the available tools list.@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(), ]
- src/mcp_server_nacos/nacos_tools.py:271-271 (registration)Enum definition assigning the tool name 'list_config_listeners' used for matching in handlers and registration.LIST_CONFIG_LISTENERS = "list_config_listeners",
- src/mcp_server_nacos/server.py:37-46 (helper)Helper method in NacosServer that performs the actual HTTP GET request to the Nacos API, used by all tool handlers including list_config_listeners.def get(self, name:str, url: str, params: Any = None) -> str: url = f'http://{self.host}:{self.port}{url}' logger.debug(f'GET {url} with params {params}') result = self._request(url, params=params) if result is None: return "Unexpected error: None result handled." if result.is_success(): return str(result.data) return f'Do {name} failed with message: {result.message}'