Dify External Knowledge MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Dify External Knowledge MCP ServerSearch the knowledge base for information about our new product launch"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Dify External Knowledge MCP Server
一個 Model Context Protocol (MCP) 伺服器,用於整合 Dify 外部知識庫 API,讓 AI Agent 能夠輕鬆查詢知識庫內容。
安裝
使用 npx (推薦)
npx @funtuantw/dify-external-knowledge-mcp全域安裝
npm install -g @funtuantw/dify-external-knowledge-mcp從源碼構建
git clone https://github.com/funtuantw/dify-external-knowledge-mcp.git
cd dify-external-knowledge-mcp
npm install
npm run buildRelated MCP server: Candlekeep
功能特性
🔍 查詢 Dify 外部知識庫
📊 支援相關性分數閾值設定
🎯 支援元數據條件篩選
🔐 使用環境變數管理 API 憑證
📦 支援 npx 直接運行
🌐 知識庫 ID 透過環境變數配置,無需每次指定
配置
{
"mcpServers": {
"dify-knowledge": {
"command": "npx",
"args": ["@funtuantw/dify-external-knowledge-mcp"],
"env": {
"DIFY_KNOWLEDGE_ENDPOINT": "https://your-endpoint.com",
"DIFY_API_KEY": "your-api-key-here",
"DIFY_KNOWLEDGE_ID": "your-knowledge-id-here"
}
}
}
}或者使用本地路徑(開發時):
{
"mcpServers": {
"dify-knowledge": {
"command": "node",
"args": ["/absolute/path/to/dify-external-knowledge-mcp/dist/index.js"],
"env": {
"DIFY_KNOWLEDGE_ENDPOINT": "https://your-endpoint.com",
"DIFY_API_KEY": "your-api-key-here",
"DIFY_KNOWLEDGE_ID": "your-knowledge-id-here"
}
}
}
}使用命令列參數:
{
"mcpServers": {
"dify-knowledge": {
"command": "npx",
"args": [
"@funtuantw/dify-external-knowledge-mcp",
"--endpoint",
"https://your-endpoint.com",
"--api-key",
"your-api-key-here",
"--knowledge-id",
"your-knowledge-id-here"
]
}
}
}使用方法
可用工具
query_dify_knowledge
查詢 Dify 外部知識庫以檢索相關資訊。
參數:
query(必需, string): 用戶的搜尋查詢或問題top_k(可選, number): 返回的最大結果數量(預設:5)score_threshold(可選, number): 最小相關性分數閾值,範圍 0-1(預設:0.5)metadata_condition(可選, object): 元數據篩選條件logical_operator(可選, string): "and" 或 "or"(預設:and)conditions(必需, array): 條件列表name(必需, string[]): 要篩選的元數據欄位名稱comparison_operator(必需, string): 比較運算符(contains, is, not contains, etc.)value(可選, string): 比較值
範例使用(通過 AI Agent):
請使用 query_dify_knowledge 工具查詢 "什麼是 Dify?"範例輸出:
Found 2 result(s) for query: "什麼是 Dify?"
### Result 1 (Score: 0.980)
**Title**: knowledge.txt
**Content**:
Dify 是一個 LLMOps 平台,提供 GenAI 應用程序的創新引擎。
**Metadata**: {
"path": "s3://dify/knowledge.txt",
"description": "dify 知識文檔"
}
---
### Result 2 (Score: 0.660)
**Title**: introduce.txt
**Content**:
GenAI 應用程序的創新引擎
**Metadata**: {
"path": "s3://dify/introduce.txt",
"description": "dify 介紹"
}
---開發
開發模式運行
npm run dev構建專案
npm run build運行構建版本
npm startAPI 參考
本專案使用 Dify 外部知識庫 API。
支援的比較運算符
contains: 包含某個值not contains: 不包含某個值start with: 以某個值開頭end with: 以某個值結尾is: 等於某個值is not: 不等於某個值empty: 為空not empty: 不為空=: 等於≠: 不等於>: 大於<: 小於≥: 大於等於≤: 小於等於before: 在某個日期之前after: 在某個日期之後
錯誤處理
伺服器會處理以下錯誤情況:
1001: 無效的 Authorization 頭格式
1002: 授權失敗
2001: 知識庫不存在
HTTP 403: 訪問被拒絕
HTTP 500: 內部伺服器錯誤
專案結構
dify-external-knowledge-mcp/
├── src/
│ └── index.ts # MCP 伺服器主程式
├── dist/ # 編譯後的輸出
├── .env.example # 環境變數範例
├── .gitignore
├── package.json
├── tsconfig.json
├── plan.md # 專案計畫文檔
└── README.md授權
MIT
貢獻
歡迎提交 Issue 和 Pull Request!
相關連結
Available Tools
1 toolquery_dify_knowledgeC
Query Dify external knowledge base to retrieve relevant information based on a search query. Returns ranked documents with content, scores, titles, and metadata.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | User's search query or question | |
| top_k | No | Maximum number of results to return (default: 5) | |
| score_threshold | No | Minimum relevance score threshold (0-1, default: 0.5) | |
| metadata_condition | No | Optional metadata filtering conditions |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'returns ranked documents with content, scores, titles, and metadata,' which gives some output context, but fails to address critical behavioral aspects like rate limits, authentication requirements, error conditions, or whether it's a read-only operation. For a query tool with complex parameters, this leaves significant gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is efficiently structured in two sentences: the first states the purpose, and the second describes the return format. There's no redundant information, and it's front-loaded with the core functionality. A perfect score is withheld because the second sentence could be slightly more concise by integrating return details with the purpose statement.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (4 parameters with nested objects) and lack of annotations or output schema, the description is moderately complete. It covers the basic purpose and return format but misses behavioral details like error handling, performance characteristics, or examples. For a query tool with metadata filtering, more context would be beneficial to fully guide the agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description does not add any parameter-specific information beyond what's already documented in the input schema, which has 100% coverage. It mentions 'search query' generally but doesn't clarify parameter interactions or usage nuances. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Query Dify external knowledge base to retrieve relevant information based on a search query.' It specifies the verb (query), resource (Dify external knowledge base), and action (retrieve information). However, without sibling tools for comparison, it cannot demonstrate differentiation from alternatives, preventing a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives, prerequisites, or specific contexts. It simply states what the tool does without indicating scenarios where it's appropriate or inappropriate, leaving the agent with minimal usage direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v1.0.1- First observed
query_dify_knowledge
TDQS
With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined as querying a knowledge base, and no other tools exist to cause confusion.
Since there is only one tool, naming consistency is inherently perfect. The tool name 'query_dify_knowledge' follows a clear verb_noun pattern, and there are no other tools to compare it against for inconsistency.
A single tool is too few for a server that appears to handle external knowledge base operations, as it suggests limited functionality. Typically, such a domain would benefit from additional tools like create, update, or delete operations for knowledge management, making this feel incomplete.
The tool set is severely incomplete for a knowledge base server. While querying is a core function, there are obvious gaps such as tools for adding, updating, deleting, or listing knowledge base entries, which are essential for full lifecycle coverage in this domain.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Universal persistent memory and knowledge retrieval layer for AI agents and LLMs.
11Universal memory for AI agents and tools. Save, organize and search context anywhere.
Search your knowledge bases from any AI assistant using hybrid RAG.
Ingest, manage, and retrieve documents for RAG-powered AI applications
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants like Cursor to directly query and retrieve information from Dify knowledge bases through natural language.2266MIT
- AlicenseNot gradedqualityAmaintenanceA RAG knowledge base server that enables AI agents to search, retrieve, and manage technical documentation through the Model Context Protocol.7GPL 3.0
- AlicenseNot gradedqualityCmaintenanceExposes Dify knowledge base retrieval capabilities via MCP for use in Cursor and other MCP-compatible clients, enabling semantic search and document browsing.MIT
- FlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that exposes a hybrid RAG pipeline (dense+sparse retrieval with reranking) for querying an enterprise knowledge base, enabling autonomous agents to search and retrieve relevant information.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/funtuan/dify-external-knowledge-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server