dify-kb-search

20
0
Source

Search Dify Knowledge Base (Dataset) to get accurate context for RAG-enhanced answers.

Install

mkdir -p .claude/skills/dify-kb-search && curl -L -o skill.zip "https://mcp.directory/api/skills/download/1767" && unzip -o skill.zip -d .claude/skills/dify-kb-search && rm skill.zip

Installs to .claude/skills/dify-kb-search

About this skill

Dify Knowledge Base Search Skill

๐Ÿ” Search your Dify Knowledge Base to get accurate, contextual answers

This skill enables AI agents to query Dify datasets for RAG (Retrieval-Augmented Generation) context retrieval. Perfect for knowledge base Q&A, documentation search, and contextual AI responses.

Dify Knowledge Base

โœจ Features

  • List Knowledge Bases - Discover all available Dify datasets
  • Smart Search - Query datasets with hybrid, semantic, or keyword search
  • Auto-Discovery - Automatically find available datasets if ID not provided
  • Configurable Results - Adjust top-k, search method, and reranking
  • Error Handling - Graceful error messages for debugging
  • Zero Hardcoding - All configuration via environment variables

๐Ÿš€ Quick Start

1. Configure Environment Variables

Set up in openclaw.json:

{
  "env": {
    "vars": {
      "DIFY_API_KEY": "${DIFY_API_KEY}",
      "DIFY_BASE_URL": "https://dify.example.com/v1"
    }
  }
}

Environment Variables:

VariableRequiredDefaultDescription
DIFY_API_KEYโœ… Yes-Your Dify API Key (from Settings โ†’ API)
DIFY_BASE_URLโŒ Nohttp://localhost/v1Your Dify instance base URL

2. Install Dependencies

pip3 install requests

๐Ÿ› ๏ธ Tools

dify_list

Lists all available knowledge bases (datasets) in your Dify instance.

Invocation: dify_list tool

Example Response:

{
  "status": "success",
  "count": 2,
  "datasets": [
    {
      "id": "dataset-abc123",
      "name": "Product Documentation",
      "doc_count": 42,
      "description": "All product guides and tutorials"
    },
    {
      "id": "dataset-xyz789",
      "name": "API Reference",
      "doc_count": 156,
      "description": "REST API documentation"
    }
  ]
}

Usage:

{}

dify_search

Searches a Dify Dataset for relevant context chunks.

Invocation: dify_search tool (mapped to python3 scripts/search.py)

Parameters:

ParameterTypeRequiredDefaultDescription
querystringโœ… Yes-Search query or question
dataset_idstringโŒ NoAuto-discoverSpecific dataset ID to search
top_kintegerโŒ No3Number of results to return
search_methodstringโŒ Nohybrid_searchSearch strategy
reranking_enablebooleanโŒ NofalseEnable reranking for better results

Search Methods:

  • hybrid_search - Combine semantic + keyword search (recommended)
  • semantic_search - Meaning-based similarity search
  • keyword_search - Exact keyword matching

Example Usage:

{
  "query": "How do I configure OpenClaw?",
  "top_k": 5
}
{
  "query": "API authentication methods",
  "dataset_id": "dataset-xyz789",
  "search_method": "semantic_search",
  "reranking_enable": true
}

Example Response:

{
  "status": "success",
  "query": "How do I configure OpenClaw?",
  "dataset_id": "dataset-abc123",
  "count": 3,
  "results": [
    {
      "content": "To configure OpenClaw, edit the openclaw.json file...",
      "score": 0.8923,
      "title": "Installation Guide",
      "document_id": "doc-001"
    },
    {
      "content": "OpenClaw supports environment variables via...",
      "score": 0.8451,
      "title": "Configuration Options",
      "document_id": "doc-002"
    }
  ]
}

๐Ÿ“‹ Complete Workflow Example

[
  {
    "tool": "dify_list",
    "parameters": {}
  },
  {
    "tool": "dify_search",
    "parameters": {
      "query": "What are the system requirements?",
      "top_k": 5,
      "search_method": "hybrid_search"
    }
  }
]

๐Ÿ”ง Troubleshooting

Common Errors

