Running WordPress in Docker and Connecting it to Claude via MCP

I’ve been running The Captains Log on WordPress for a while now, but recently decided to give it a proper home on my homelab server rather than relying on shared hosting. What started as a simple migration turned into an interesting exploration of Docker, Cloudflare tunnels, and the Model Context Protocol (MCP).

The Setup

First things first – I got WordPress running in a Docker container on my homelab server. Nothing too fancy here, just a standard WordPress image with MySQL backing it. The interesting bit came when I wanted to expose it to the internet without opening ports on my router or dealing with dynamic DNS nonsense.

Enter Cloudflare Tunnels. These are brilliant – you run a lightweight daemon on your server that creates an outbound connection to Cloudflare’s network, and they handle all the routing. No port forwarding, no exposing your home IP, and you get free SSL certificates thrown in. The setup was surprisingly straightforward, and within minutes thecaptainslog.co.nz was serving traffic through the tunnel.

The MCP Adventure

Here’s where things got interesting. I’d been playing around with MCP servers – these let you connect various services to Claude so it can interact with them directly. I thought, why not connect my WordPress site?

I’m using Unla as my MCP gateway. It’s basically a bridge that lets you run multiple MCP servers and expose them to Claude Desktop through a single connection point. It’s got a web interface for managing everything, which beats editing JSON files by hand.

Setting up the WordPress MCP server in Unla required a few things. First, I had to generate an Application Password in WordPress – these are special passwords you can create for API access without exposing your main login credentials. Then it was just a matter of configuring the MCP server with the right details:

  • WordPress site URL (including the /index.php bit because my permalinks aren’t quite set up properly yet)
  • My WordPress username
  • The application password
  • Author ID for posts

The tricky bit was getting the permalink structure right. WordPress can run with “pretty permalinks” that look clean, or with /index.php in the path if your web server doesn’t have mod_rewrite enabled properly. Mine’s currently using the latter, which meant the API endpoint wasn’t where the MCP server expected it to be. Once I updated the configuration to point to the /index.php path, everything clicked into place.

Connecting Claude Desktop

The last piece was getting Claude Desktop to talk to the MCP server. Unla exposes an SSE (Server-Sent Events) endpoint that Claude can connect to. I added a configuration to my Claude Desktop config file pointing to the Unla gateway running on my server, and after a quick restart, Claude had access to WordPress.

We tested it with a simple post, and it worked first try. Claude can now search for posts, retrieve them, create new ones, and update existing content – all using the proper Gutenberg block format that WordPress expects.

What’s Next

The obvious next step is integrating this with n8n, my workflow automation platform. I could set up automated posting from RSS feeds, create posts based on data from other services, or even have Claude help with content creation directly from the workflow engine.

I’m also thinking about fixing those permalinks properly so I can get rid of the /index.php in the URL structure. It’s purely cosmetic, but it’d be cleaner.

The combination of Docker for containerization, Cloudflare Tunnels for secure exposure, and MCP for programmatic access creates a pretty flexible setup. Everything’s running on my homelab, I control the data, and I can automate interactions with it through Claude. Not bad for a weekend project.

This post itself? Written by Claude through the MCP connection we just set up. Meta, I know.