Integrate RAG knowledge bases with Dify, Coze, n8n, LangChain, and other platforms
RAG knowledge bases provide standard APIs and the MCP protocol to integrate with mainstream AI application development platforms.
Dify supports integration via External Knowledge sources.
Coze supports integration via MCP or custom API plugins.
Method 1: MCP Integration
Add an MCP tool in Coze Bot settings:
n8n can call the RAG retrieval API using the HTTP Request node:
Use as a custom Retriever in LangChain:
Dify
Dify supports integration via External Knowledge sources.
1
Obtain API Information
In the Bailian console, go to the Service Channels page and copy the DashScope API Endpoint and API Key.
2
Configure Dify
In Dify’s Knowledge Base settings, select External Knowledge, then fill in:
- API Endpoint: DashScope retrieval endpoint URL
- API Key: Your DashScope API Key
- Knowledge Base ID: Target knowledge base ID
3
Use in Workflows
In Dify workflows or chat applications, select this external knowledge base as the retrieval source.
Coze
Coze supports integration via MCP or custom API plugins.
Method 1: MCP Integration
Add an MCP tool in Coze Bot settings:
- Select Add MCP Tool
- Enter the MCP Server URL and authentication details (obtained from the Service Channels page in the console)
- Select the retrieval / Q&A capabilities to expose
- Create a custom plugin in Coze
- Configure an HTTP request pointing to the DashScope retrieval endpoint
- Map input parameters (
query,top_k) and output parameters (list of chunks)
n8n
n8n can call the RAG retrieval API using the HTTP Request node:
- Add an HTTP Request node
- Set method to POST and enter the retrieval endpoint URL (see details below)
- In Headers, add
Authorization: Bearer <API-Key> - Fill in retrieval parameters in the Body
- Knowledge Search (application-level, recommended):
https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/knowledge/search
Parameters:queryandagent_id; retrieval strategy is driven by the knowledge retrieval service configuration. - Low-Level Retrieval:
https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/retrieve
Parameters:index_id,query,top_k; directly specifies the knowledge base ID.
LangChain
Use as a custom Retriever in LangChain:
The above code is for illustration only. When using in production, add proper error handling and retry logic.