Skip to main content
Glama
nacos-group

Nacos MCP Server

Official
by nacos-group

list_service_instances

Retrieve service instances from Nacos by specifying service name, namespace, group, and cluster parameters to discover available endpoints.

Instructions

This interface retrieves the list of instances for a specified service.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceIdNoThe namespaceId of service, default is `public` if missing
groupNameNoThe groupName pattern of service, default is `DEFAULT_GROUP` if missing
serviceNameYesThe serviceName pattern of service, required.
clusterNameNoThe 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`

Implementation Reference

  • Specific handler case for the 'list_service_instances' tool within the MCP server's call_tool function. It retrieves the API URL from the tool class and executes an HTTP GET request via NacosServer.get to list service instances.
    case nacos_tools.NacosToolNames.LIST_INSTANCES:
        url = nacos_tools.NacosListInstances().url
        result = nacos.get(name, url, arguments)
        return [types.TextContent(type="text", text=result)]
  • Tool class defining the schema, input validation, description, and Nacos API endpoint for 'list_service_instances'.
    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"
            )
  • Registration of all tools, including NacosListInstances (line 78), in the MCP server's list_tools decorator function.
    @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(),
        ]
  • NacosServer.get method, which performs the actual HTTP GET request to Nacos API, used by all tool handlers including list_service_instances.
    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}'
  • Enum defining the tool name constant 'list_service_instances' used in schema, handler, and registration.
    class NacosToolNames(str, Enum):
        LIST_NAMESPACES = "list_namespaces",
        LIST_SERVICES = "list_services",
        GET_SERVICE = "get_service",
        LIST_INSTANCES = "list_service_instances",
        LIST_SERVICE_SUBSCRIBERS = "list_service_subscribers",
        LIST_CONFIGS = "list_configs",
        GET_CONFIG = "get_config",
        LIST_CONFIG_HISTORY = "list_config_history",
        GET_CONFIG_HISTORY = "get_config_history",
        LIST_CONFIG_LISTENERS = "list_config_listeners",
        LIST_LISTENED_CONFIGS = "list_listened_configs",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states it 'retrieves' data, implying a read-only operation, but doesn't mention permissions, rate limits, pagination, or response format. This is inadequate for a tool with 4 parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (4 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what an 'instance' entails, the return format, or how results are structured, leaving significant gaps for the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema fully documents all parameters. The description adds no additional meaning beyond implying filtering by service, which is already covered by the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('retrieves') and resource ('list of instances for a specified service'), making the purpose understandable. However, it doesn't distinguish this tool from sibling tools like 'list_services' or 'get_service', which reduces its specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_services' or 'get_service'. It lacks context about prerequisites, exclusions, or comparisons with sibling tools, leaving the agent to infer usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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