MSE Nacos Enterprise Edition supports the registration and configuration management of Model-as-a-Service Consumer Protocol (MCP) services. This feature provides standardized integration of external tools for large language models (LLMs).
Create an MCP service
This feature is supported only in MSE Nacos Enterprise Edition 3.0 and later. Microservices Engine provides three ways to create an MCP service. You can choose one based on your business needs:
Standard MCP service: Build a complete MCP configuration from scratch.
HTTP-to-MCP service: Convert an existing HTTP service to an MCP service.
Dynamically registered MCP service: Automatically register a service using the Nacos software development kit (SDK).
Create a standard MCP service
Log on to the MSE console, and select a region in the top navigation bar.
In the left-side navigation pane, choose Microservices Registry > Instances, and then click the name of the target instance.
In the navigation pane on the left, click MCP Registry. Select a Namespace, click Create MCP Service, and then click the Standard MCP Service tab.
On the Standard MCP Service page, configure the basic information. The key parameters are described as follows:
MCP Protocol Type:
Stdio: Lacks network communication capabilities. This protocol is suitable for local development, debugging, and offline environment validation.
SSE: Used for unidirectional real-time communication scenarios, such as configuration pushes from an API gateway. It offers low latency and high compatibility but only supports server-to-client unidirectional streaming.
Streamable HTTP: Suitable for production environment deployments and cross-network communication, such as hybrid cloud or cross-VPC. This protocol also supports bidirectional communication.
Backend Service:
Use Existing Service: If your MCP service is already registered with MSE Nacos through the console or an SDK, you can select it directly.
Create New Service: If your MCP service is not yet registered with MSE Nacos, you must configure Service IP/Domain Name, Service Port, and Access Path. The access path must start with a forward slash (/), such as
/v1/mcp.
After you complete the configuration, click Save And Publish.
Create an HTTP-to-MCP service
Log on to the MSE console, and select a region in the top navigation bar.
In the left-side navigation pane, choose Microservices Registry > Instances, and then click the name of the target instance.
In the navigation pane on the left, click MCP Registry. Select a Namespace, click Create MCP Service, and then click the HTTP-to-MCP Conversion tab.
On the HTTP-to-MCP Conversion tab, configure the basic information. The key parameters are described as follows:
HTTPS Service: Specifies whether to use the HTTPS protocol, which is different from the original HTTP service.
MCP Protocol:
SSE: Used for unidirectional real-time communication scenarios, such as configuration pushes from an API gateway. It offers low latency and high compatibility but only supports server-to-client unidirectional streaming.
Streamable HTTP: Suitable for production environment deployments and cross-network communication, such as hybrid cloud or cross-VPC. This protocol also supports bidirectional communication.
Backend Service:
Use Existing Service: If your HTTP service is already registered with MSE Nacos through the console or an SDK, you can select it directly.
Create New Service: If your HTTP service is not yet registered with MSE Nacos, you must configure Service IP/Domain Name and Service Port.
MCP Tool Configuration Encryption: When enabled, this feature integrates the KMS service into the encryption and decryption process. This reduces the risk of sensitive data leaks. For KMS Key, select an existing key name. If no keys are available, you must first purchase and enable a KMS instance and then create a software-protected key.
(Optional) Create an MCP tool.
After you complete the configuration, click Save And Publish.
Dynamically register an MCP service
You can develop an MCP Server using the Spring AI Alibaba framework or the Nacos MCP Wrapper for Python. After the MCP Server starts, it dynamically registers with Nacos for unified management. This supports the following features:
Dynamic service management: Create, retrieve, update, and delete service information from the MCP service list.
Dynamic description updates: Metadata, such as tool descriptions and parameter definitions, supports hot updates at runtime without restarting the service.
Dynamic enabling and disabling of MCP Server Tools: Enable or disable MCP Server tools at runtime without restarting the service.
MCP services can be deployed using Function Compute. For more information, see Deploy an MCP service in Function Compute and register it with MSE Nacos.
Assign a dedicated RAM user to the application. This user should be separate from the one used for console access to prevent permission escalation risks.
If RAM authentication is enabled, use the AccessKey ID and AccessKey secret of your Alibaba Cloud account for identity authentication.
If authentication is not enabled, use the open source username and password. The username is a static field: Nacos. To obtain the password, go to the Instances list, click the ID of the target instance, and on the Basic Information page, click Reset next to Open Source Console Password. Then, copy the password.
Develop an MCP Server using the Spring AI Alibaba Nacos MCP framework
The version of spring-ai-alibaba must be 1.0.0.3 or later.
1. Import dependencies
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-mcp-registry</artifactId>
<version>{1.0.0.3 or later}</version>
</dependency>
<!-- MCP Server (WebMVC) -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
<version>{1.0.0 or later}</version>
</dependency>2. Define the service (example)
@Service
public class WeatherService {
@Tool(description = "Get weather information by city name")
public String getWeather(@ToolParam(description = "City name") String cityName) {
return "Sunny in " + cityName;
}
}3. Configure Nacos registration parameters
spring:
application:
name: mcp-nacos-registry-example
ai:
mcp:
server:
name: webmvc-mcp-server # MCP service name
version: 1.0.0 # Service version
type: SYNC # Invocation type: SYNC (synchronous) or ASYNC (asynchronous)
instructions: "This mcp server provides time information tools and resources"
alibaba:
mcp:
nacos:
server-addr: # Replace with your Nacos address
namespace: public # Nacos namespace ID (default: public)
access-key: # AccessKey ID of your Alibaba Cloud account
secret-key: # AccessKey secret of your Alibaba Cloud account
register:
enabled: true # Specifies whether to enable service registration4. Start the service
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ToolCallbackProvider weatherTools(WeatherService weatherService) {
return MethodToolCallbackProvider.builder().toolObjects(weatherService).build();
}
}Develop an MCP Server using the Nacos MCP Wrapper for Python
1. Prepare the environment
pip install nacos-mcp-wrapper-python2. Configure automatic registration parameters
nacos_settings = NacosSettings()
nacos_settings.SERVER_ADDR = "127.0.0.1:8848" # <nacos_server_addr> e.g. 127.0.0.1:8848
nacos_settings.NAMESPACE= "public" # Nacos namespace ID
nacos_settings.ACCESS_KEY="" #AccessKey ID of your Alibaba Cloud account
nacos_settings.SECRET_KEY="" #AccessKey secret of your Alibaba Cloud account3. Write the code
from nacos_mcp_wrapper.server.nacos_mcp import NacosMCP
from nacos_mcp_wrapper.server.nacos_settings import NacosSettings
# Create an MCP server instance
nacos_settings = NacosSettings()
nacos_settings.SERVER_ADDR = "127.0.0.1:8848" # <nacos_server_addr> e.g. 127.0.0.1:8848
nacos_settings.ACCESS_KEY = ""
nacos_settings.SECRET_KEY = ""
mcp = NacosMCP("nacos-mcp-python", nacos_settings=nacos_settings, version="1.0.1", port=18001)
# Register an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two integers together"""
return a + b
# Register a subtraction tool
@mcp.tool()
def minus(a: int, b: int) -> int:
"""Subtract two numbers"""
return a - b
if __name__ == "__main__":
try:
mcp.run(transport="sse")
# mcp.run(transport="stdio")
# mcp.run(transport="streamable-http")
except Exception as e:
print(f"Runtime error: {e}")FAQ
The error message
mcp server info is not compatibleorcheck mcp server compatible falseappears upon startup.This error occurs because the data of the MCP Server being registered is incompatible with the data for that version that already exists in Nacos. Ensure that the data of the automatically registered MCP Server is compatible with the data of the corresponding version in Nacos. This includes:
The MCP Server protocol (stdio, sse, or streamable) must be the same.
The service reference must be the same.
The Tools data must be consistent. This includes the tool names, number of tools, parameter types, and whether parameters are optional. The tool descriptions and parameter descriptions do not need to be consistent.
Discover and call an MCP Server
Assign a dedicated RAM user to the application. This user should be separate from the one used for console access to prevent permission escalation risks.
If RAM authentication is enabled, use the AccessKey ID and AccessKey secret of your Alibaba Cloud account for identity authentication.
If authentication is not enabled, use the open source username and password. The username is a static field: Nacos. To obtain the password, go to the Instances list, click the ID of the target instance, and on the Basic Information page, click Reset next to Open Source Console Password. Then, copy the password.
Discover and call an MCP Server using the Spring AI Alibaba Nacos MCP framework
1. Import dependencies
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-openai</artifactId>
<version>{1.0.0 or later}</version>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-chat-client</artifactId>
<version>{1.0.0 or later}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-mcp-registry</artifactId>
<version>{1.0.0.3 or later}</version>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-client-webflux</artifactId>
<version>{1.0.0 or later}</version>
</dependency>2. Create an Async or Sync MCP Client
Declare a list of synchronous MCP clients:
@Autowired
private List<LoadbalancedMcpSyncClient> loadbalancedMcpSyncClients;Or, declare a list of asynchronous MCP clients:
@Autowired
private List<LoadbalancedMcpAsyncClient> loadbalancedMcpAsyncClients;You can inject synchronous tool callbacks using ToolCallbackProvider:
@Qualifier("loadbalancedSyncMcpToolCallbacks") ToolCallbackProvider toolsAlternatively, you can inject asynchronous tool callbacks using ToolCallbackProvider:
@Qualifier("loadbalancedMcpAsyncToolCallbacks") ToolCallbackProvider tools3. application.yml configuration
spring:
application:
name: mcp-client-webflux
ai:
openai:
api-key: ${DASHSCOPE_API_KEY}
base-url: https://dashscope.aliyuncs.com/compatible-mode
chat:
options:
model: qwen-max
alibaba:
mcp:
nacos:
namespace: 4ad3108b-4d44-43d0-9634-3c1ac4850c8c
server-addr: 127.0.0.1:8848
access-key: # AccessKey ID of your Alibaba Cloud account
secret-key: # AccessKey secret of your Alibaba Cloud account
client:
enabled: true
sse:
connections:
server1:
service-name: webflux-mcp-server # Service name of the corresponding MCP Server in Nacos
version: 1.0.0 # Version number of the corresponding MCP Server in Nacos
mcp:
client:
enabled: true
name: mcp-client-webflux
version: 0.0.1
initialized: true
request-timeout: 600s
type: sync
toolcallback:
enabled: true
root-change-notification: true4. Sample code
@SpringBootApplication
public class NacosMcpDiscoveryClientApplication {
public static void main(String[] args) {
SpringApplication.run(NacosMcpDiscoveryClientApplication.class, args);
}
@Bean
public CommandLineRunner predefinedQuestionsDemo(ChatClient.Builder chatClientBuilder, @Qualifier("loadbalancedMcpAsyncToolCallbacks") ToolCallbackProvider tools,
ConfigurableApplicationContext context) {
return args -> {
var chatClient = chatClientBuilder
.defaultToolCallbacks(tools.getToolCallbacks())
.build();
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.print("\n>>> QUESTION: ");
String userInput = scanner.nextLine();
if (userInput.equalsIgnoreCase("exit")) {
break;
}
if (userInput.isEmpty()) {
userInput = "What time is it in UTC+8?";
}
System.out.println("\n>>> ASSISTANT: " + chatClient.prompt(userInput).call().content());
}
scanner.close();
context.close();
};
}
}Discover and call an MCP Server in Nacos using Nacos MCP Router
Nacos MCP Router has two working modes:
router mode: The default mode. Nacos MCP Router acts as a standard MCP Server, providing features such as MCP Server recommendation, distribution, installation, and proxying for other MCP Servers.
proxy mode: Nacos MCP Router provides only the proxy feature. It can convert stdio and sse protocols to the Streamable HTTP protocol with a single click and without code changes.
Router pattern
stdio Protocol
Start Nacos MCP Router:
Start with uvx:
{
"mcpServers": {
"nacos-mcp-router": {
"command": "uvx",
"args": [
"nacos-mcp-router@latest"
],
"env": {
"NACOS_ADDR": "<NACOS-ADDR>, Optional. Default value: 127.0.0.1:8848.",
"ACCESS_KEY_ID": "<ACCESS_KEY_ID>, AccessKey ID of your Alibaba Cloud account",
"ACCESS_KEY_SECRET": "<ACCESS_KEY_SECRET>, AccessKey secret of your Alibaba Cloud account"
}
}
}
}Start with Docker:
{
"mcpServers": {
"nacos-mcp-router": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"NACOS_ADDR=<NACOS-ADDR>",
"-e",
"ACCESS_KEY_ID=<ACCESS_KEY_ID>",
"-e",
"ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET>",
"-e",
"TRANSPORT_TYPE=stdio",
"nacos-mcp-router:latest"
]
}
}
}MCP configuration (example for CherryStudio):
{
"mcpServers": {
"nacos-mcp-router": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"host",
"-e",
"NACOS_ADDR=<NACOS-ADDR>",
"-e",
"ACCESS_KEY_ID=<ACCESS_KEY_ID>",
"-e",
"ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET>",
"-e",
"TRANSPORT_TYPE=stdio",
"nacos-mcp-router:latest"
]
}
}
}SSE protocol
Start with uvx:
export NACOS_ADDR=127.0.0.1:8848
export ACCESS_KEY_ID=ACCESS_KEY_ID
export ACCESS_KEY_SECRET=ACCESS_KEY_SECRET
export TRANSPORT_TYPE=sse
uvx nacos-mcp-router@latestStart with Docker:
docker run -i --rm --network host -e NACOS_ADDR=$NACOS_ADDR -e ACCESS_KEY_ID=$ACCESS_KEY_ID -e ACCESS_KEY_SECRET=$ACCESS_KEY_SECRET -e TRANSPORT_TYPE=sse nacos-mcp-router:latestStreamableHTTP protocol
Start with uvx:
export NACOS_ADDR=127.0.0.1:8848
export ACCESS_KEY_ID=ACCESS_KEY_ID
export ACCESS_KEY_SECRET=ACCESS_KEY_SECRET
export TRANSPORT_TYPE=streamable_http
uvx nacos-mcp-router@latestStart with Docker:
docker run -i --rm --network host -e NACOS_ADDR=$NACOS_ADDR -e ACCESS_KEY_ID=$ACCESS_KEY_ID -e ACCESS_KEY_SECRET=$ACCESS_KEY_SECRET -e TRANSPORT_TYPE=streamable_http nacos-mcp-router:latestProxy pattern
In proxy mode, you must set the environment variables MODE=proxy and PROXIED_MCP_NAME.
Using uvx:
export NACOS_ADDR=$NACOS_ADDR
export ACCESS_KEY_ID=$ACCESS_KEY_ID
export ACCESS_KEY_SECRET=$ACCESS_KEY_SECRET
export TRANSPORT_TYPE=streamable_http
export MODE=proxy
export PROXIED_MCP_NAME=$PROXIED_MCP_NAME
uvx nacos-mcp-router@latestUsing Docker:
docker run -i --rm --network host -e NACOS_ADDR=$NACOS_ADDR -e ACCESS_KEY_ID=$ACCESS_KEY_ID -e ACCESS_KEY_SECRET=$ACCESS_KEY_SECRET -e TRANSPORT_TYPE=streamable_http -e MODE=proxy -e PROXIED_MCP_NAME=$PROXIED_MCP_NAME nacos-mcp-router:latestEnvironment variable configuration:
Parameter | Description | Default Value | Required | Notes |
NACOS_ADDR | Nacos server address | 127.0.0.1:8848 | No | The address of the Nacos server, such as 192.168.1.1:8848. You must include the port number. |
ACCESS_KEY_ID | AccessKey ID of your Alibaba Cloud account | - | No | |
ACCESS_KEY_SECRET | AccessKey secret of your Alibaba Cloud account | - | No | |
NACOS_NAMESPACE | Nacos namespace | public | No | The Nacos namespace, such as public. |
TRANSPORT_TYPE | Transport protocol type | stdio | No | The transport protocol type. Valid values: stdio, sse, and streamable_http. |
PROXIED_MCP_NAME | Name of the proxied MCP server | - | No | In proxy mode, this is the name of the MCP server to be converted. The server must be registered with Nacos first. |
MODE | Working mode | router | No | Valid values: router and proxy. |
PORT | Service port | 8000 | No | Used when the protocol type is sse or streamable. |
Edit an MCP service
Log on to the MSE console, and select a region in the top navigation bar.
In the left-side navigation pane, choose Microservices Registry > Instances, and then click the name of the target instance.
In the navigation pane on the left, click MCP Registry. Select a Namespace, and then click Edit for the target MCP service:
For an MCP tool, you can directly edit and save the Tool Description and the descriptions in the Parameter Structure without changing the version number.
Update version number before editing.
ImportantEach MCP service supports saving only one draft. The latest saved version that is not published will overwrite the previous draft.
Delete MCP Service
Log on to the MSE console, and select a region in the top navigation bar.
In the left-side navigation pane, choose Microservices Registry > Instances
In the left-side navigation pane, choose MCP Registry > Namespace,and delete the targe MCP service.
Create an MCP tool
You can create an MCP tool using either GUI or CLI. The GUI mode lets you create MCP tools by importing a Swagger file, while the CLI editing mode is compatible with the AI Gateway's YAML format.
Protocol Conversion Configuration: The AI Gateway uses this configuration to convert an HTTP service into an MCP service. It is compatible with the open-source Higress RestToMcp template format.
Create an MCP tool by importing a Swagger file
Follow the preceding steps in Create an HTTP-to-MCP service. Before importing, ensure your Swagger file is correctly formatted. After a successful import, the MCP service will be displayed in the MCP service list.
If a service with the same name already exists, the new tool will overwrite the existing one.
