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 (推薦)
全域安裝
從源碼構建
功能特性
🔍 查詢 Dify 外部知識庫
📊 支援相關性分數閾值設定
🎯 支援元數據條件篩選
🔐 使用環境變數管理 API 憑證
📦 支援 npx 直接運行
🌐 知識庫 ID 透過環境變數配置,無需每次指定
配置
或者使用本地路徑(開發時):
使用命令列參數:
使用方法
可用工具
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):
範例輸出:
開發
開發模式運行
構建專案
運行構建版本
API 參考
本專案使用 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: 內部伺服器錯誤
專案結構
授權
MIT
貢獻
歡迎提交 Issue 和 Pull Request!