Skip to main content

Service Channels

API, MCP, CLI, Skill, and other integration paths.

Once a Knowledge Retrieval or Q&A service is published, you can integrate it into your application through several channels. The Service Channels page in the console shows the integration details and sample code for each one.

Channel comparison

ChannelProtocolBest forNotes
Dash APIREST / SSEBackend services you ownDashScope HTTP endpoints.
MCP ServerMCPAI Agent frameworksWorks with Qoder, Claude Code, Codex, and others.
Python SDKPythonPython appsWraps auth, retries, and stream parsing.
Java SDKJavaJava appsPulled in as a Maven dependency.
CLICommand lineLocal debugging, scripts, CIkscli — 34 commands covering Knowledge Base management, retrieval, and chat.
Agent SkillSkill packageQoder / Claude CodeIntegrate the Knowledge Base as a skill package.
Bailian AgentWebQuick validation / low-codeSupports Agent binding and Workflow binding in Alibaba Cloud Bailian.

Dash API

All retrieval and Q&A capabilities are exposed through the DashScope API at https://{workspaceId}.cn-beijing.maas.aliyuncs.com. Authentication:
Authorization: Bearer <API-Key>
Create an API Key in the Console API Key page. The system routes requests to the correct workspace based on the API Key. Main endpoints:
EndpointMethodPath
RetrievePOST/api/v1/indices/rag/index/retrieve
Q&APOST/api/v2/apps/knowledge/chat
Knowledge searchPOST/api/v1/indices/knowledge/search
See the API Reference for the full list.

MCP Server

MCP (Model Context Protocol) is an open protocol that lets AI coding assistants and Agent frameworks call external tools directly. After connecting to the Knowledge MCP Server, your AI assistant can retrieve from your Knowledge Bases mid-conversation.

Prerequisites

  • At least one Knowledge Base containing successfully parsed documents.
  • An API Key.
  • An MCP-compatible client (Qoder, Claude Code, Codex, etc.).

Setup

1

Get an API Key

Create an API Key in the Console API Key page. Store it as an environment variable:
export DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxx"
2

Add the MCP Server in your client

Pick the configuration that matches your client:
  • Qoder / QoderWork
  • Claude Code
  • Codex
Open the MCP config file and add:
{
  "mcpServers": {
    "rag_mcp": {
      "type": "streamableHttp",
      "url": "https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/mcp",
      "headers": {
        "Authorization": "Bearer ${DASHSCOPE_API_KEY}"
      }
    }
  }
}
3

Verify the connection

From your client, try invoking the Knowledge Base. For example, in Claude Code:
Search the knowledge base for "how to create a knowledge base"
If the assistant successfully calls the Retrieve tool and returns matches, the integration is working.

Connection details

ItemValue
Endpointhttps://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/mcp
Protocol versionMCP 2024-11-05
TransportStreamable HTTP (POST + GET SSE)
AuthAuthorization: Bearer <API-Key>

Tools

NameFunctionDescription
ListIndicesList Knowledge BasesPaginated list of Knowledge Bases in the current workspace, filterable by name prefix.
RetrieveRetrieve from a Knowledge BaseRetrieve relevant Chunks with hybrid search and Rerank.
Parameters for Retrieve:
ParameterTypeRequiredDefaultDescription
IndexIdstringYes—Knowledge Base index ID.
QuerystringYes—Query text; cannot be empty.
DenseSimilarityTopKintegerNo100Semantic retrieval recall count, range 0–100.
SparseSimilarityTopKintegerNo100Keyword retrieval recall count, range 0–100.
EnableRerankingbooleanNotrueWhether to apply reranking.
Rerank.ModelNamestringNoqwen3-rerankRerank model; either qwen3-rerank or qwen3-rerank-hybrid.
DenseSimilarityTopK + SparseSimilarityTopK must be no less than RerankTopN (default 5). Otherwise the call returns Index.InvalidParameter with the message dense_similarity_top_k + sparse_similarity_top_k >= rerank_top_n. For example, with the default RerankTopN, Dense=1 and Sparse=0 fails, while Dense=3 and Sparse=2 succeeds.
RerankMode, RerankMinScore, RerankTopN, and RerankInstruct on the Rerank object are not available in this version and will return an error if passed. Use EnableReranking and Rerank.ModelName to control reranking.
Parameters for ListIndices:
ParameterTypeRequiredDefaultDescription
pageNumberintegerNo1Page number, starting from 1.
pageSizeintegerNo10Items per page.
indexNamestringNo—Filter by Knowledge Base name prefix.
Supported clients:
  • Qoder / QoderWork
  • Claude Code
  • Codex (0.120.0+)
  • Alibaba Cloud Model Studio MCP custom integration (Agent)
  • Any other MCP-compatible client

