# Spoko Content Editor for MCP — an AI agent edits WordPress block by block

My open-source plugin in the official WordPress.org directory: an AI agent reads and fixes posts over MCP one Gutenberg block at a time, with a hash check, a dry run and a revision on every save. On blog.polo.blue it linked 1,684 images and restored the IDs Polylang Pro had lost.

**Canonical:** https://spoko.space/wordpress-content-editor-mcp/  
**Language:** en  
**Published:** 2026-11-29  
**Updated:** 2026-12-01  
**Tags:** wordpress, mcp, gutenberg, ai, php, open-source, polylang  
**Category:** Portfolio  
**GitHub:** https://github.com/spokospace/wordpress-content-mcp

---
<div class="text-center flex gap-4 justify-center flex-wrap">

</div>

## At a glance {#at-a-glance}

|  |  |
| --- | --- |
| Problem | An AI agent that rewrites a whole post to fix one paragraph can break blocks it never meant to touch, or overwrite an edit someone made in the editor a minute earlier. |
| What I built | A WordPress plugin through which an agent (Claude, Cursor, any MCP client) reads and edits posts one Gutenberg block at a time. Every write needs a content hash, takes a dry run and leaves a revision. |
| The hard part | Real blog content built up over years: images without links, attachment IDs lost by Polylang Pro, old Classic blocks, and other plugins that react to every save. |
| My role | Author and maintainer: code, tests, releases, documentation, the WordPress.org submission and the rollout on my car blog. |
| Result | The plugin passed the WordPress plugin team's review and has been in the official WordPress.org directory since 24 November 2026, MIT licensed. On blog.polo.blue, 1,684 images in 286 posts had no link; 4 posts were left, and I fixed those separately. |

## Where it came from {#where-it-came-from}

