Skip to main content

Drupal RAG MCP

Drupal Agent Screenshot

A Model Context Protocol (MCP) server that gives AI coding assistants direct access to Drupal projects through:

  • Drupal codebase search (RAG)
  • File reading
  • File writing
  • Drupal route discovery
  • Safe Drupal command execution
  • Project file listing

This server is designed for use with MCP-compatible clients such as:

  • Claude Desktop
  • Claude Code
  • Cursor
  • Windsurf
  • Cline
  • OpenAI Codex CLI
  • Other MCP-compatible tools

Features

Search Drupal Knowledge Base

Search indexed Drupal source code and documentation using semantic search.

Tool:

search_drupal_docs

Read Drupal Files

Read any file within the configured Drupal project.

Tool:

read_drupal_file

Write Drupal Files

Create or update files inside the Drupal project.

Tool:

write_drupal_file

Run Drupal Commands

Execute approved Drupal development commands.

Supported commands:

  • drush
  • composer
  • phpunit

Tool:

run_drupal_command

List Project Files

Browse project source files without using embeddings.

Tool:

list_project_files

Discover Drupal Routes

Search Drupal routes by:

  • Route name
  • Path
  • Controller
  • Form
  • Permission
  • Title

Tool:

find_routes

Architecture

AI Client
    │
    ▼
Drupal MCP Server
    │
    ▼
Drupal RAG API
    │
    ├── Chroma Vector Database
    ├── Drupal Source Code
    └── Drupal Documentation

The MCP server communicates with a local FastAPI service that performs indexing, search, file operations, and command execution.


Installation

Install from PyPI:

pip install drupal-rag-mcp

Or install with RAG dependencies:

pip install "drupal-rag-mcp[rag]"

Requirements

  • Python 3.10+
  • Drupal project
  • Composer
  • Drush (optional)
  • ChromaDB

Build Your Drupal RAG

Create a .drupal-rag folder under your home directory

mkdir ~/.drupal-rag 
cd ~/.drupal-rag
touch config.toml

Paste this settings

drupal_root = "/path_to_drupal_project_directory"
db_dir = "~/.drupal-rag/chroma"

Inside ~/.drupal-rag

mkdir docs

Inside docs add all your drupal documentation (PDF, MD, txt). Start indexing your docs to create rag

drupal-rag-index

This will:

  1. Scan Drupal files
  2. Split documents into chunks
  3. Generate embeddings
  4. Store vectors in Chroma

Start the API Server

drupal-rag-api

The API provides:

POST /search
POST /read-file
POST /write-file
POST /run-command
POST /list-files
POST /find-routes

Start the MCP Server

drupal-rag-mcp

The MCP server uses stdio transport and is intended to be launched by an MCP client.


MCP Client Configuration

Claude Desktop

{
  "mcpServers": {
    "drupal-rag": {
      "command": "drupal-rag-mcp"
    }
  }
}

Cursor

{
  "mcpServers": {
    "drupal-rag": {
      "command": "drupal-rag-mcp"
    }
  }
}

VSCODE

Installing and Running Ollama on Mac

brew install ollama
brew services start ollama
brew services stop ollama

Run and Download an AI Model

ollama pull qwen3
ollama run qwen3

Set Up Continue

  1. Add Extension Continue
  2. Configure Continue config.yaml
name: Local Config
version: 1.0.0
schema: v1

models:
  - name: Qwen3
    provider: ollama
    model: qwen3
  1. Add MCP server in Continue
which drupal-rag-mcp

Example output: /opt/anaconda3/envs/drupal_rag/bin/drupal-rag-mcp

Configure Continue mcp-server.yaml

name: Drupal RAG MCP
version: 0.0.1
schema: v1

mcpServers:
  - name: drupal-rag
    command: /opt/anaconda3/envs/drupal_rag/bin/drupal-rag-mcp
    args: []
    env:
      DRUPAL_ROOT: /path_to_your_drupal

Codex CLI

[mcp_servers.drupal-rag]
command = "drupal-rag-mcp"
args = []

Example Prompts

Find the route responsible for user login.
Search Drupal documentation for cache tags.
Show me all custom routes under /admin.
Read web/modules/custom/example/src/Form/ExampleForm.php
Run drush cr

Security

The server includes several safeguards:

  • Path traversal protection
  • Drupal root restriction
  • Command allow-list
  • Ignored directories and file types
  • Local-only API access

Only approved commands can be executed.

Review the source code before enabling write access in production environments.


License

MIT License

Copyright (c) 2026 John Paul Mariano

See the LICENSE file for full license text.

Metadata

Release files for drupal-rag-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 drupal-rag-mcp 0.1.0
File Size Uploaded Provenance Actions
drupal_rag_mcp-0.1.0.tar.gz 10.2 kB Without provenance Details for drupal_rag_mcp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for drupal-rag-mcp 0.1.0
File Interpreter ABI Platform Actions
drupal_rag_mcp-0.1.0-py3-none-any.whl Python 3 none any Details for drupal_rag_mcp-0.1.0-py3-none-any.whl

Total release size: 20.0 kB

Release files / drupal_rag_mcp-0.1.0.tar.gz

Download URL drupal_rag_mcp-0.1.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3bc72c221b66bfed09ef1d2ec9301e03248bf35fdeda9a5a5770b9b1c9fe4b63
BLAKE2b-256 checksum
How to use checksums
17d3abca164e791252c8c10e59dda978ba8ba1335571e758088aaacfe9b82a56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

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

Download URL drupal_rag_mcp-0.1.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6ecd435fe8d1552101547d7b66f20b55d699ee2b8aff2a343be476b2b99bef0
BLAKE2b-256 checksum
How to use checksums
92ee4845e19695c6d4a623abcb27b8b066c7f1e578cfa1175ac42c0df2f36b1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Security for drupal-rag-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