作者:席翁
全新里程碑:Nacos 3.1.0 正式發佈
Nacos 社區正式發佈 3.1.0 版本!作為全新的里程碑版本,3.1.0 在 A2A(Agent-to-Agent)註冊中心和 MCP(Model-Context-Protocol)註冊中心兩大核心能力上實現重大突破,同時修復多項歷史問題並升級關鍵依賴。以下是本次版本的核心亮點:
1.1 全新特性:A2A 註冊中心正式上線
Nacos 3.1.0 首次引入 A2A 註冊中心功能,為 AI Agent 框架(如 Spring AI Alibaba)及開發者提供輕量化的 Agent 服務註冊與發現能力。
-
核心能力:
- 支持
AgentCard及 Agent 服務端點的註冊,實現 Agent 元數據(如名稱、版本、描述)的統一管理。 - 提供基礎的 Agent 發現 API,支持基於 Agent 名稱的精準發現和模糊搜索,未來將擴展基於技能標籤(Skills)、描述等多維度的檢索能力。
- 支持
-
應用場景:
- 為分佈式 AI 代理服務提供基礎設施,簡化 Agent 生命週期管理。
- 在 AI Agent 框架中快速集成,助力構建多 Agent 協作的 AI 應用。
1.2 MCP 註冊協議能力全面增強
在 3.0.X 版本支持標準 MCP Registry API 的基礎上,3.1.0 進一步優化 MCP 生態兼容性與管理效率:
-
協議與部署升級:
- 更新官方 MCP 註冊協議,用户可將 Nacos 作為私有化 MCP 註冊中心,構建企業級模型市場或服務目錄。
- 新增 MCP 服務器導入功能,支持通過 JSON 文件快速註冊 MCP 服務,並支持從 MCP URL 自動獲取工具配置。
- 支持從 MCP 官方註冊中心中一鍵導入 MCP 服務。
-
安全與管控增強:
- 控制枱支持動態啓用/禁用 MCP 服務,靈活控制資源佔用。
- 新增 MCP 工具配置加密功能,結合配置加密插件保障敏感數據存儲安全。
-
兼容性保障:
- 數據結構與協議全面對齊 MCP 官方標準,確保後續版本升級兼容性。
由於 MCP 官方註冊中心協議還屬於 preview 階段,Nacos 目前適配了當前最新版本的協議
2025-07-09,若 MCP 官方註冊中心協議新版本中存在不兼容改動,可能導致 MCP 官方註冊中心一鍵導入功能失效。Nacos 3.1.0 版本發佈期間,MCP 官方發佈新了新版本
2025-09-16的註冊中心協議,Nacos 3.1.0 已經極速完成了適配,若需要使用該功能請下載最新的 Nacos 3.1.0 發佈包及鏡像。
1.3 其他重要改進
-
功能優化:
- 新增命名空間存在性校驗,避免無效操作。
- 增強控制枱提示,如重複發佈 Agent 名稱時的友好提醒。
-
問題修復:
- 修復 MySQL 與 Derby 數據庫配置發佈性能不一致問題。
- 解決 MCP 控制枱 OpenAPI 文件解析異常、URL 編碼錯誤等問題。
- 修復 A2A 訂閲判斷邏輯、模糊搜索結果異常等關鍵缺陷。
-
依賴升級:
- 升級 Spring Boot 至 3.4.9、gRPC 至 1.75.0,提升穩定性與安全性。
升級注意事項:
1. 從 3.1.0-BETA 升級: > - 需在升級前刪除所有
AgentCard,或升級後刪除agent和agent-version配置組,並重新發布AgentCard。2. 從 3.0.0 版本升級: > - 若從 3.0.0 版本升級,需使用社區提供的遷移工具將舊版 MCP 服務遷移至
public命名空間。3. 從其他版本升級正常升級。
更多 3.1.0 版本的變更日誌如下:
## Feature
[#12191] Add namespace existence check.
[#13322] Support A2A registry.
[#13423] Support enabled or disabled MCP server in console.
[#13543] Add MCP server import functionality with registry support.
[#13783] Add config metadata update admin api.
[#13808] Add Support official mcp registry protocol.
[#13814] Support prompt encrypt for mcp tools.
## Enhancement/Refactor
[#13777] Enhance namespace exist check logic to improve code quality.
[#13829] Enhance the hint when publish duplicate name of agent.
## BugFix
[#13744] Fix omitted CONFIG_INFO_GRAY_WRAPPER_ROW_MAPPER for config datasource plugin.
[#13752] Fix NPE and ignore InterruptedException stack log.
[#13761] Fix add validation when deleting roles to prevent issues like mistakenly deleting ROLE_ADMIN.
[#13767] Fix service NullPointerException when K8S getSpec().
[#13773] Fix preserve protocol slashes when building MCP OpenAPI-derived URLs.
[#13779] Fix Mcp tool description edit limitation.
[#13787] Fix bug where the Nacos Mcp console cannot correctly parse OpenApi files.
[#13801] Fix bug that sometimes garbled characters appear when parsing OpenAPI file URL in MCP console.
[#13810] Fix bug that caused inconsistent performance between Derby and MySQL databases when publishing configurations.
[#13824][#13826] Fix AI gRPC resource parser and leak auth login for MCP/A2A request in nacos-client.
[#13830] Fix agentCard subscribe judgement problem.
[#13832] Fix blur search may contain unexpected results.
## Dependencies
[#13385] Upgrade os-maven-plugin version to 1.7.1.
[#13711] Upgrade spring boot version to 3.4.9.
[#13753] Upgrade grpc version to 1.75.0.
[#13825] Upgrade jraft version to 1.3.15.bugfix.
Nacos+Spring AI AIibaba 快速開發分佈式 Agent 應用
隨着 Nacos 3.1.0 及 Spring AI Alibaba 的新版本發佈,能夠支持快速開發簡單的 Agent 並暴露 A2A 協議服務,同時註冊到 Nacos 上並讓上有 Agent 應用發現且能夠進行遠程調用,實現 Agent 的分佈式部署。接下來以 Nacos 問答助手為例,手把手帶您實現基於 Nacos 3.1.0 與 Spring AI Alibaba 的分佈式 AI Agent 系統:
樣例工程已發佈至 nacos-group/nacos-spring-ai-alibaba-example [ 1] ,歡迎嘗試。
2.1 環境準備和啓動
- JDK 17+
- Nacos Server 3.1.0+
- Spring AI Alibaba 1.0.0.4+
- 阿里雲百鍊 API KEY
Nacos 的安裝與啓動,請參考 Nacos 快速開始 [ 2] 或 Nacos Docker 快速開始 [ 3] 進行安裝。
阿里雲百鍊的 API-KEY 可參考文檔 [ 4] 獲取,若已獲取,則忽略此步驟。
首次開通阿里雲百鍊時會提供 100 萬 Token 的免費額度。
2.2 構建 A2A Server Agent
2.2.1 引入 pom
<properties>
<spring.ai.alibaba.version>1.0.0.4</spring.ai.alibaba.version>
</properties>
<dependencies>
<!-- 引入A2A Server starter -->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-a2a-server</artifactId>
<version>${spring.ai.alibaba.version}</version>
</dependency>
<!-- 引入A2A Nacos 註冊中心 -->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-a2a-registry</artifactId>
<version>${spring.ai.alibaba.version}</version>
</dependency>
<!-- 引入A2A 百鍊大模型客户端,可以用其他的spring ai大模型客户端代替,如openai -->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-dashscope</artifactId>
<version>${spring.ai.alibaba.version}</version>
</dependency>
</dependencies>
2.2.2 添加配置文件 application.yml
server:
port: 9999
spring:
application:
name: a2s-server-example
ai:
# 配置百鍊大模型
dashscope:
api-key: ${BAILIAN_API_KEY}
base-url: https://dashscope.aliyuncs.com/compatible-mode
chat:
options:
model: qwen-plus-latest
alibaba:
a2a:
# 配置Nacos的地址和用户名密碼
nacos:
server-addr: ${NACOS_ADDRESS:localhost:8848}
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD}
# 配置A2A server的額外信息,如版本號,agentCard中的Skills等
server:
version: 1.0.1
card:
url: http://localhost:9999/a2a
skills:
- id: nacos-question-answer
name: Nacos Question Answer
description: Answer questions about Nacos.
tags:
- Nacos
examples:
- What is Nacos?
icon-url: https://img.alicdn.com/imgextra/i4/O1CN01rW3vAB1FDWKSOiFf0_!!6000000000453-2-tps-204-40.png
documentation-url: https://nacos.io
provider:
organization: Alibaba
url: https://www.alibaba.com
logging:
level:
root: debug
2.2.3 構建 A2A Server Agent 代碼
/**
* Spring AI Alibaba 啓動類
*/
@SpringBootApplication
publicclassA2aServerExampleApplication {
publicstaticvoidmain(String[] args) {
SpringApplication.run(A2aServerExampleApplication.class, args);
}
}
/**
* Spring AI Alibaba Agentic API構建LLMAgent
*/
@Configuration
publicclassRootAgentConfiguration {
privatestaticfinal String SYSTEM_PROMPT =
"An assistant or maintainer for nacos. You only try to answer nacos' question. "
+"If user ask not nacos relative question, Please answer with apology. \n When you answer Nacos' question, "
+"you can try to use relative tools to query data and do analyze. If no suitable tools found, please answer Nacos' question by your knowledge.\n";
@Bean
@Primary
public BaseAgent rootAgent(ChatModel chatModel) throws GraphStateException {
return ReactAgent.builder().name("Nacos Agent").description(
"Answer question about Nacos and do some maintain and query operation about Nacos Cluster.")
.model(chatModel).instruction(SYSTEM_PROMPT).outputKey("output").build();
}
}
至此,僅需 3 步完成 A2A Server Agent 的構建和開發,之後僅需啓動即可,如使用 mvn spring-boot:run,啓動成功後,在 Nacos 控制枱上即可查看到註冊的 AgentCard 並且能從詳情中查看到具體信息:
2.3 構建 A2A Client Agent
2.3.1 引入 pom
<properties>
<spring.ai.alibaba.version>1.0.0.4</spring.ai.alibaba.version>
<spring.boot.version>3.4.5</spring.boot.version>
</properties>
<dependencies>
<!-- 引入A2A Client starter -->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-a2a-client</artifactId>
<version>${spring.ai.alibaba.version}</version>
</dependency>
<!-- 引入A2A Nacos 註冊中心 -->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-a2a-registry</artifactId>
<version>${spring.ai.alibaba.version}</version>
</dependency>
<!-- 可選,引入web構建簡單的頁面 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
</dependencies>
2.3.2 添加配置文件 application.yml
server:
port: 8888
spring:
application:
name: a2s-client-example
ai:
alibaba:
a2a:
nacos:
# 開啓從Nacos中自動發現Agent
discovery:
enabled: true
server-addr: ${NACOS_ADDRESS:localhost:8848}
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD}
logging:
level:
root: debug
2.3.3 構建 A2A Client Agent 代碼
/**
* Spring AI Alibaba 啓動類
*/
@SpringBootApplication
public class A2aClientExampleApplication {
public static void main(String[] args) {
SpringApplication.run(A2aClientExampleApplication.class, args);
}
}
/**
* Spring AI Alibaba Agentic API構建LLMAgent
*/
@Configuration
public class RootAgentConfiguration {
@Bean
public BaseAgent rootAgent(AgentCardProvider agentCardProvider) throws GraphStateException {
return A2aRemoteAgent.builder()
// 傳入自動構建的Nacos AgentCard Provider
.agentCardProvider(agentCardProvider)
// 設置需要的Agent的名稱,Nacos AgentCard Provider會根據此名稱自動訂閲AgentCard和Agent的可訪問端點
.name("Nacos Agent")
.description("Answer Nacos questions or query and operate datum in Nacos.")
.inputKey("messages")
.outputKey("messages")
.build();
}
}
/**
* 構建簡單的訪問API.
*/
@RestController
@RequestMapping("/")
public class TestController {
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(TestController.class);
private final BaseAgent rootAgent;
public TestController(BaseAgent rootAgent) {
this.rootAgent = rootAgent;
}
@GetMapping("sync")
public Object sync(@RequestParam("question") String question) throws GraphStateException, GraphRunnerException {
System.out.println(question);
return rootAgent.invoke(Map.of("messages", List.of(new UserMessage(question)))).orElseThrow().value("messages")
.orElseThrow();
}
@GetMapping("stream")
public Flux<String> stream(@RequestParam("question") String question) throws GraphStateException, GraphRunnerException {
return rootAgent.stream(Map.of("messages", List.of(new UserMessage(question)))).mapNotNull(output -> {
LOGGER.debug("stream agent invoke : `{}`", output.toString());
if (output.isSTART() || output.isEND()) {
return null;
}
if (output instanceof StreamingOutput) {
return ((StreamingOutput) output).chunk();
}
return null;
}).publishOn(Schedulers.parallel());
}
}
同樣的,僅需 3 步就完成 A2A Client Agent 的構建和開發,之後僅需啓動即可,如使用 mvn spring-boot:run,啓動成功後,可通過瀏覽器訪問 localhost:8888/index.html 進行測試。
About Nacos
Nacos 致力於幫助您發現、配置和管理微服務。Nacos 提供了一組簡單易用的特性集,幫助您快速實現動態服務發現、服務配置、服務元數據及 AI 管理。
Nacos 幫助用户更敏捷和容易地構建、交付和管理雲原生 AI 應用的平台。 Nacos 是構建以“服務”為中心的現代應用架構(例如微服務範式、雲原生範式、AI 原生範式)的服務基礎設施。
Nacos 3.0 還有很多待完成的功能及大量待探索和開發的領域,歡迎大家掃碼加入 Nacos 社區羣及 Nacos MCP 社區討論羣,參與 Nacos 社區的貢獻和討論,在 Nacos 社區一起搭把手,讓你的代碼和能力有機會能在各行各業領域內進行釋放能量,期待認識你和你一起共建 Nacos 社區。
“Nacos 相信一切都是服務,每個服務節點被構想為一個星球,每個服務都是一個星系;Nacos 致力於幫助這些服務建立連接賦予智能,助力每個有面向星辰的夢想能夠透過雲層,飛在雲上,更好的鏈接整片星空。”
Nacos 官網:https://nacos.io/
Nacos 倉庫地址:https://github.com/alibaba/nacos
“Nacos 社區羣6”羣的釘釘羣號:145925004742
“Nacos MCP 社區討論羣2”羣的釘釘羣號:115205016856
相關鏈接:
[1] nacos-group/nacos-spring-ai-alibaba-example
https://github.com/nacos-group/nacos-spring-ai-alibaba-example
[2] Nacos 快速開始
https://nacos.io/docs/latest/quickstart/quick-start/
[3] Nacos Docker 快速開始
https://nacos.io/docs/latest/quickstart/quick-start-docker/
[4] 文檔
https://bailian.console.aliyun.com/?spm=5238cd80.238ed193.0.0...
點擊此處,進一步瞭解 Nacos。