A Knowledge Base for AI in Drupal: RAG and MCP in Practice
A Drupal knowledge base is where a company maintains, approves, and keeps its knowledge current. An AI assistant built on it answers from content somebody stands behind, rather than from a pile of documents.
In Which Open-Source CMS Should You Choose for an AI Knowledge Base? I compare five systems. This article goes deeper into one of them: how to design a knowledge base in Drupal and connect it to AI through an API, RAG, and MCP.
Why build a knowledge base in Drupal
Drupal core already has what knowledge base management needs, and what other systems often add on the side:
- content types and fields: knowledge is a structured record, not a page of text,
- taxonomy: area, product, audience, confidentiality level,
- roles and permissions: who can read, edit, and approve knowledge,
- Content Moderation and Workflows: draft, review, approval, publication,
- revisions: a change history for every record, with author and date,
- multilingual content: translations stay together with the original,
- JSON:API: content is machine-readable with no extra development.
For AI this gives one important property: every answer can be traced to a specific version of a specific record, and to the person who approved it.
Content model: start from the knowledge
The most common mistake is to turn an existing website into the knowledge base. Pages written for visitors carry navigation, marketing copy, and repeated blocks; to search and AI, that is noise.
A dedicated content type for a knowledge article works better, with fields that make sense to both people and machines:
| Field | Purpose |
|---|---|
| Question or topic | One piece of knowledge per record, a clear heading |
| Answer | Self-contained text with no “see above” references |
| Area and product | Taxonomy for filtering during retrieval |
| Audience | Customer, partner, employee |
| Validity | Review date, optionally an expiry date |
| Owner | Who is responsible for the knowledge |
Shorter, self-contained records behave better in RAG than long documents: retrieval returns more precise passages, and metadata lets the answer be narrowed to the right product or audience.
Governance: who approved the knowledge
AI may work only with published content. In Drupal, an approval workflow ensures that: an editor prepares a draft, the owner of the area approves it, and only the published revision reaches the index or the agent.
The same rules apply to an AI agent. It can prepare a draft article or a revision, but a human confirms publication and changes to approved content. Drupal records who created and changed what, so the audit trail remains.
Knowledge base API: JSON:API and webhooks
A knowledge base API is the first integration layer. JSON:API in Drupal core exposes knowledge records with their fields, taxonomy, and relationships; permissions are evaluated for the account the client signs in with.
A RAG indexer, a website chatbot, or another internal system reads content through the API. Drupal can notify a downstream service when content changes, so the record is re-indexed and the index does not drift from its source.
Knowledge base RAG: retrieval over your content
RAG (Retrieval-Augmented Generation) means that AI searches the knowledge base for relevant passages before it answers, and answers from them. There are four steps:
- Content selection: only published content intended for the given audience goes into the index.
- Chunking: a record is split so that each passage makes sense on its own.
- Indexing: passages are stored with metadata in a search index; production setups combine semantic search with full text search and reranking.
- Answer with sources: AI receives the retrieved passages and cites the source records in its answer.
In Drupal you can build on the AI module, which connects Drupal to language models and vector databases such as Qdrant . The alternative is a custom indexer that reads content through the API; it fits where a search layer already exists.
One thing to watch: the index is a copy of the content. Permissions are not enforced there by themselves; they have to be carried over as metadata and filtered at retrieval time. A deleted or withdrawn record must leave the index as well.
Knowledge base MCP: Drupal as an MCP server
MCP (Model Context Protocol) is an open standard through which an AI agent calls tools exposed by another system. The MCP Server module turns Drupal into an MCP server with OAuth 2.1 authorization and tool-level permissions.
The agent then works with live data in Drupal rather than a copy: it finds a record, reads the current revision, prepares a draft of a new article. Drupal enforces permissions at the moment of the call, by the role of the agent or of the user the agent acts for.
| RAG | MCP | |
|---|---|---|
| Data | A copy of content in an index | Live data in Drupal |
| Suited to | Answers from a large body of content | Controlled actions and precise queries |
| Permissions | Metadata and a filter at retrieval | Drupal on every call |
| Freshness | Depends on index synchronization | Always current |
In practice the two are combined: the MCP server exposes a search tool that calls RAG, alongside tools for working with content.
How to start
- Scope the knowledge: one area, one audience, tens to hundreds of records.
- Design the content model: content type, fields, taxonomy, owner.
- Set up workflow and roles: who writes, who approves, what AI can see.
- Expose content through the API and build a RAG index on top of it.
- Add an MCP server once the agent needs live data or write access.
- Measure: which questions went unanswered and which knowledge is missing.
Steps 1 to 3 are about content and processes, not AI. They deserve the most time; the model and the search layer can be replaced later, while the knowledge and its structure remain.
Frequently asked questions
Is our existing Drupal website enough for a knowledge base? As a source, yes; as a content model, usually not. Knowledge is better kept in a dedicated content type with its own fields and workflow; the website can still display it.
Do I need RAG or MCP? RAG for answers from a large body of content, MCP for live data and actions. Most projects start with RAG and add MCP when the agent needs to do more than read.
Will AI see non-public content? Only what it has permission for. With MCP, Drupal checks that on every call; with RAG, permissions have to be carried into the index and used as a filter.
I build knowledge bases in Drupal, including the AI integration; the services are described under Drupal Development and GenAI, Chatbots & Agents .