keepcalculator

06 Numbers and Powers

Connect AI Assistant to WordPress with MCP

Card No. 06·41459 · Updated · Standard formula, shown below

This guide walks you through connecting an AI assistant to your WordPress site using the Model Context Protocol (MCP). MCP provides a standardized way for AI models to interact with external tools and data sources, and this setup lets your assistant read posts, create drafts, manage comments, and more—directly through WordPress. You’ll need a WordPress site (self-hosted or WordPress.com with a business plan), an AI assistant that supports MCP (such as Claude Desktop or similar), and basic familiarity with the command line.

What You’ll Need

  • A WordPress site (self-hosted via WordPress.org or a WordPress.com plan that allows plugins).
  • An AI assistant that supports MCP clients (e.g., Claude Desktop, or a custom MCP client).
  • Node.js and npm installed on your computer (for running the MCP server locally).
  • WordPress REST API enabled (it’s on by default).
  • Application Password for your WordPress user (or a custom authentication token).
  • Basic knowledge of terminal/command prompt.

Step-by-Step

  1. Create an Application Password in WordPress. Log in to your WordPress admin dashboard. Go to Users > Profile. Scroll to the Application Passwords section (if you don’t see it, your site may not support it—check that you’re on HTTPS). Enter a name for the password (e.g., “MCP Assistant”), click Add New Application Password, and copy the generated string. You’ll need this later.
  2. Install the WordPress MCP Server package. Open your terminal. If you don’t have a project directory, create one: mkdir wordpress-mcp && cd wordpress-mcp. Then run npm init -y to create a package.json file. Install the official WordPress MCP server package by running: npm install @wordpress/mcp. (If this package isn’t available, you can use a community alternative like wordpress-mcp—search npm for the latest.)
  3. Set up environment variables. Create a .env file in your project directory. Add the following lines, replacing the placeholders with your actual site URL and credentials:
    WORDPRESS_URL=https://yourdomain.com
    WORDPRESS_USERNAME=yourusername
    WORDPRESS_PASSWORD=your_application_password
    Save the file. This keeps your credentials secure and out of your main configuration.
  4. Configure the MCP server in your AI assistant. The exact method depends on your assistant. For Claude Desktop, open its configuration file (usually claude_desktop_config.json located in your user folder). Add a new server entry under mcpServers with a name like wordpress. The command should be npx and the arguments should include -y and the package name. Here’s an example:
    {
      "mcpServers": {
        "wordpress": {
          "command": "npx",
          "args": ["-y", "@wordpress/mcp"]
        }
      }
    }

    If your assistant uses a different format, refer to its documentation for adding an MCP server.

  5. Start the MCP server (test manually). Before launching your assistant, test the server by running npx -y @wordpress/mcp in your terminal. It should start and wait for connections. If you see errors, check that your environment variables are set correctly and that your WordPress site is accessible.
  6. Launch your AI assistant and verify the connection. Open your AI assistant (e.g., Claude Desktop). It should automatically start the MCP server. Try a simple command like “List my recent posts” or “Create a draft post titled ‘Hello from MCP’.” If the assistant responds successfully, your connection is working.
  7. Use the MCP tools. Your AI assistant now has access to WordPress tools such as reading posts, creating drafts, updating posts, fetching comments, and more. You can ask it to perform these actions using natural language. For example, “Show me the last 5 comments” or “Update the post with ID 123 to change its status to published.”

Common Mistakes

  • Using your regular WordPress password instead of an Application Password. Regular passwords often fail due to two-factor authentication or security plugins. Application Passwords are designed for API access.
  • Not enabling HTTPS. WordPress REST API and Application Passwords require HTTPS. If your site is on HTTP, the connection will be blocked.
  • Incorrect URL format. The WORDPRESS_URL should be the site’s home URL without a trailing slash (e.g., https://example.com, not https://example.com/).
  • Forgetting to install the MCP package. If you skip npm install, the server won’t run.
  • Not restarting the AI assistant after changing config. MCP servers are loaded at startup. After editing the config file, fully quit and reopen the assistant.
  • Using a WordPress.com free plan. The REST API is limited on free plans; you need a Business or higher plan to use Application Passwords and plugins.

Tips

  • Use a dedicated WordPress user for the MCP connection with limited permissions (e.g., Editor role) to minimize risk.
  • Store your .env file securely and never commit it to version control.
  • If you’re behind a firewall or using a local WordPress site, you may need to use a tunneling service like ngrok to expose it to the MCP server.
  • Check the official WordPress MCP documentation for a full list of available tools and their parameters.
  • Test with read-only commands first (like listing posts) before trying write operations.

Troubleshooting

  • Server doesn’t start. Run npx -y @wordpress/mcp in the terminal and look for error messages. Common issues: missing environment variables (check your .env file), invalid package name (try wordpress-mcp instead), or Node.js version too old (update to latest LTS).
  • Authentication errors (401). Double-check your username and Application Password. Make sure the Application Password was generated correctly and hasn’t been revoked. Also verify that your WordPress site allows Application Passwords (Settings > General > Allow Application Passwords).
  • Connection refused or timeout. If your WordPress site is local, MCP may not be able to reach it. Use a public URL or a tunnel. Also check that your firewall isn’t blocking outbound connections.
  • Assistant says “Tool not found”. The MCP server might not have loaded. Restart the assistant and check the logs (for Claude Desktop, logs are in ~/Library/Logs/Claude on macOS).
  • REST API disabled by a plugin. Some security plugins disable the REST API. Temporarily disable them to test, then whitelist your MCP server’s IP if needed.
  • Changes not reflected. If you update a post but don’t see it on your site, check that the post status is set to ‘publish’ and that you’re using the correct post ID.

Frequently Asked Questions

Do I need a specific AI assistant to use MCP with WordPress?

MCP is an open standard, but not all AI assistants support it yet. As of now, Claude Desktop has built-in support. Other assistants like custom GPTs or open-source models may require additional setup or a custom MCP client.

Can I use MCP with WordPress.com hosted sites?

Yes, but only on plans that support plugins and Application Passwords (Business and above). Free and Personal plans don’t have these features.

Is it safe to share my Application Password with the MCP server?

Your Application Password is stored in your local .env file and only used by the server on your machine. It’s not shared with the AI assistant or third parties. Still, use a dedicated user with limited permissions.

What can the AI assistant do with WordPress via MCP?

It can read posts, pages, comments, and media, create drafts, update post content and metadata, change post status, and manage comments (approve, delete, etc.). The exact tools depend on the MCP server package you’re using.

Can I connect to multiple WordPress sites?

Yes, you can configure multiple MCP servers in your assistant, each with different environment variables pointing to different sites. Just add another entry in the config file.

What if I don’t use Node.js?

Most MCP servers are built in Node.js, but you can also run them in Python if a Python implementation exists. Check the package documentation for alternative installation methods.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →