How To: Connect Claude to WordPress with MCP

What’s MCP? The Model Context Protocol (MCP) is the open standard Claude (and soon other AI assistants) uses to call external “tools.” An MCP server tells Claude which tools it offers, and Claude can then call them over JSON-RPC.

With AI Engine, your WordPress site publishes 30+ tools . Everything from wp_create_post to wp_upload_media and theme operations. Claude can draft posts, upload images, tag content, even fork and modify a theme, all from one chat! 🙀

The little Node script mcp.js (bundled with AI Engine) is the bridge. It was written on MacOS so it has not been tested on Windows. What it does:

  • Opens a secure SSE stream to WordPress (/wp-json/mcp/v1/sse);
  • Tunnels Claude’s JSON-RPC calls to /wp-json/mcp/v1/messages;
  • Relays the responses back to Claude;
  • Cleans up automatically (sends mwai/kill and exits) when Claude quits.

At first, I actually built everything using mcp-remote, but I found it pretty hard to debug, especially when dealing with remote MCP servers. So I ended up making my own version in mcp.js. But if you prefer, you can totally use mcp-remote — it does work just fine with the MCP implementation in AI Engine too!

1. Requirements

  1. WordPress 6.7+
  2. WP REST API (normally enabled by default)
  3. AI Engine 2.7.6+
  4. Claude Desktop ≥ 0.9.2
  5. Node ≥ 20.19.0

mcp.js also handles everything else: it registers your sites, edits Claude’s config, launches the relay, and shuts it down cleanly.

2. Connect Claude to your site

First, set a token for the authentication. You’ll find this field in Settings of AI Engine, under the DevTools tab.

You’ll want to grab the content of the labs folder onto your local machine (or maybe just the mcp.js file, actually). Run these two commands:

# Let's make it an executable
chmod +x ai-engine/labs/mcp.js
# Register site + patch Claude config
ai-engine/labs/mcp.js add https://example.com TOKEN
# First-time test (verbose)
ai-engine/labs/mcp.js start example.com

The first command writes an MCP entry to Claude’s config: ~/.config/anthropic/claude.json on macOS/Linux or %APPDATA%\\Anthropic\\claude.json on Windows.

Launch Claude Desktop and wait a few seconds. If you see a plug icon (connected) and a hammer showing 30+ tools, congrats! It works! 🙂

But honestly, don’t be surprised if it doesn’t… you have no idea how many issues I ran into. And most of the time, it wasn’t even about the code, but stuff like server security, SSL, caching, SSE quirks, edge-caching, Cloudflare headaches, and so on. Also, if the token doesn’t work, Claude will not tell you anything, you’ll have to look into its logs! I really recommend starting with a local install you can fully control, just to have a clean, simple environment at first.

3. Try these prompts

  • Simple — “List my latest 5 posts.”
  • Simple — “Create a draft post titled My AI Journey, one paragraph, and attach a random Media-Library image.”
  • Intermediate — “Review the 10 newest posts, then publish a logical follow-up. Re-use existing categories & tags. Generate an image if none fits.”
  • Advanced — “Fork Twenty Twenty-One into a dark grid theme called Futurism supporting post types Article & Project.”

4. Issues

Take a look inside the ~/Library/Logs/Claude directory. There are some log files there that might be useful — hopefully! Though honestly, they’re not as helpful as I wish they were.

Each SSE connection ties up one PHP worker. Kinsta and similar hosts give 5–8 workers per site, so two Claude sessions can chew through resources fast if they don’t end properly. You might see that your website doesn’t load anymore, in that case you’ll have to restart the web server, or kill the php-fm processes, that highly depends on how your server is set up.

Caching can cause all kinds of problems. Since you’re not connecting to the SSE through your browser, Cloudflare or your hosting service might flag you as a non-browser and then SSE just won’t work (yeah, that really happens). Usually it’s done for caching reasons. For example, if you’re using Kinsta Edge-Caching, you’ll need to turn it off completely. Or you can talk to Kinsta and ask them to disable it only for the SSE endpoint of AI Engine.

If you want to test your server for SSE, try my gist here.

Handy mcp.js commands

Kill the node process related to MCP
ai-engine/labs/mcp.js reset
# Disable auto-launch
ai-engine/labs/mcp.js claude none
# human-readable relay
mcp.js start example.com
# silent relay (Claude uses this)
mcp.js relay example.com
# manage sites
mcp.js add mysite.com
# show all
mcp.js list
# switch target
mcp.js claude mysite.com
# ad-hoc RPC (no curl)
mcp.js post mysite.com '{\"method\":\"tools/list\"}' <session_id>

Extra PHP logging (optional)

Edit wp-content/plugins/ai-engine/classes/modules/mcp.php:

private $logging = true;

Then tail wp-content/debug.log.

What happens when you close Claude?

Claude doesn’t send SIGTERM to helpers, so mcp.js handles its own cleanup:

  • detects stdin close,
  • sends a mwai/kill notification to WordPress,
  • aborts the SSE fetch,
  • exits 0 — no orphan node processes.