ErrorSolution
Missing DIFY_API_KEYSet DIFY_API_KEY in environment variables
Connection refusedCheck DIFY_BASE_URL is correct and accessible
No datasets foundVerify dataset exists in your Dify workspace
API request failedCheck network connectivity and API key permissions

Debug Mode

Run manually to see detailed errors:

DIFY_API_KEY=your-key python3 scripts/search.py <<< '{"query":"test"}'

๐Ÿ“š Integration Tips

RAG Pipeline Integration

# Example: Use search results in AI response
results = dify_search(query, top_k=5)
context = "\n".join([r["content"] for r in results["results"]])
final_prompt = f"Answer based on context:\n\n{context}\n\nQuestion: {query}"

Multiple Datasets

For searching across multiple datasets, loop through them:

{
  "query": "Find information about authentication",
  "dataset_id": "dataset-api-docs"
}

Then query another dataset separately.

๐Ÿ”’ Security

  • Never commit API keys - Use environment variables or .env files
  • Rotate keys regularly - Generate new keys in Dify Settings
  • Restrict access - Limit API key permissions where possible

๐Ÿ“– Implementation Details

This skill uses the Dify Dataset API:

  • List Datasets: GET /v1/datasets
  • Search: POST /v1/datasets/{id}/retrieve

For API documentation, see: https://docs.dify.ai/reference/api-reference

๐Ÿ“ Changelog

v1.1.0 (2026-02-08):

  • โœ… Added search method selection (hybrid/semantic/keyword)
  • โœ… Added reranking support
  • โœ… Auto-discovery of datasets
  • โœ… Improved error handling
  • โœ… Removed hardcoded URLs (fully configurable)
  • โœ… Added detailed logging

v1.0.0 (2026-02-06):

  • Initial release
  • Basic list and search functionality

More by openclaw

View all โ†’

seedream-image-gen

openclaw

Generate images via Seedream API (doubao-seedream models). Synchronous generation.

1333

nano-pdf

openclaw

Edit PDFs with natural-language instructions using the nano-pdf CLI.

6611

a-stock-analysis

openclaw

A่‚กๅฎžๆ—ถ่กŒๆƒ…ไธŽๅˆ†ๆ—ถ้‡่ƒฝๅˆ†ๆžใ€‚่Žทๅ–ๆฒชๆทฑ่‚ก็ฅจๅฎžๆ—ถไปทๆ ผใ€ๆถจ่ทŒใ€ๆˆไบค้‡๏ผŒๅˆ†ๆžๅˆ†ๆ—ถ้‡่ƒฝๅˆ†ๅธƒ๏ผˆๆ—ฉ็›˜/ๅฐพ็›˜ๆ”พ้‡๏ผ‰ใ€ไธปๅŠ›ๅŠจๅ‘๏ผˆๆŠข็ญน/ๅ‡บ่ดงไฟกๅท๏ผ‰ใ€ๆถจๅœๅฐๅ•ใ€‚ๆ”ฏๆŒๆŒไป“็ฎก็†ๅ’Œ็›ˆไบๅˆ†ๆžใ€‚Use when: (1) ๆŸฅ่ฏขA่‚กๅฎžๆ—ถ่กŒๆƒ…, (2) ๅˆ†ๆžไธปๅŠ›่ต„้‡‘ๅŠจๅ‘, (3) ๆŸฅ็œ‹ๅˆ†ๆ—ถๆˆไบค้‡ๅˆ†ๅธƒ, (4) ็ฎก็†่‚ก็ฅจๆŒไป“, (5) ๅˆ†ๆžๆŒไป“็›ˆไบใ€‚

448

trello

openclaw

Manage Trello boards, lists, and cards via the Trello REST API.

478

openai-whisper

openclaw

Local speech-to-text with the Whisper CLI (no API key).

557

ui-audit

openclaw

AI skill for automated UI audits. Evaluate interfaces against proven UX principles for visual hierarchy, accessibility, cognitive load, navigation, and more. Based on Making UX Decisions by Tommy Geoco.

187

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

282789

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

210415

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

201286

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

214231

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

169197

rust-coding-skill

UtakataKyosui

Guides Claude in writing idiomatic, efficient, well-structured Rust code using proper data modeling, traits, impl organization, macros, and build-speed best practices.

165173

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.