Skip to main content

dify-kb-mcp

MCP server that exposes Dify knowledge base retrieval as agent tools.

Two tools, both read-only:

Tool What it does
search_knowledge Semantic search across one or more datasets, returns the best passages with scores
list_knowledge_bases Lists datasets with document counts and retrieval settings

Install

uvx dify-kb-mcp
# or
pip install dify-kb-mcp

Configure

Variable Required Default Notes
DIFY_API_BASE no http://localhost:5001/v1 Your Dify API base, e.g. https://dify.example.com/v1
DIFY_DATASET_TOKEN yes – Dataset API key from Dify → 知识库 → API
DIFY_RERANK no 0 1 enables reranking when the dataset has it configured
DIFY_RERANK_PROVIDER no huggingface_tei Rerank provider name
DIFY_RERANK_MODEL no bge-reranker-base Rerank model name
DIFY_MAX_RESULT_CHARS no 3000 Result truncation limit

MCP client config

{
  "mcpServers": {
    "dify-kb": {
      "command": "uvx",
      "args": ["dify-kb-mcp"],
      "env": {
        "DIFY_API_BASE": "https://dify.example.com/v1",
        "DIFY_DATASET_TOKEN": "dataset-xxxxxxxx"
      }
    }
  }
}

Behaviour notes

  • Only datasets with at least one document are searched.
  • Each dataset's own retrieval settings (search method, score threshold) are respected; only reranking is overridden by DIFY_RERANK.
  • If reranking is requested but the rerank service is down, the request is retried once without reranking instead of failing.
  • Errors (bad token, unreachable host) are returned as readable text rather than raised, so the agent can explain them to the user.

License

MIT

Metadata

Release files for dify-kb-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dify-kb-mcp 0.1.0
File Size Uploaded Provenance
dify_kb_mcp-0.1.0.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dify-kb-mcp 0.1.0
File Interpreter ABI Platform
dify_kb_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / dify_kb_mcp-0.1.0.tar.gz

Download URL dify_kb_mcp-0.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
785aeaec3609cdf759a96fca36dd1be54dab9cb44d1783133a95bb5b7b20cb13
BLAKE2b-256 checksum
How to use checksums
86ac2385c87b282bbfc78e85279cc9773d60806fc88d05240222426776f7fc7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / dify_kb_mcp-0.1.0-py3-none-any.whl

Download URL dify_kb_mcp-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4776e70e33b9b55aced16ce2668b003e5f744de70161f01a12e217849cd75013
BLAKE2b-256 checksum
How to use checksums
57b1051b8a4b3b50536800c6a1b906190502e0165dddc65cbd86bb85c130c95e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for dify-kb-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page