Nacos CLI User Guide
Nacos CLI is a command-line tool for Nacos configuration center, supporting configuration management, AI skill management, and interactive terminal mode.
1. Prerequisites
1.1. Runtime Requirements
- 64-bit OS, supporting Linux/Unix/Mac/Windows
- Nacos Server 2.x or 3.x
1.2. Ensure Nacos Server is Running
Before using Nacos CLI, please ensure your Nacos server is running properly. If you haven’t installed Nacos yet, please refer to Nacos Quick Start for installation and startup.
2. Install Nacos CLI
2.1. Install via Official Script (Recommended)
This is the simplest installation method. After installation, configure the Nacos address to start using it.
Linux / macOS:
curl -fsSL https://nacos.io/nacos-installer.sh | sudo bash -s -- --cliWindows (PowerShell):
iwr -UseBasicParsing https://nacos.io/nacos-installer.ps1 -OutFile $env:TEMP\nacos-installer.ps1; & $env:TEMP\nacos-installer.ps1 -cli; Remove-Item $env:TEMP\nacos-installer.ps12.2. Install via npm
If you already have a Node.js environment, you can install via npm:
# npm global installnpm install -g @nacos-group/clinacos-cli --help
# Or use npx without installationnpx @nacos-group/cli --help2.3. Verify Installation
nacos-cli --help3. Authentication Configuration
Nacos CLI supports two authentication methods:
3.1. Configuration File (Recommended)
To avoid entering authentication information every time, using a configuration file is recommended.
# Create configuration filecat > local.conf << EOFhost: <your_nacos_host>port: <your_nacos_port>username: <your_username>password: <your_password>namespace: ""EOF
# Use configuration filenacos-cli --config ./local.conf skill-listConfiguration File Format (YAML):
# Nacos server addresshost: <your_nacos_host>
# Nacos server portport: <your_nacos_port>
# Authentication type: nacos or aliyunauth_type: nacos
# Nacos authenticationusername: <your_username>password: <your_password>
# Alibaba Cloud authentication (optional)access_key: ""secret_key: ""
# Namespace ID (optional, leave empty for public)namespace: ""3.2. Command-Line Parameters
3.2.1. Nacos Authentication (Username/Password)
nacos-cli --host <host> --port <port> -u <username> -p <password>3.2.2. Alibaba Cloud Authentication (AccessKey/SecretKey)
If you are using Alibaba Cloud MSE Nacos, you can use AK/SK for authentication:
nacos-cli --host <host> --port <port> --auth-type aliyun --access-key <your_ak> --secret-key <your_sk>3.3. Configuration Priority
Configuration values are applied in the following priority order:
- Command-line parameters (highest priority)
- Configuration file
- Default values (lowest priority)
Example:
# Use configuration file but override hostnacos-cli --config ./local.conf --host <another_host> skill-list
# Use configuration file entirelynacos-cli --config ./local.conf skill-list4. Quick Start
Tip: The following examples assume a configuration file has been set up. See 3.1 Configuration File for details.
4.1. CLI Mode
Execute commands directly from the command line:
# List all skillsnacos-cli skill-list
# Get a skillnacos-cli skill-get <skill-name>
# Upload a skillnacos-cli skill-upload /path/to/skill4.2. Interactive Terminal Mode
Start an interactive session:
nacos-cliAfter entering interactive mode, you can execute the following commands:
nacos> skill-listnacos> skill-get <skill-name>nacos> config-listnacos> help5. Feature Modules
5.1. AI Skill Management ✅
Nacos CLI provides complete AI skill lifecycle management, including listing, downloading, uploading, and real-time synchronization.
5.1.1. List Skills
Get the list of AI skills stored in Nacos. By default, skill descriptions are displayed (truncated to 50 characters).
Command Format
nacos-cli skill-list [flags]Parameters
| Parameter | Short | Default | Description |
|---|---|---|---|
| —name | Filter by skill name | ||
| —page | 1 | Page number | |
| —size | 10 | Page size |
Usage Examples
# List all skills (with descriptions by default)nacos-cli skill-list
# Filter by namenacos-cli skill-list --name <skill-name>
# Interactive modenacos> skill-listnacos> skill-list --name <skill-name> --page 25.1.2. Get/Download Skills
Download skills from Nacos to a local directory, including skill metadata (SKILL.md) and all resource files.
Command Format
nacos-cli skill-get <skill-name> [flags]Parameters
| Parameter | Short | Default | Description |
|---|---|---|---|
| -o, —output | -o | ~/.skills | Output directory |
Usage Examples
# Download to default directory (~/.skills)nacos-cli skill-get <skill-name>
# Download to specified directorynacos-cli skill-get <skill-name> -o /custom/path
# Interactive modenacos> skill-get <skill-name>Skill Directory Structure The downloaded skill directory structure is as follows:
~/.skills/<skill-name>/├── SKILL.md # Skill metadata and instructions├── prompts/ # Prompt resources│ └── main.md└── scripts/ # Script resources └── init_skill.py5.1.3. Upload Skills
Upload local skills to Nacos, supporting single or batch uploads.
Command Format
nacos-cli skill-upload <path> [flags]Parameters
| Parameter | Default | Description |
|---|---|---|
| —all | false | Batch upload all skills in the directory |
Usage Examples
# Upload a single skillnacos-cli skill-upload /path/to/skill
# Batch uploadnacos-cli skill-upload --all /path/to/skills/folder
# Interactive modenacos> skill-upload /path/to/skillnacos> skill-upload --all /path/to/skills5.1.4. Real-time Skill Synchronization
Listen for skill changes in Nacos and automatically sync to the local directory. When a skill is updated in Nacos, local files are automatically updated.
Note:
skill-syncis only available in CLI mode and does not support interactive terminal mode.
Command Format
nacos-cli skill-sync <skill-name>... [flags]Parameters
| Parameter | Short | Default | Description |
|---|---|---|---|
| —all | false | Sync all skills | |
| -o, —output | -o | ~/.skills | Output directory |
Usage Examples
# Sync a single skillnacos-cli skill-sync <skill-name>
# Sync multiple skillsnacos-cli skill-sync <skill-name-1> <skill-name-2>
# Sync all skillsnacos-cli skill-sync --all
# Press Ctrl+C to stop syncing5.2. Configuration Management ✅
Provides configuration list queries and configuration content retrieval for the configuration center.
5.2.1. List Configurations
Get the configuration list from the Nacos configuration center, supporting filtering by dataId and group.
Command Format
nacos-cli config-list [flags]Parameters
| Parameter | Short | Default | Description |
|---|---|---|---|
| —data-id | Configuration ID (supports fuzzy search with * wildcard) | ||
| —group | Configuration group (supports fuzzy search) | ||
| —page | 1 | Page number | |
| —size | 10 | Page size |
Usage Examples
# List all configurationsnacos-cli config-list
# Filter by dataIdnacos-cli config-list --data-id "application*"
# Paginated querynacos-cli config-list --page 2 --size 20
# Interactive modenacos> config-listnacos> config-list --data-id <dataId> --page 25.2.2. Get Configuration
Get the configuration content for a specified dataId and group.
Command Format
nacos-cli config-get <dataId> <group> [flags]Parameters
| Parameter | Type | Description |
|---|---|---|
| dataId | string | Configuration ID, required |
| group | string | Configuration group, required |
Usage Examples
# CLI modenacos-cli config-get <dataId> <group>
# Interactive modenacos> config-get <dataId> <group>5.3. Service Registration (Naming) ❌
Service registration and discovery features are not yet implemented, including:
service-list- List servicesservice-get- Get service detailsinstance-list- List service instancesinstance-register- Register service instanceinstance-deregister- Deregister service instance
5.4. Distributed Lock (Lock) ❌
Distributed lock features are not yet implemented, including:
lock-acquire- Acquire distributed locklock-release- Release distributed lock
5.5. Contribution Guide
We welcome community developers to participate in building Nacos CLI! Feel free to submit Issues or Pull Requests on GitHub.
6. Interactive Terminal Commands
In interactive terminal mode, in addition to the commands above, the following terminal-specific commands are also supported:
| Command | Description |
|---|---|
help | Show all available commands |
server | Show current connected server information |
ns | Show current namespace |
ns <namespace> | Switch to specified namespace |
clear | Clear screen |
quit or exit | Exit terminal |
Usage examples:
nacos> help # Show helpnacos> server # View server informationnacos> ns # View current namespacenacos> ns <namespace> # Switch namespacenacos> clear # Clear screennacos> quit # Exit7. Global Parameters
The following parameters apply to all commands:
| Parameter | Short | Description |
|---|---|---|
| —host | Nacos server address | |
| —port | Nacos server port | |
| —username | -u | Username (Nacos authentication) |
| —password | -p | Password (Nacos authentication) |
| —auth-type | Authentication type: nacos or aliyun | |
| —access-key | AccessKey (Alibaba Cloud authentication) | |
| —secret-key | SecretKey (Alibaba Cloud authentication) | |
| —namespace | -n | Namespace ID |
| —config | -c | Configuration file path |
| —help | -h | Show help information |
8. API Compatibility
Nacos CLI supports both Nacos v1 and v3 APIs:
- Nacos 3.x: Preferentially uses v3 API, automatically handles Bearer Token authentication
- Nacos 2.x: Falls back to v1 API
The CLI automatically detects the server version and selects the appropriate API version without manual configuration.
9. FAQ
9.1. Login Failed
Problem: “Login failed” error when executing commands
Solution:
- Verify the Nacos server address and port are correct
- Verify the username and password are correct
- Verify whether authentication is enabled on the Nacos server
9.2. Connection Timeout
Problem: Command execution timeout
Solution:
- Check if the network connection is working properly
- Verify the Nacos server is running normally
- Check firewall settings
9.3. Namespace Not Found
Problem: Namespace not found error
Solution:
- Use the
nscommand to check the current namespace - Confirm the namespace ID is correct in the Nacos console
- Note: The namespace ID is not the namespace name