Microservices Engine (MSE) provides centralized prompt management for Nacos instances running version 3.1.1 or later. You can store, version, optimize, debug, and dynamically update prompts through the MSE console or Nacos SDK, without redeploying your application.
A prompt consists of four components:
| Component | Description |
|---|---|
| Prompt name | A unique, immutable identifier. Cannot be changed after creation. |
| Prompt template | The prompt content. Use {{parameter_name}} to define replaceable parameters. |
| Version | A semantic version (MAJOR.MINOR.PATCH) that tracks each change. Published versions are immutable. |
| Description | A summary of the prompt's purpose and use case. |
Prerequisites
Before you begin, make sure that you have:
Created an instance and upgraded the Nacos engine version to
3.1.1.0or later
Open the prompt management page
Most operations in this topic start from the same page. To navigate there:
Log on to the MSE Service Registry and Configuration Center Management Console. In the top menu bar, select the Region.
In the navigation pane, choose Microservices Registry > Instances.
On the Instances page, click the target instance name.
In the navigation pane, click Prompt management. In the upper-left corner of the page, select a Namespace.
Create a prompt
On the Prompt management page, click Create prompt.
Configure the following parameters, then click OK.
Parameter Description Prompt name A unique identifier for the prompt. Cannot be changed after creation. Version number The initial version. Follow semantic versioning (MAJOR.MINOR.PATCH), for example, 1.0.0.Description A brief introduction to the prompt's purpose and use case. Prompt template The prompt content. Use {{parameter_name}}to define replaceable parameters.
View prompt details
On the Prompt management page, click a prompt name to view its details. The details page shows the current version number, commit message, prompt template, and parsed parameters.
To view historical versions, use the dropdown list next to the prompt name and click any version number to see its details.
Search for prompts
On the Prompt management page, enter the prompt name in the search box, then click the search icon or press Enter. Fuzzy search is supported.
Edit a prompt
Each edit creates a new version. The new version number must be greater than the current latest version.
After a version is published, it cannot be modified. All changes require publishing a new version. Prompt management retains historical versions for the last 30 days by default.
On the Prompt management page, find the target prompt and click Edit in the Actions column.
In the Edit prompt panel, update the prompt content:
Basic information: Modify the prompt template. The parameter preview section shows how supported parameters change before and after editing. MSE Nacos provides a sample template as a starting point.
Version information: Enter a new version number and a commit message that describes this change.
To update the description, go to the prompt list page and click the edit icon in the Description column.
Optimize a prompt
MSE Nacos includes a built-in AI optimization engine that automatically analyzes and improves prompt quality. It removes ambiguous phrasing, enhances logical structure, adjusts tone based on the use case, and adds security constraints and boundary conditions.
The optimize and debug features use a different navigation path. In the navigation pane, choose Service Registry and Configuration Center > Instances, then click the target instance name and open Prompt management.
Click a prompt name to open its details page.
Click Optimize prompt, enter your optimization requirements, then click Optimize.
After a short wait, the optimized content appears. Review the result and decide whether to replace the original content.
To apply the optimization, click Publish new version in the upper-right corner.
Debug a prompt
The built-in debugging panel lets you test prompts directly in the console. Enter input, adjust template variables, select a model, and see AI responses instantly without deployment.
The debug feature uses the same navigation path as optimize. In the navigation pane, choose Service Registry and Configuration Center > Instances, then click the target instance name and open Prompt management.
Click a prompt name to open its details page.
In the debugging panel on the right side, configure and test the prompt:
Enter user input and fill in the parameters referenced in the prompt template.
Select a model for debugging.
Adjust model parameters as needed.
Click Generate response in the upper-right corner.
The model's response appears below.
Delete a prompt
On the Prompt management page, find the target prompt and click Delete in the Actions column.
Query and subscribe to prompts with the Nacos client
Beyond the console, you can query and subscribe to prompts programmatically through the Nacos configuration service. Specify {promptKey}.json as the data_id and nacos-ai-prompt as the group.
The returned prompt follows this JSON format:
{
"promptKey": "assistant",
"version": "1.0.1",
"template": "You are a professional {{language}} code generation assistant. Generate {{type}} code based on user requirements.\nRequirements:\n1. Code style: {{style}}\n2. Comment language: {{comment_lang}}\n3. Complexity: {{complexity}}\n",
"commitMsg": "Initial version"
}Python
Install dependencies
pip install nacos-sdk-pythonConfigure the client
import os
from v2.nacos import (
NacosConfigService, ClientConfigBuilder, GRPCConfig, ConfigParam
)
# Retrieve credentials from environment variables
client_config = (ClientConfigBuilder()
.access_key(os.getenv('NACOS_ACCESS_KEY'))
.secret_key(os.getenv('NACOS_SECRET_KEY'))
.server_address(os.getenv('NACOS_SERVER_ADDR', 'localhost:8848'))
.log_level('INFO')
.grpc_config(GRPCConfig(grpc_timeout=5000))
.build())Query and subscribe to prompts
config_client = await NacosConfigService.create_config_service(client_config)
# Query a prompt by its key
prompt = await config_client.get_config(ConfigParam(
data_id=f"{promptKey}.json",
group="nacos-ai-prompt"
))
# Subscribe to prompt updates
async def config_listener(tenant, data_id, group, prompt):
print("Prompt updated - tenant:{} data_id:{} group:{} prompt:{}".format(
tenant, data_id, group, prompt
))
await config_client.add_listener(
f"{promptKey}.json", "nacos-ai-prompt", config_listener
)Java
Add dependency
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${version}</version>
</dependency>Configure the client
String serverAddr = "localhost:8848";
ConfigService configService = NacosFactory.createConfigService(serverAddr);Query and subscribe to prompts
// Query a prompt by its key
String prompt = configService.getConfig(
"{promptKey}.json", "nacos-ai-prompt", 5000
);
// Subscribe to prompt updates
configService.addListener(
"{promptKey}.json", "nacos-ai-prompt", new Listener() {
@Override
public void receiveConfigInfo(String prompt) {
System.out.println("Received prompt: " + prompt);
}
@Override
public Executor getExecutor() {
return null;
}
});