Skip to content

Latest commit

 

History

History
168 lines (119 loc) · 10 KB

File metadata and controls

168 lines (119 loc) · 10 KB

WordPress as a MCP Server | Jon learns to code with AI

Disclaimer: This is a personal summary and interpretation based on a YouTube video. It is not official material and not endorsed by the original creator. All rights remain with the respective creators.

AI-Powered buttons

Teach Me: 5 Years Old | Beginner | Intermediate | Advanced | (reset auto redirect)

Learn Differently: Analogy | Storytelling | Cheatsheet | Mindmap | Flashcards | Practical Projects | Code Examples | Common Mistakes

Check Understanding: Generate Quiz | Interview Me | Refactor Challenge | Assessment Rubric | Next Steps

This document summarizes the key takeaways from the video. I highly recommend watching the full video for visual context and coding demonstrations.

Before You Get Started

  • I summarize key points to help you learn and review quickly.
  • Simply click on Ask AI links to dive into any topic you want.

What is Model Context Protocol (MCP)?

MCP is an open protocol that lets applications feed extra context (like your code, files, or in this case a WordPress site) directly to an LLM-powered agent.
The agent can then read, create, update, or delete data on your behalf using “tools” — basically functions the LLM can call when needed.

Ask AI: What is Model Context Protocol (MCP)?

Installing and Enabling the WordPress MCP Plugin

The plugin is a set of open-source packages from Automattic that turns any WordPress site into an MCP server.

  1. Download the plugin from GitHub and install/activate it normally.
  2. Go to Settings → MCP and enable Create tools and Update tools (leave Delete disabled unless you really want it).
  3. The plugin instantly registers a bunch of tools (get site info, add post, update post, etc.) that are powered mostly by the REST API.

Ask AI: How to install WordPress MCP plugin

Connecting Your Site to an AI Client (Cursor / Claude Desktop)

You don’t install anything on the client side — you use the @wordpress/remote npm package via npx as a proxy.

Typical config (Cursor or Claude Desktop):

{
  "mcpServers": {
    "wordpress-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@wordpress/remote",
        "https://yoursite.local",
        "yourusername",
        "your-application-password"
      ]
    }
  }
}

Application passwords are used for auth (enable them on local/dev environments by defining WP_ENVIRONMENT_TYPE as local or development).

Cursor shows the available tools immediately after connecting, which is super handy. Claude Desktop was flaky in the stream, so Jonathan switched to Cursor.

Ask AI: Connect WordPress MCP to Cursor or Claude Desktop

Using the Built-in Tools – Live Demo

Jonathan asked the Cursor agent questions like:

  • “What can you tell me about my WordPress site?” → calls wp_get_site_info.
  • “Create a new post titled ‘Demoing the WordPress MCP plugin’ in draft mode” → used the repo README as context, generated markdown content, then called wp_add_post.

First attempt gave markdown instead of blocks. Second attempt (with explicit “use WordPress blocks” instruction) produced proper Gutenberg blocks. Iterative prompting fixed code snippets, images, etc.

This basically turns your AI chat into a remote WordPress admin.

Ask AI: Generate WordPress posts with MCP and Cursor

Building Custom Tools – Enable Debug Log (Proof of Concept)

Jonathan wanted a tool to turn on WP_DEBUG, WP_DEBUG_LOG, and set WP_DEBUG_DISPLAY to false without manually editing wp-config.php.

He created a tiny throwaway plugin that literally writes those constants into wp-config.php when an option is set (very rough, not production-ready, but it works for demo).

Then he added a custom class inside the MCP plugin itself:

class MCP_Enable_Debug {
    public function register_tool() {
        return [
            'name'        => 'enable_debug',
            'description'  => 'Enables WordPress debug log by writing to wp-config.php',
            'type'         => 'update',
            'callback'     => [$this, 'enable_debug'],
            'permissions_callback' => 'manage_options',
        ];
    }

    public function enable_debug() {
        // rough file-write logic that toggles the constants
        return ['success' => true, 'message' => 'Debug log enabled'];
    }
}

Registered with new MCP_Enable_Debug(); in the main plugin file.
After saving, the tool appeared in Cursor and could be called with “Enable the debug log on the WordPress site”.

Ask AI: Create custom MCP tools in WordPress

Reading the Debug Log Tool

Same pattern – another class that reads wp-content/debug.log and returns the last ~25 lines (or full content).

Now the agent can:

  1. Enable debug → tool runs → constants written.
  2. Trigger an error on the site.
  3. Ask “Read the debug log” → gets the latest entries right inside the chat.

Super handy for debugging production/staging without SSH or opening the file manually.

Ask AI: Read WordPress debug.log via MCP

Why This Feels Game-Changing

  • Generate blog post drafts in your AI chat → push live with one command.
  • Debug production errors without leaving your IDE — enable log, reproduce, read log, fix locally, deploy.
  • Turn any GitHub repo into an MCP server (there’s a package for that too).
  • Build your own desktop/site management tools that talk to multiple sites.

Jonathan’s closing thought: install WordPress MCP + a small personal plugin with your favorite tools (debug toggle, plugin disable/enable, etc.) and you have a self-serve “AI admin” from anywhere.

Ask AI: Use cases for WordPress MCP in development workflow


About the summarizer

I'm Ali Sol, a Backend Developer. Learn more: