dify-knowledge
dify knowledge mcp server
claude mcp add --transport stdio liiklin-dify-knowledge-mcp-server node /path/to/your/dify-knowledge-mcp-server/index.js \ --env DIFY_API_KEY="your_actual_api_key" \ --env DIFY_API_URL="https://api.dify.ai/v1/datasets/YOUR_DATASET_ID/documents/query"
How to use
This MCP server provides access to your Dify knowledge base via the MCP protocol, allowing an AI assistant (such as Cursor) to perform semantic, full-text, or hybrid searches against your knowledge content. After configuring the MCP server, Cursor can invoke the available tools to query the knowledge base and retrieve relevant documents. The primary tool exposed is query_dify_knowledge, which lets you search with a query string and specify options like top_k, search_method, and reranking. You can also run get_dify_config to verify the current Dify API configuration. The server is designed to keep your API keys secure by reading them from environment variables or an .env file rather than hard-coding them into source code.
How to install
Prerequisites:
- Node.js (supports ES modules) installed on your system
- Access to a Dify dataset with a valid API key
Step-by-step installation:
- Install dependencies
npm install
- Configure API information (choose one method):
- Using a .env file (recommended):
# Copy configuration template and edit
cp env.example .env
# Edit the .env file to set your values
# DIFY_API_URL=https://api.dify.ai/v1/datasets/YOUR_DATASET_ID/documents/query
# DIFY_API_KEY=your_actual_api_key
- Environment variables:
# Linux/Mac
export DIFY_API_URL="https:// api.dify.ai/v1/datasets/YOUR_DATASET_ID/documents/query"
export DIFY_API_KEY="your_actual_api_key"
# Windows
set DIFY_API_URL=https://api.dify.ai/v1/datasets/YOUR_DATASET_ID/documents/query
set DIFY_API_KEY=your_actual_api_key
- Command-line arguments (alternative):
node index.js --api-url="https://api.dify.ai/v1/datasets/YOUR_DATASET_ID/documents/query" --api-key="your_actual_api_key"
- Run the server
node index.js
Additional notes
Tips and common issues:
- Keep API keys secure by leveraging .env files or environment variables; never commit keys to version control.
- Ensure DIFY_API_URL points to the correct dataset documents query endpoint and that DIFY_API_KEY is valid.
- When configuring Cursor, use the exact MCP server name (e.g., dify-knowledge) and provide the correct path to your server script if you customize locations.
- If you encounter connectivity errors, verify network access to the Dify API endpoint and confirm the dataset ID exists.
- The server supports multiple search methods (semantic_search, full_text_search, hybrid_search) and can re-rank results to improve relevance; adjust settings via the query_dify_knowledge tool parameters.
- For debugging, test running node index.js locally to ensure the server starts and prints readiness messages like Ready to query knowledge base!.
Environment variables and configuration options:
- DIFY_API_URL: Endpoint to query Dify documents (required)
- DIFY_API_KEY: Your Dify API key (required)
- Any additional environment variables required by your implementation can be added to the mcp configuration under env.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.