All Products
Search
Document Center

Microservices Engine:Integrate AgentScope with Nacos AI Registry to Use Skills

Last Updated:Aug 27, 2026

Use Skill packages from Nacos AI Registry as the skill source for AgentScope. Through NacosSkillRepository, an agent can directly download a Skill ZIP from Nacos and load it as an AgentSkill for use.

Prerequisites

  • An Alibaba Cloud Microservices Engine (MSE) AI Governance Center instance is activated, and a workspace has been created.

  • An AccessKey ID and AccessKey Secret are prepared, and the RAM user has been granted Skill-related read permissions. For details, see Configure RAM permissions for AI Governance Center.

  • Complete network access configuration based on your Agent's runtime environment:

  • AgentScope 1.0.12+, JDK 17+, and Maven 3.8+.

Information

  • Maven Artifact:io.agentscope:agentscope-extensions-nacos-skill

  • AgentScope:1.0.12+

  • Dependencies:io.agentscope:agentscope-core,com.alibaba.nacos:nacos-client

  • JDK:JDK 17+

  • Notice:NacosSkillRepository is automatically processed.

Example

The following is an end-to-end runnable example showing the complete flow from initializing the Nacos connection to starting an agent conversation. Replace SERVER_ADDR with the public endpoint domain or VPC private domain:

import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.ai.AiFactory;
import com.alibaba.nacos.api.ai.AiService;
import io.agentscope.core.ReActAgent;
import io.agentscope.core.model.DashScopeChatModel;
import io.agentscope.core.nacos.skill.NacosSkillRepository;
import io.agentscope.core.skill.AgentSkill;
import io.agentscope.core.skill.SkillBox;
import java.util.Properties;

public class NacosSkillDemo {

    public static void main(String[] args) throws Exception {
        // 1. Create AiService
        Properties props = new Properties();
        props.put(PropertyKeyConst.SERVER_ADDR, "airegistry.cn-hangzhou.mse.aliyuncs.com:80");
        props.put(PropertyKeyConst.NAMESPACE, "your-namespace-id");
        props.put(PropertyKeyConst.ACCESS_KEY, "your-access-key");
        props.put(PropertyKeyConst.SECRET_KEY, "your-secret-key");

        AiService aiService = AiFactory.createAiService(props);

        // 2. Create NacosSkillRepository and load a Skill
        try (NacosSkillRepository repo = new NacosSkillRepository(aiService, "public")) {
            AgentSkill skill = repo.getSkill("safe-commit-helper");
            System.out.println("Loaded: " + skill.getName());
            System.out.println("Description: " + skill.getDescription());

            // 3. Bind to Agent
            // SkillBox reads Skills from the repository on demand. The getSkill call above
            // demonstrates that a Skill exists; the SkillBox itself uses the repository
            // directly when the agent invokes tool calls during conversation.
            SkillBox skillBox = new SkillBox(repo);

            var model = DashScopeChatModel.builder()
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .modelName("qwen-max")
                    .build();

            var agent = ReActAgent.builder()
                    .name("DevAssistant")
                    .systemPrompt("You are a programming assistant.")
                    .model(model)
                    .skillBox(skillBox)
                    .build();

            // 4. Use the Agent
            var response = agent.call(io.agentscope.core.message.Msg.of("Help me generate a commit message"));
            System.out.println(response.getText());
        } finally {
            aiService.shutdown();
        }
    }
}

Step-by-Step Guide

1. Add Dependencies

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.agentscope</groupId>
    <artifactId>agentscope-extensions-nacos-skill</artifactId>
</dependency>

For version management, use agentscope-bom:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.agentscope</groupId>
            <artifactId>agentscope-bom</artifactId>
            <version>1.0.12</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
Note

NacosSkillRepository requires io.agentscope:agentscope-core, com.alibaba.nacos:nacos-client, and JDK 17+.

2. Initialize AiService

Create a Nacos AiService instance and configure the AI Governance Center access address and credentials. SERVER_ADDR can be the public endpoint domain or VPC private domain:

import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.ai.AiFactory;
import com.alibaba.nacos.api.ai.AiService;
import java.util.Properties;

Properties props = new Properties();
props.put(PropertyKeyConst.SERVER_ADDR, "airegistry.cn-hangzhou.mse.aliyuncs.com:80");
props.put(PropertyKeyConst.NAMESPACE, "your-namespace-id");
props.put(PropertyKeyConst.ACCESS_KEY, "LTAI5tXXXXXXXXXXXXXX");
props.put(PropertyKeyConst.SECRET_KEY, "XXXXXXXXXXXXXXXXXXXXxx");

AiService aiService = AiFactory.createAiService(props);

A single AiService instance corresponds to one namespace. If you need to access multiple namespaces, create a separate instance for each. Reuse instances within the same application and call aiService.shutdown() on exit to release resources.

3. Create NacosSkillRepository and Load a Skill

Create a NacosSkillRepository instance using try-with-resources:

import io.agentscope.core.nacos.skill.NacosSkillRepository;
import io.agentscope.core.skill.AgentSkill;

