mcpField
D
dify-knowledge-base-search

dify-knowledge-base-search

github.com/tiangong-aiData & databases11113 installsUpdated 1w ago
Repository

About dify-knowledge-base-search

dify-knowledge-base-search is a skill for retrieving dataset content through Dify. It guides users through request setup, response interpretation, and troubleshooting for knowledge retrieval workflows.

Key features

  1. 01Call the Dify dataset retrieval endpoint
  2. 02Set a query and optional top_k
  3. 03Interpret records in the response
  4. 04Troubleshoot authentication and route issues

Use cases

  1. 01Search a Dify dataset with a query
  2. 02Increase top_k when more records are needed
  3. 03Resolve API authentication or routing errors

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/tiangong-ai/agent-skills --skill dify-knowledge-base-search

After installing, type/dify-knowledge-base-searchin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

agents/
openai.yaml
assets/
example-request.json
references/
env.md
request-response.md
testing.md

Details

From the project README

Dify Knowledge Base Search

Prepare required inputs

  • Provide data as JSON containing query and optional retrieval_model.top_k.
  • Read these env vars:
    • DIFY_API_BASE_URL: base API URL and include /v1 (example: https://api.dify.ai/v1).
    • DIFY_DATASET_ID: target dataset ID.
    • DIFY_API_KEY: send as Authorization: Bearer <DIFY_API_KEY>.

Send request

  • Endpoint: ${DIFY_API_BASE_URL}/datasets/${DIFY_DATASET_ID}/retrieve
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <DIFY_API_KEY>
  • Use assets/example-request.json as the payload template.
curl -sS --location --request POST "$DIFY_API_BASE_URL/datasets/$DIFY_DATASET_ID/retrieve" \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $DIFY_API_KEY" \
  --data @assets/example-request.json

Interpret response

  • Request shape: { "query": string, "retrieval_model"?: { "top_k": number } }
  • Success shape: 200 with { query, records: [...] }
  • If records is empty, increase retrieval_model.top_k moderately and retry.

Troubleshoot quickly

  • If auth fails, verify DIFY_API_KEY and Authorization header format.
  • If route fails, verify DIFY_API_BASE_URL includes /v1.
  • If results are low quality, refine query and tune top_k.

References

  • references/env.md
  • references/request-response.md
  • references/testing.md

Assets

  • assets/example-request.json

Comments

Markdown supported