[polo.blue](https://spoko.space/modern-car-blog/) is my blog about the Volkswagen Polo, in English and Polish. Posts are written in WordPress on blog.polo.blue, and readers get static Astro pages that the build generates from content fetched over the REST API. A classic [headless CMS](https://spoko.space/glossary/headless-cms/): WordPress is only the writing tool.

WordPress 6.9 ships the Abilities API, and the official MCP Adapter plugin builds on it to expose a site to an AI agent over MCP (Model Context Protocol). The adapter alone gives no tool for editing content, though. Through the plain REST API an agent can only fetch the whole post and send all of it back. In a post with dozens of blocks, galleries and tables, one slip in the model's output is enough to break a block nobody meant to touch.

So I wrote a plugin with smaller steps. It started as an in-house tool called Polo Blocks MCP, and once it was working on my blog I turned it into a general-purpose plugin with no trace of polo.blue in the code.

## Why not an existing plugin {#why-not-an-existing-plugin}

Ready-made options exist, and some of them do more than mine. I looked at them before writing my own:

| Option | Why not on polo.blue |
| --- | --- |
| MCP Adapter (official) | I use it: it is what connects WordPress to the agent. On its own, though, it exposes no tool that reads or changes post content. That has to come from a separate plugin, and that is what mine is. |
| WordPress MCP (Automattic) | Automattic's first MCP plugin is archived. Its authors point to the MCP Adapter and the Abilities API, which is what my plugin is built on. |
| Block MCP (GravityKit) | The closest to what I was after: block-level editing, revisions, protection against overwriting someone else's change, plus stable block IDs and batch edits. But it is a separate MCP server next to the plugin, and an agent can also use it to create new posts. |
| AI Engine (Meow Apps) | A large plugin with a chatbot and over a hundred MCP tools: posts, media, users, menus, and in Pro also plugins, themes and the database. On a blog where the agent should only fix content, that is far more access than needed. |

Three things decided it:

- **As little access as possible.** The agent on polo.blue fixes existing posts, and since version 2.2 it can also prepare a new post, but only as a draft. The plugin has no tool that publishes or deletes a post, installs a plugin or changes settings. A person publishes. What isn't there, the agent can't do, even by mistake. New tools are added only when I need them, with the same safeguards.
- **Only the official route.** The plugin uses the Abilities API from WordPress core and the MCP Adapter. No server of its own, no login of its own, no REST routes of its own, so nothing extra to maintain and secure.
- **The blog's own needs.** Image links on polo.blue's public domain instead of the admin host, and restoring IDs lost by Polylang Pro, are things none of these plugins do. With my own code, a tool like that takes a day to add, as `link-images` did.

## How an edit works {#how-an-edit-works}

The agent doesn't get the whole post to rewrite. It gets the block tree, where each block has a path: `12.0.3` is the fourth block inside the first block of the thirteenth top-level block. A change touches exactly that path, and the rest of the post stays byte for byte as it was.

**One fix in a post**

1. **get-outline** — The block tree with paths and text previews, plus the `content_hash` of what the agent sees.
2. **Dry run** — The same call with `expected_hash` and `dry_run`: the result, unsaved, to check.
3. **Validation** — Before saving, the plugin checks the block structure after the change. If anything is broken, nothing is saved.
4. **Save** — A normal post update with a revision. `revision_id` is the backup.

- hash matches: **Change saved** — Only the block it pointed at; the rest of the post untouched.
- someone edited the post: **Write refused** — The agent reads the post again instead of overwriting someone else's change.

The agent signs in with its own account and an application password, not mine, and has exactly that account's capabilities: `edit_post` for the post, `upload_files` for the media search, `edit_posts` or `edit_pages` for drafts. The plugin has no admin screen and no endpoint of its own outside the MCP Adapter's route.

| Tool | What it does |
| --- | --- |
| `find-posts` | Finds posts and pages by title, slug or ID. |
| `get-outline` | The block tree with paths, names and text previews. |
| `get-blocks` | The markup of the given blocks. |
| `validate-post` | Lists problems in the block structure. |
| `find-media` | Searches the media library by title or file name. |
| `replace-block` | Replaces the block at a path. |
| `insert-blocks` | Inserts blocks before or after a given block. |
| `delete-block` | Deletes a block. |
| `move-blocks` | Moves sibling blocks elsewhere without sending their content again. |
| `unwrap-block` | Replaces a container (e.g. a group) with the blocks inside it. |
| `link-images` | Links every unlinked image in a post to its full-size file. |
| `create-draft` | Creates a new post or page as a draft, e.g. from a Markdown file. Never publishes. |

## In production: 1,684 images without a link {#in-production-1684-images-without-a-link}

The lightbox on polo.blue opens only images that link to their file. Images inserted in the editor with "Link to: None" have no link, so clicking them did nothing. Over the years a lot of those piled up: a scan of the blog's published posts and pages found 1,684 unlinked images in 286 posts.

The first fix was a filter that added the links only at render time. I pulled it: the saved content stayed broken, and the fix lived in a separate file on the server that is easy to forget. Instead the plugin got a `link-images` tool. It sets "Link to: Media file" on the image, the same thing the editor does, and saves the post with a revision. It leaves images that already have a link alone, and those with the `no-lightbox` class too.

The links point at the public image address, `polo.blue/images/…`, not at the admin host. The plugin takes that address from a constant or a filter, so on another site it is one setting. The first version of this had a bug: for images on the old image subdomain it built the address of a file that did not exist, and 8 images on one page opened an empty lightbox. The first build showed it, and the fix went into 1.2.1.

Linking the images turned up two things no dry run will show:

- **Saving a post runs other plugins.** On the first larger post, the Smart Auto Upload Images plugin took the old image subdomain for a foreign server and downloaded 21 images into the media library as new files. I stopped the run, excluded the blog's domains in its settings, checked on a post with 37 images that nothing new appeared, and only then carried on. I deleted the duplicates.
- **Hosting has limits.** With four agents working at once, the server answered "Error establishing a database connection" a few times. Every such call went through on a retry, and the last 40 posts ran one after another. Thanks to the hash check, none of them could save half a change.

In the end 4 posts and 36 images were left, which the tool skipped on purpose. One post had an old Classic block, and the plugin refuses to save a post with one. I rewrote it as normal blocks, and link-images did the rest. The other three were down to Polylang.

## Polylang Pro and lost image IDs {#polylang-pro-and-lost-image-ids}

The blog is bilingual and keeps its translations in Polylang Pro. Polylang translates media too: one image file gets a separate attachment for each language. When posts were translated and their language switched, the image IDs in the blocks got lost. Some blocks had no ID at all, some pointed at an attachment that no longer existed. As a result, the attachments assigned to a post didn't show up properly, and `link-images` couldn't work out the full-size file, so it skipped those images.

The image file itself was in the media library all along, just under another ID. Version 2.0.3 uses that:

- When an image has no ID, or the ID of a deleted attachment, the plugin looks its file up in the media library: the file itself, and for a resized copy also the original, including the `-scaled` version.
- When one file has several attachments because Polylang translates media, the one in the post's language wins. Another translation plugin can choose through the `spoko_content_mcp_image_attachment` filter.
- The block gets its `id` and the `wp-image-N` class back, as the editor would set them, and the link points at that attachment's full file. The tool's result has a `restored_id` field, so you can see what was restored.

On the blog, the English and Polish versions of the cruise control post got their IDs back on all 17 images, and in an old post about a bulb the dead ID was replaced by the ID of an existing attachment with the same file. Every save left a revision, and not a single file was added to the media library.

## From a tool for my own blog to WordPress.org {#from-a-tool-for-my-own-blog-to-wordpressorg}

**Releases**

1. **October 2026: Polo Blocks MCP 1.1** — The plugin as it ran on blog.polo.blue: ten block tools, the hash check, dry runs, revisions.
2. **29 October: link-images (1.2)** — The image-linking tool, then a fix for links on the public image domain.
3. **7 November: version 2.0, public** — A new general-purpose name, one endpoint /wp-json/spoko/content, MIT license, updates from GitHub releases, submitted to WordPress.org.
4. **20 November: Spoko Content Editor for MCP** — The WordPress.org review: "MCP" is another project's name, so in a plugin name it has to come after "for". Slug, endpoint and tools unchanged.
5. **24 November: officially on WordPress.org** — The plugin passes review and goes into the WordPress plugin directory as spoko-content-mcp.
6. **26 November: 2.0.3** — Restoring IDs lost by Polylang, and media search by file name.
7. **1 December: 2.1, after a security audit** — Writes to one post one at a time, filtering of agent markup and a stricter updater.
8. **1 December: 2.2, create-draft** — The agent creates a new post or page as a draft. Publishing stays with a person.

Since 24 November 2026 the plugin has been officially in the [WordPress.org directory](https://wordpress.org/plugins/spoko-content-mcp/). To get there it went through the WordPress plugin team's review, where people check the code, security, license and name by hand. That review is what made me rename it. As a result it installs like any other plugin: in the admin, under Plugins → Add New, by typing its name into the search.

The plugin has two builds of the same code. The GitHub build updates itself from the repository's releases: with auto-updates on, WordPress installs a new version without me. The WordPress.org build has no such mechanism, since the directory doesn't allow it, and WordPress.org updates it. Before submitting it I ran it through Plugin Check, the directory's official tool, with no errors or warnings, experimental checks included.

The tests need no WordPress install and no database: `link-images` runs against the real block parser and serializer from WordPress core, and the updater against stubbed GitHub responses. A release is one script, no CI.

## Security audit and version 2.1 {#security-audit-and-version-21}

A plugin that gives an AI agent access to a site's content has to stay safe when the agent makes a mistake or reads text someone else wrote. So at the end of November I went through it in a separate security audit. It found two serious issues and a few smaller ones, and the fixes shipped in version 2.1.0 on 1 December 2026.

- **Two writes from the same hash could both go through.** The plugin checked the hash and saved the post in two separate steps. When two agents saved the same post at the same moment, both saves succeeded and one change was lost. Now writes to one post run one at a time: each takes a lock on the post, reads it again inside the lock, and only then saves. A second write waits up to 10 seconds and then gets a `post_busy` error instead of overwriting the first.
- **An agent could save a script.** An Editor or Administrator account may save any HTML in WordPress, and the agent worked with that account's rights. An agent that had read planted text could therefore put a script into a post. Now markup from the agent goes through WordPress's HTML filter for every account. It lets through only embeds from known services, PDFs from the site and SVG drawings, and leaves the rest of the post alone. A site that really needs raw HTML can turn that on with a separate setting.
- **Smaller fixes.** The updater accepts only packages from this repository's releases. `find-media` lists only files the account may read, `link-images` links only http(s) addresses, and `replace-block` and `unwrap-block`, which replace content, are marked destructive, so an MCP client can ask before using them.

I tested the fixes on a real WordPress with a MariaDB database, not only in unit tests. Version 2.0.3 updated itself to 2.1.0 through its old updater. Up to 10 agents saved the same post at once and no change was lost. 440 sample Gutenberg blocks went through the new filter, and the ones it changes are listed in the documentation. Version 2.1.1 then refined how SVG drawings are saved on WordPress 7, so that an unchanged drawing is saved byte for byte.

## Drafts from a Markdown file: version 2.2 {#drafts-from-a-markdown-file-version-22}

Version 2.2.0, released on 1 December 2026, added the `create-draft` tool. With it the agent puts a new post or page into WordPress as a draft, for example from an article written in a Markdown file. It turns the Markdown into blocks and sets the title, slug, excerpt, existing categories and tags, a featured image from the media library and, with Polylang, the language.

The status is always "draft". So the agent's account does not need the `publish_posts` capability, and the Contributor role is enough. The draft's markup goes through the same filter and the same block check as every other write. A `source_key`, such as the file path, keeps a retried call from making a second draft. The tool is on by default. A site that doesn't want it turns it off with the `SPOKO_CONTENT_MCP_CREATE_DRAFTS` constant or the `spoko_content_mcp_create_drafts` filter.

There is no tool for publishing. A person reviews the draft and publishes it in the WordPress admin.

## What's next {#whats-next}

The next tools follow the same rules (hash check, dry run, revision) and cover the rest of a content workflow: a request to publish that a person approves in the admin, scheduling, a link and image check for a post before it goes live, changing a draft's title, slug and categories, creating categories and tags, and pairing translations in Polylang, active only where Polylang is. Moving posts to the trash stays with a person.

## When it makes sense {#when-it-makes-sense}

The plugin helps when content lives in WordPress and you want to hand part of the work on it to an AI agent: fixes in old posts, cleaning up images and links, adding a section, translating. The panel, the revisions and the final word stay with a person. On polo.blue the agent proposes, and a published post changes only after my "yes".

If you have a WordPress site that could use this kind of cleanup, or you want to connect it to an AI agent, [get in touch](https://spoko.space/contact/).

<div class="text-center flex gap-4 justify-center flex-wrap mt-8">

</div>

## Frequently Asked Questions {#faq}

### How is this different from the standard WordPress REST API? {#faq-how-is-this-different-from-the-standard-wordpress-rest-api}

The REST API saves a whole post at once, so an agent that wants to change one paragraph has to send back the entire content. Spoko Content Editor for MCP addresses single Gutenberg blocks by path, refuses a write if the post changed in the meantime, has a dry run and checks the block structure before every save.

### What does it need to run? {#faq-what-does-it-need-to-run}

WordPress 6.9 or newer (the Abilities API is in core), PHP 7.4+, the official MCP Adapter plugin and a separate account for the agent with an application password. The tools run with that account's own capabilities.

### Does it work without Polylang? {#faq-does-it-work-without-polylang}

Yes. Polylang is not required. When it is active, link-images picks the attachment in the post's language when it restores a lost ID, and a filter lets another translation plugin choose the right attachment.

### Where can I get it? {#faq-where-can-i-get-it}

From the WordPress.org plugin directory (slug spoko-content-mcp) or from the GitHub releases. The GitHub build updates itself from the repository's releases; the directory build is updated by WordPress.org.
