Dify's four-box PDF chatbot, plugged into Claude Code (the setup, the switch, the one line)
The short version
Dify is a drag-and-drop canvas for building AI apps: you put boxes on a screen, join them with lines, and get a chatbot or a workflow without writing code. It has 159,268 GitHub stars and is made by LangGenius; its founder and CEO is Luyu Zhang, whose stated goal is to "put this technology in everyone's hands, not just the most well-resourced corporations." Claude Code works for you; Dify builds a bot that other people (your customers) can talk to. This guide gives you the four-box setup that turns a PDF into that bot on Dify's free cloud, then the one switch and the one line that let Claude Code ask the same bot questions. Below: what to click, the exact line, the free plan's limits, what running it yourself takes, and the licence. Source: Dify's docs (https://docs.dify.ai), pricing page (https://dify.ai/pricing) and GitHub repo (https://github.com/langgenius/dify), checked 23 Oct 2026.
| What | The number |
|---|---|
| GitHub stars | 159,268 (checked 23 Oct 2026) |
| Boxes on the canvas | 4: User Input, Knowledge Retrieval, LLM, Answer |
| Code you write | 0 |
| Free plan | 200 message credits (one-time), 5 apps, 50 Knowledge documents |
| Line that plugs it into Claude Code | 1 |
| Running it yourself | Docker, 2 CPU cores, 4 GB RAM |
| Licence | Dify's own licence: Apache 2.0 plus no multi-tenant hosting without a paid licence |
First: what you need
- A free account at https://cloud.dify.ai. New accounts start on the free Sandbox plan.
- Your PDF: a shop manual, an FAQ, a price list. Something your customers keep asking about.
- Claude Code, for the last step only. The bot itself needs no Claude Code at all.
Step 1: put your PDF into a Knowledge base
- In Dify, click Knowledge > Create > Create a ready-to-use knowledge base, and choose to upload a local file.
- Pick your PDF. Dify cuts it into small pieces ("chunks") so it can find the right passage later. The default chunk and search settings are fine for a first try.
- Wait until processing finishes. That's your bot's memory.
Step 2: drag the four boxes
- Go to Studio > Create from Blank and pick Chatflow (a chatbot built on the canvas). Give it a name, like "My Shop Help".
- Make the chain read like this, left to right (Dify's own docs name exactly these four):
- User Input: the customer's question comes in.
- Knowledge Retrieval: searches your Knowledge base for that question. Pick the Knowledge base from Step 1.
- LLM: the AI writes the reply. In its Context field, select the Knowledge Retrieval box's
result, and in its instruction, use theContextvariable, so it answers from your PDF. A simple instruction works: "Answer only from the context. If it isn't there, say you don't know." - Answer: sends the reply back to the customer.
- Click Preview and ask it something your PDF covers, like "What's your refund policy?". In chatflows, Dify shows the passage it used (citations) by default.
- Click Publish > Publish Update. You now have a chat link you can share. If you change anything later, publish again, or the change won't go live.
Which AI writes the reply? On the free cloud, new accounts get a starter allowance of AI credits for some models, so you don't need your own key to try it (set it under the model provider settings if the LLM box asks for a model).
Step 3: switch on the plug for Claude Code
- In your app, open the Access Point tab and find the MCP Server card. It's off by default.
- Switch it on. Dify gives you a unique server address (a link). MCP is a plug standard that lets AI tools like Claude Code use outside tools; this link turns your bot into one.
- Copy the link.
Copy this: the one line
Open your Terminal in your project folder (on a Mac: Cmd + Space, type Terminal) and paste, putting your link in place of the last part:
claude mcp add --transport http my-shop-bot <your Dify MCP link>
What it does: it adds your Dify bot to Claude Code as a tool called my-shop-bot, for this project. Then:
- Start Claude Code (
claude), type/mcpand check thatmy-shop-botshows as connected. - Ask in plain words: "Ask my-shop-bot what our refund policy is." Claude Code calls your bot, and the bot answers from your PDF.
Want it in every project, not just this one? Add --scope user after add.
To be plain about it: Dify's docs show this link being added to Claude Desktop and Cursor, not Claude Code.
claude mcp add --transport http <name> <url> is Claude Code's standard way to add any such web (HTTP) MCP link, so the same
link goes in this way.
The catch
- Your MCP link is a password. Dify's docs: "Your MCP Server URL contains authentication credentials, so treat it like an API key." Don't paste it in a chat, a screenshot or a public file. If it leaks, regenerate it on the same card: the old one stops working at once.
- The free plan is small. Dify's pricing page, Sandbox (free): 200 message credits, 5 apps, 50 Knowledge documents, 50 MB of Knowledge storage, 1 team member, 10 Knowledge requests a minute. Dify's quick-start says the 200 credits are a one-time allowance, not monthly. "Once they're used up, you can switch to your own API key": an API key is a paid password for an AI model, so after that you pay the AI company for each answer. Paid plans start with Professional.
- Running it yourself needs Docker. Docker is an app that runs other apps in sealed boxes. Dify's README asks for at
least 2 CPU cores and 4 GB of RAM and Docker Compose v2.24.0 or later, then:
and you finish setup atcd dify/docker cp .env.example .env docker compose up -dhttp://localhost/install. Fine for a technical friend; for week one, the free cloud is easier. - Keep it updated if you self-host. In May 2026 two critical security bugs were reported in Dify (CVE-2026-41947 and CVE-2026-41948) and fixed in version 1.14.2. The latest release on 23 Oct 2026 is 1.17.1 (10 Sep 2026). Old installs are risky, so update when new versions come out.
- The licence isn't plain Apache. Dify's code is on GitHub under its own licence, the "Dify Open Source License": Apache 2.0 plus two extra rules. Hosting it for many companies at once (multi-tenant) needs Dify's written OK, which means a paid licence, and you may not remove or change the Dify logo or copyright in the console or apps. Using it for your own shop is fine.
- It's a second tool. Claude Code can already read a PDF in your folder for you. Dify pays off when you want a bot other people can use, around the clock.
For builders
- Each Dify app gets its own MCP link, so you can plug several bots into Claude Code, each with its own name.
- Write a clear description for the app and its input: AI tools read it to decide when to call your bot.
- Dify can use Claude models as the LLM box too; pick them in the model provider settings with your own key.
Sources
- Dify repo: https://github.com/langgenius/dify (checked 23 Oct 2026; 159,268 stars, latest release 1.17.1)
- Licence: https://github.com/langgenius/dify/blob/main/LICENSE
- Publish as an MCP server (Access Point, the warning): https://docs.dify.ai/en/use-dify/publish/publish-mcp
- Knowledge Retrieval box (the four-box chain, citations): https://docs.dify.ai/en/use-dify/nodes/knowledge-retrieval
- Create a Knowledge base: https://docs.dify.ai/en/use-dify/knowledge/create-knowledge/introduction
- Quick start (200 one-time credits, Publish): https://docs.dify.ai/en/use-dify/getting-started/quick-start
- Free plan limits: https://dify.ai/pricing
- Founder quote: https://dify.ai/blog/dify-raises-30m-tomorrow-s-organizations-will-be-built-by-people-and-agents
- The May 2026 security fixes: https://www.wiz.io/vulnerability-database/cve/cve-2026-41948
- Claude Code MCP (adding an HTTP server): https://code.claude.com/docs/en/mcp