try (NacosSkillRepository repo = new NacosSkillRepository(aiService, "public")) {
    String name = "safe-commit-helper";
    if (repo.skillExists(name)) {
        AgentSkill skill = repo.getSkill(name);
        System.out.println(skill.getName() + " - " + skill.getDescription());
    } else {
        System.out.println("Skill not found: " + name);
    }
}

If namespaceId is empty or null, "public" is used automatically. The skillExists check verifies the Skill before downloading; if it returns false, check the Skill name and namespace.

Note

The YAML frontmatter in SKILL.md exported by Nacos may have multi-line indentation. NacosSkillRepository automatically handles this by flattening to a single-line format — no manual intervention is required. SKILL.md is the skill definition file published to Nacos.

4. Bind Skills to the Agent

Load Skills from the repository into the agent through SkillBox:

import io.agentscope.core.skill.SkillBox;
import io.agentscope.core.ReActAgent;
import io.agentscope.core.model.DashScopeChatModel;

SkillBox skillBox = new SkillBox(repo);

var model = DashScopeChatModel.builder()
        .apiKey(System.getenv("DASHSCOPE_API_KEY"))
        .modelName("qwen-max")
        .build();

var agent = ReActAgent.builder()
        .name("MyAgent")
        .systemPrompt("You are an intelligent assistant.")
        .model(model)
        .skillBox(skillBox)
        .build();

To verify the agent can use the Skill, send a test message and check that the response reflects Skill-generated content:

var response = agent.call(io.agentscope.core.message.Msg.of("Help me review my code."));
System.out.println(response.getText());

Version and Label Configuration

skillVersion and skillLabel control which version of a Skill the repository downloads. Use a version to lock a specific release — this ensures reproducible behavior in production. Use a label to track a rolling target — for example, a "stable" label that points to the latest verified release, which is useful in test or staging environments.

Each value is resolved according to the following priority — the first non-empty value takes effect:

Priority

Source

Configuration Key

1 (highest)

Properties passed to constructor

agentscope.nacos.skill.version / agentscope.nacos.skill.label

2

JVM system properties

Same as above

3 (lowest)

Environment variables

AGENTSCOPE_NACOS_SKILL_VERSION / AGENTSCOPE_NACOS_SKILL_LABEL

Download API Selection

NacosSkillRepository automatically selects the download method based on version and label (version takes priority):

  1. If skillVersion is non-empty → AiService.downloadSkillZipByVersion(name, version)

  2. Otherwise, if skillLabel is non-empty → AiService.downloadSkillZipByLabel(name, label)

  3. Otherwise → AiService.downloadSkillZip(name)

Load by Version

Properties appProps = new Properties();
appProps.setProperty(NacosSkillRepository.SKILL_VERSION_PATH, "v1.0.0");

try (NacosSkillRepository repo =
             new NacosSkillRepository(aiService, "public", appProps)) {
    AgentSkill skill = repo.getSkill("safe-commit-helper");
}

Load by Label

Properties appProps = new Properties();
appProps.setProperty(NacosSkillRepository.SKILL_LABEL_PATH, "stable");

try (NacosSkillRepository repo =
             new NacosSkillRepository(aiService, "public", appProps)) {
    AgentSkill skill = repo.getSkill("safe-commit-helper");
}

Via Environment Variables

export AGENTSCOPE_NACOS_SKILL_VERSION=v1.0.0
# or
export AGENTSCOPE_NACOS_SKILL_LABEL=stable

Via JVM System Properties

java -Dagentscope.nacos.skill.version=v1.0.0 -jar myapp.jar

Priority Example

When Properties, JVM properties, and environment variables are all set, the value in Properties takes precedence:

// JVM: -Dagentscope.nacos.skill.version=jvm-ver
// ENV:  AGENTSCOPE_NACOS_SKILL_VERSION=env-ver

Properties props = new Properties();
props.setProperty(NacosSkillRepository.SKILL_VERSION_PATH, "app-ver");

// "app-ver" takes effect here
NacosSkillRepository repo = new NacosSkillRepository(aiService, "public", props);
repo.getSkill("my-skill");  // actually calls downloadSkillZipByVersion("my-skill", "app-ver")

When both version and label are configured, version takes priority and label is ignored.

API Reference

Core class: io.agentscope.core.nacos.skill.NacosSkillRepository, implementing the AgentSkillRepository interface.

Capability

Method

Status

Description

Load a single Skill

getSkill(name)

Supported

Download ZIP → adapt frontmatter → build AgentSkill

Check if Skill exists

skillExists(name)

Supported

Determined by download result / NOT_FOUND error code

Get repository metadata

getRepositoryInfo()

Supported

Type is always nacos, location is namespace:<namespaceId>

Get source identifier

getSource()

Supported

Format: nacos:<namespaceId>

Writeable declaration

isWriteable()

Always false

setWriteable() is ignored and prints a warning

List all Skills

getAllSkillNames() / getAllSkills()

Not yet implemented

Returns an empty collection, prints a warning. Planned for a future release.

Write operations

save() / delete()

Not yet implemented

Returns false, prints a warning. Planned for a future release.

Environment Variables Reference

Variable

Default

Description

AGENTSCOPE_NACOS_SKILL_VERSION

None

Specify Skill version (optional)

AGENTSCOPE_NACOS_SKILL_LABEL

None

Specify Skill label (optional)