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 validationAlibaba Cloud Bailian Agent platform.

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 RAG 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.

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

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 RAG 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

In Qoder, Claude Code, and other AI coding tools, you can plug the Knowledge Base in as a skill package:
  1. Download the Skill config file from Service Channels → Agent Skill in the console.
  2. Drop it into your project's .skill/ directory.
  3. The AI coding tool detects it and loads the Knowledge Base retrieval capability.
If your application is built on Dify, Coze, or another third-party platform, see Third-Party Integration for setup guides.