Skip to main content

MCP server for Drupal RAG, file access, routes, and safe Drupal commands

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drupal_rag_mcp-0.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drupal_rag_mcp-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file drupal_rag_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: drupal_rag_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for drupal_rag_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3bc72c221b66bfed09ef1d2ec9301e03248bf35fdeda9a5a5770b9b1c9fe4b63
MD5 60d601c82cce3623a3d0627e6f5f39fd
BLAKE2b-256 17d3abca164e791252c8c10e59dda978ba8ba1335571e758088aaacfe9b82a56

See more details on using hashes here.

File details

Details for the file drupal_rag_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: drupal_rag_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for drupal_rag_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ecd435fe8d1552101547d7b66f20b55d699ee2b8aff2a343be476b2b99bef0
MD5 a0daf0782739616a53f97ca6cd3ef7fd
BLAKE2b-256 92ee4845e19695c6d4a623abcb27b8b066c7f1e578cfa1175ac42c0df2f36b1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page