1. Home
  2. The Lab
  3. WP AI Agent

WordPress plugin + REST API

WP AI Agent

A WordPress plugin that lets an AI assistant do real work on a live site — read the page, make the change, write it back — without me relaying every step by hand. The interesting part was never getting it to work. It was making it safe enough to leave installed.

Type
WordPress plugin + MCP server
Written in
PHP 8 and Node.js
Releases
12, currently v0.8.3
Status
In production, across a fleet

01

The reason

I maintain a lot of WordPress sites. A large share of the work on any of them isn't creative — it's reading what a page currently contains, changing one thing, checking the result, and moving to the next site. Multiply that by a fleet and the routine parts start crowding out the parts that need judgement.

An assistant could take most of that, but only if it could actually reach the site. That turns out to be the whole problem. WordPress ships a REST API, but it's built around posts and taxonomies — it doesn't expose the filesystem, it doesn't expose the database, and it has no idea what a page builder's layout structure means. Reaching a site properly meant building the bridge myself.

02

What it actually is

Two pieces, deliberately unequal.

The plugin is the substantial half: 5,903 lines of PHP across 15 files in the current build, requiring PHP 8 and WordPress 6. It exposes a key-authenticated REST surface and holds all of the logic that decides what's and isn't allowed to happen.

The client is deliberately thin — a single Node file under 500 lines, exposing a small set of tools over the Model Context Protocol so an assistant can call the site directly. It contains no rules of its own.

That imbalance is the main architectural decision on the project. Every check lives on the site, inside the plugin, where it can't be bypassed by writing a different client. A thin client is replaceable; a thin server would be a liability.

03

What it can do

Filesystem operations against the site, including chunked transfer so a file larger than PHP's upload ceiling can still be read or written in one logical operation. Database queries. Plugin and theme management. Configuration recommendations presented as a diff before anything is applied.

And page building — the piece that made it worth writing. It can create and update Divi 5 pages from structured layout data, with a dry-run validation pass that checks the layout before it's saved, not after. Divi is where most of my client work lives, so an agent that can read and write real Divi structure is the difference between the tool being useful and being a novelty.

Every response comes back in a structured envelope with stable error codes and a hint about the fix, and every request carries an identifier that ties a multi-step operation together in the action log. That log is queryable, which matters the first time you need to answer "what exactly did it change last Tuesday".

04

The part that took the longest

Giving a program write access to a live website is easy. Making that safe is the entire project, and it's where most of the engineering went.

The design principle underneath it: a key on its own isn't permission to do everything. The riskier categories of operation require a second authorisation that can't be granted through the API itself, so possession of the key can never escalate into possession of the site. That separation is the load-bearing idea, and everything else is an expression of it.

Around that sit the ordinary disciplines: writes to sensitive files go through a backup, a syntax check, an atomic replacement and a health check that can roll the change back; destructive database operations need an explicit confirmation on top of the higher authorisation tier; requests the server makes on its own behalf are checked so they can't be aimed at internal addresses; file access is confined to the site's own directory.

None of that's clever. It's just the list you end up with after thinking honestly about what a mistake — or a leaked key — would actually cost somebody whose business is on the other end.

05

How it gets used

Day to day it's what turns "can you update the hours on the contact page" into something I can hand off and check, instead of doing it by hand on each site. The assistant reads the page's real structure, makes the change, and writes it back; I review the result.

It also underpins the fleet dashboard, which polls every site running the plugin and reports the state of all of them at once — online or not, version drift, WordPress and PHP versions. That answers "is everything up" without opening a tab per site, which is the question that used to cost the most time for the least thought.

06

What it taught me

That the feature list is the easy half. The first working version arrived quickly; twelve releases later, a large share of the changes since have been about narrowing what the thing is permitted to do.

It also changed how I think about building anything that acts on someone else's behalf. The useful question isn't "what can this do" but "what happens when this is wrong, or when the credential isn't in the hands I think it's in" — and that question has to shape the architecture, because it can't be answered convincingly with a patch afterwards.

The same instinct shows up in the client work. It's the reason a redesign over live commerce gets treated as a risk-management job first and a visual one second.

PHP 8 WordPress REST API Node.js MCP Divi 5 SQL GPL-2.0
On the detail level here

This page describes the architecture and stops there on purpose — no endpoints, no authentication design, no configuration specifics. This plugin is installed on live client sites, and a public account of exactly how its permissions work would be more useful to somebody probing an installation than it's to anybody reading a portfolio. Happy to go into the detail properly in a conversation.

Want this kind of thinking on your build?

Tell me what you're trying to ship and what's in the way. You will get an honest read on scope, timeline and cost — within one business day.