list_service_instances
Retrieve a list of service instances by specifying namespace, group, service name, and optional cluster details for efficient service discovery and management.
Instructions
This interface retrieves the list of instances for a specified service.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clusterName | No | The cluster name of instances in service, optional and default is null means match all cluster. If need match multiple cluster, use `,` to split like `cluster1,cluster2` | |
| groupName | No | The groupName pattern of service, default is `DEFAULT_GROUP` if missing | |
| namespaceId | No | The namespaceId of service, default is `public` if missing | |
| serviceName | Yes | The serviceName pattern of service, required. |
Implementation Reference
- src/mcp_server_nacos/server.py:104-107 (handler)Executes the 'list_service_instances' tool by retrieving the Nacos API URL and making an HTTP GET request with provided arguments via NacosServer.get.case nacos_tools.NacosToolNames.LIST_INSTANCES: url = nacos_tools.NacosListInstances().url result = nacos.get(name, url, arguments) return [types.TextContent(type="text", text=result)]
- Defines the tool class NacosListInstances with name 'list_service_instances', input schema for namespaceId, groupName, serviceName, clusterName, description, and Nacos API endpoint.class NacosListInstances(NacosTool): def __init__(self): super().__init__( name=NacosToolNames.LIST_INSTANCES, description="This interface retrieves the list of instances for a specified service.", inputSchema={ "type": "object", "properties": { "namespaceId": {"type": "string", "description": "The namespaceId of service, default is `public` if missing"}, "groupName": {"type": "string", "description": "The groupName pattern of service, default is `DEFAULT_GROUP` if missing"}, "serviceName": {"type": "string", "description": "The serviceName pattern of service, required."}, "clusterName": {"type": "string", "description": "The cluster name of instances in service, optional and default is null means match all cluster. If need match multiple cluster, use `,` to split like `cluster1,cluster2`"}, }, "required": ["serviceName"], }, url="/nacos/v3/admin/ns/instance/list" )
- src/mcp_server_nacos/server.py:71-86 (registration)Registers the NacosListInstances tool (for 'list_service_instances') in the MCP server's list of available tools.@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(), ]
- Defines the enum constant NacosToolNames.LIST_INSTANCES = 'list_service_instances' used for tool identification in registration and handler.LIST_INSTANCES = "list_service_instances",