Skip to main content
Glama
nacos-group

Nacos MCP Server

Official
by nacos-group

list_services

Retrieve a list of services under a specified namespace, with or without instance details. Optimize memory and network usage by controlling the withInstances parameter for efficient data retrieval. Supports pagination and filtering by group or service name patterns.

Instructions

This interface retrieves the list of services under a specified namespace. The response format depends on the withInstances parameter:withInstances=true: Returns service details with instances (ServiceDetailInfo objects). withInstances=false: Returns service metadata without instances (ServiceView objects). **NOTE: ** When withInstances=true, The API may cost too much memory and networks, If Only want get instance list with little or one service, Suggest use withInstances=false with List Service Instances.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupNameParamNoThe groupName pattern of services, default null means all group if missing. if not null, server will search all service match groupName both prefix and subfix, such as: input `test`, groupName `test`, `atest`, `testb`, `atestb` will all matched
ignoreEmptyServiceNoWhether ignore the empty service in result, default is true
namespaceIdNoThe namespaceId of services, default is `public` if missing
pageNoYesThe current page number, default is 1.
pageSizeYesThe size of services in each page, default is 100
serviceNameParamNoThe serviceName pattern of services, default null means all service if missing. if not null, server will search all service match serviceName both prefix and subfix, such as: input `test`, serviceName `test`, `atest`, `testb`, `atestb` will all matched
withInstancesNoWhether contain instances under each services in result, recommend and default is false

Implementation Reference

  • Handler logic for the 'list_services' tool: instantiates NacosListServices to get the API URL, passes arguments to NacosServer.get method, and returns the response as text content.
    case nacos_tools.NacosToolNames.LIST_SERVICES: url = nacos_tools.NacosListServices().url result = nacos.get(name, url, arguments) return [types.TextContent(type="text", text=result)]
  • Tool definition class NacosListServices: sets tool name to 'list_services', provides detailed input schema for parameters like pageNo, pageSize, namespaceId, groupNameParam, serviceNameParam, ignoreEmptyService, withInstances, and specifies the Nacos API endpoint URL.
    class NacosListServices(NacosTool): def __init__(self): super().__init__( name=NacosToolNames.LIST_SERVICES, description="This interface retrieves the list of services under a specified namespace. The response format depends on the `withInstances` parameter:`withInstances=true`: Returns service details with instances (`ServiceDetailInfo` objects). `withInstances=false`: Returns service metadata without instances (`ServiceView` objects). **NOTE: ** When `withInstances=true`, The API may cost too much memory and networks, If Only want get instance list with little or one service, Suggest use `withInstances=false` with `List Service Instances`.", inputSchema={ "type": "object", "properties": { "pageNo": {"type": "int", "description": "The current page number, default is 1."}, "pageSize": {"type": "int", "description": "The size of services in each page, default is 100"}, "namespaceId": {"type": "string", "description": "The namespaceId of services, default is `public` if missing"}, "groupNameParam": {"type": "string", "description": "The groupName pattern of services, default null means all group if missing. if not null, server will search all service match groupName both prefix and subfix, such as: input `test`, groupName `test`, `atest`, `testb`, `atestb` will all matched"}, "serviceNameParam": {"type": "string", "description": "The serviceName pattern of services, default null means all service if missing. if not null, server will search all service match serviceName both prefix and subfix, such as: input `test`, serviceName `test`, `atest`, `testb`, `atestb` will all matched"}, "ignoreEmptyService": {"type": "bool", "description": "Whether ignore the empty service in result, default is true"}, "withInstances": {"type": "bool", "description": "Whether contain instances under each services in result, recommend and default is false"}, }, "required": ["pageNo", "pageSize"], }, url="/nacos/v3/admin/ns/service/list" )
  • Registers the NacosListServices tool (list_services) by including its instance in the list returned by 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(), ]
  • Defines the enum value NacosToolNames.LIST_SERVICES = 'list_services' used for tool name matching in handler and registration.
    class NacosToolNames(str, Enum): LIST_NAMESPACES = "list_namespaces", LIST_SERVICES = "list_services",

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