CLI

kscli (Knowledge Studio CLI) is the command-line tool for Knowledge Bases. Its 34 commands span Knowledge Base setup, content maintenance, retrieval service management, and retrieval/chat. No code required — it fits local debugging, scripting, and CI/CD pipelines. The console Service Channels page provides the install command and usage examples.
This section covers Knowledge Studio CLI (kscli), a different tool from the Bailian CLI (bl). Bailian CLI uses bl knowledge search --agent-id <retrieval-service-id> --query "your query" to call a published retrieval service; --agent-id is not a Knowledge Base ID. Do not mix the two tools' installation, configuration, or commands.

Prerequisites

  • Node.js 20 or later.
  • At least one Knowledge Base containing successfully parsed documents.
  • An API Key.

Quickstart

1

Install the CLI

npm install -g knowledge-studio-cli
Run kscli --version to verify the installation.
2

Configure the API Key and workspace

Obtain the actual workspace ID (e.g., llm-xxxxxxxxxxxx) from Workspace Management in the console; see API endpoint. Replace ws-xxxxxxxx below with that ID. The API Key, Knowledge Base, and retrieval service must belong to this workspace. Once written to the config file, later commands no longer need these flags:
kscli config set --key api_key --value sk-xxxxxxxxxxxxxxxx
kscli config set --key workspace_id --value ws-xxxxxxxx
3

Run your first retrieval

List the retrieval services in the workspace, then retrieve with a service ID:
kscli service list --scene search
kscli search --query "your question" --agent-id aid-xxxxxxxx
The command prints the matched Chunks along with their relevance scores.

Common commands

CommandPurpose
kscli kb listList Knowledge Bases
kscli doc upload --file <path> --index-id <id>Upload files and import them into a Knowledge Base
kscli service list --scene searchList retrieval services and their IDs
kscli search --query <text> --agent-id <id>Run a semantic retrieval
kscli chat --message <text> --agent-id <id>Run a Knowledge conversation
kscli retrieve --index-id is the earlier direct-retrieval command and is now deprecated — it prints a deprecation warning when used. Use search instead: retrieval scope and strategy come from the service config behind --agent-id, which supports multiple Knowledge Bases, routing, and reranking.
For all 34 commands, parameter constraints, and output formats, see the CLI reference.

Agent Skill

Integrate your Knowledge Base as a skill package into AI coding tools such as Qoder or Claude Code. Install URL: https://skills.aliyun.com/skills/alibabacloud-bailian-rag-knowledgebase. You can also obtain this link on the console's Service Channels → Agent Skill page. Once installed, the AI coding tool automatically detects and loads Knowledge Base retrieval capabilities without manual configuration.

Bailian Agent

KnowledgeStudio Knowledge Bases can be integrated as external capabilities into Alibaba Cloud Bailian agent applications in two ways: Use this method for Agent 2.0 applications. The agent decides when to invoke the Knowledge Base according to its task plan, alongside other tools such as MCP.
  1. In the Bailian console, select Create Application → Agent Application → Agent 2.0.
  2. In the Knowledge Base section, select External Knowledge Base → KnowledgeStudio.
  3. Enter your API Key and Knowledge Base ID, then publish.

Method 2: Workflow binding

Use this method for workflow applications with ordered steps. KnowledgeStudio serves as a Knowledge Base Retrieval node in the workflow.
  1. In the Bailian console, select Create Application → Workflow Application.
  2. Drag a Knowledge Base Retrieval node onto the canvas and select KnowledgeStudio as the source.
  3. Connect the start, LLM, and end nodes, then publish the application.

Selection guidance

MethodBest for
Agent bindingDynamic tasks that require multi-step reasoning and autonomous decisions, such as enterprise Q&A or complex research.
Workflow bindingFixed processes that require strict execution order, such as report generation, customer-service routing, or diagnostic assistance.
If your application is built on Dify, Coze, or another third-party platform, see Third-Party Integration for setup guides.