Skip to main content

Drupal MCP Toolkit: Four Modules for Agent-Driven Site Management

· 5 min read
Victor Jimenez
Software Engineer & AI Agent Builder

As AI agents become part of the Drupal workflow, you need infrastructure that makes automation traceable, predictable, and composable. I built four small Drupal modules that together form an MCP Toolkit for agent-driven site management.

The Problem

When agents modify configuration, create content, or run audits on a Drupal site, you need:

  1. Visibility into what agents did and when.
  2. Structured access to content and config without scraping rendered pages.
  3. Audit checks that agents can invoke programmatically.
  4. Configuration snapshots for diffing and CI validation.

Each of these is a small, focused concern -- so I built each as a separate module with a narrow, well-defined surface.

Architecture

The Toolkit

ModulePurposeKey Capability
MCP Audit ServerAgent activity loggingStructured events, decoupled from Drupal logs
MCP Config ExportConfiguration snapshotsMCP-friendly format for automation and diffing
MCP Node InfoContent metadata accessRead-only node IDs, titles, types, statuses
MCP Site AuditSite health checksComposable audit capabilities across environments

1. MCP Audit Server

A lightweight server that sits between an MCP client and Drupal, capturing structured events: what tools ran, what endpoints were touched, and when. This gives you a decoupled audit trail that doesn't pollute Drupal's application logs.

Treat Audit Trails as a First-Class Integration Boundary

Emit structured events from the MCP layer, then fan out to storage or alerting without touching Drupal internals. This keeps your audit data clean and queryable independent of Drupal's watchdog.

View Code

2. MCP Config Export

Exports site configuration in an MCP-friendly format that agents and CI pipelines can consume directly. Instead of hand-checking YAML, you get a focused export target for automation, diffing, and validation.

Treating configuration as a first-class output makes automation more reliable. When the config surface is explicit and repeatable, you can diff, validate, and react to changes with confidence -- especially valuable in multi-env setups.

View Code

3. MCP Node Info

Exposes node metadata (IDs, titles, types, statuses, timestamps) through an MCP-style interface. Agents and backend jobs can query Drupal content in structured form without pulling full rendered pages.

Keep the Read Surface Thin

A thin, read-only capability surface stays predictable, cache-friendly, and easy to extend later without breaking clients. Resist the urge to expose full entity data through this endpoint.

View Code

4. MCP Site Audit

Packages site health checks behind a predictable MCP endpoint. Configuration, content, and operational issues become reusable, composable audit capabilities that agents can invoke across environments.

View Code

mcp_audit_server/src/AuditLogger.php
// Structured event capture
$this->log('tool_executed', [
'tool' => $toolName,
'endpoint' => $endpoint,
'timestamp' => time(),
'result' => $result->toArray(),
]);
Tech stack for all four modules
ComponentTechnologyWhy
CMSDrupal 10/11Service container, hooks architecture
ProtocolMCPStandardized tool discovery and transport
Audit storageDecoupled from Drupal logsClean, queryable event data
Config formatJSON exportMachine-readable for CI pipelines
Content accessRead-only MCP endpointCache-friendly, predictable surface

Why this matters for Drupal and WordPress

These four modules define a reference architecture for how CMS sites can expose structured data to AI agents through MCP. Drupal agencies can deploy the toolkit across client sites to get standardized audit trails, config snapshots, and health checks without custom scripting per project. WordPress teams can use the same modular pattern -- an MCP audit logger as a plugin, a WP-CLI config exporter, a read-only post metadata endpoint -- to bring equivalent agent-driven management to WordPress sites. The key insight is that each concern (logging, config, content, health) stays in its own module or plugin, so you adopt only what you need.

What I Learned

  • Small modules win: Each tool does one thing well. Composing them is easier than maintaining a monolithic "agent platform."
  • MCP as the integration contract: By standardizing on MCP, all four modules share the same transport and discovery patterns. Adding a fifth tool takes minutes.
  • Separation reduces risk: Audit logs, config exports, and content queries each live in their own module. A bug in one doesn't break the others.

References


Looking for an Architect who doesn't just write code, but builds the AI systems that multiply your team's output? View my enterprise CMS case studies at victorjimenezdev.github.io or connect with me on LinkedIn.