An AI agent such as Claude can work with a WordPress site in three ways: through WP-CLI commands on the server, through the REST API over HTTP, or through MCP (Model Context Protocol), where the site offers a list of tools the agent can call. All three can read and change content, but they differ in where they run, how they sign in, how many steps a task takes and how much the agent can break. We asked the same question all three ways on one local site and compared.
Short Answer
- WP-CLI can do the most and needs a shell on the server. Use it when the agent runs where WordPress runs: a local site with Claude Code, or a server you SSH into.
- REST API works from anywhere and covers almost everything in WordPress, but the agent has to know the endpoints and often needs several requests per task.
- MCP is made for agents: the site lists its tools with descriptions and input schemas, each call checks the user’s permissions, and one tool can do a whole task. It can only do what the installed tools offer.
The Test: Same Question, Three Ways
The question was “Show the 5 latest posts with their categories” on a local WordPress 7.1 site with WooCommerce, Yoast SEO and Import Export by RockStarLab installed.

WP-CLI: 11 Commands
wp post list --posts_per_page=5 --field=ID gives the IDs, then each post needs wp post get for the title and wp post term list for its categories. That is 11 commands, and each one loads WordPress from scratch, so on our local site they took 41 seconds together. The list also returned 7 posts instead of 5, because WP-CLI adds sticky posts on top. An agent that knows WordPress well could write a single wp eval command instead, but then it is running its own PHP code on your server.
REST API: 2 Requests
GET /wp-json/wp/v2/posts?per_page=5&_fields=id,title,date,categories returned the posts in one request, but categories came back as IDs ([396]), so a second request to /wp-json/wp/v2/categories was needed to turn them into names. Both took 2.4 seconds. Public posts need no login; drafts, private content and every change need an Application Password.
MCP: 1 Tool Call
Through the WordPress MCP Adapter, the agent called the rsl-ie/export-preview ability of Import Export by RockStarLab with the post type and four fields, ID, post_title, post_date and category_names. One call returned the rows with category names, in 2.7 seconds including starting the MCP server.
How They Compare
| WP-CLI | REST API | MCP | |
|---|---|---|---|
| Where the agent runs | On the server (shell access) | Anywhere with HTTP | In an MCP client: Claude Desktop, Claude Code, Cursor and others |
| Sign-in | Server account; --user picks the WordPress user |
Application Password or cookie | Application Password (remote) or --user (local) |
| What it can do | Everything, including running PHP | Everything with an endpoint | Only the tools (abilities) the site offers |
| How the agent learns it | From training and --help |
From training and /wp-json |
The site sends tool names, descriptions and input schemas |
| Steps per task | Often many | Often several | Often one |
| Risk of a wrong step | Highest: shell and database access | Medium: limited by the user’s role | Lowest: limited to the offered tools and the user’s role |
When to Use Which
WP-CLI
Best for developers working on a local site or staging server with an agent in the terminal, such as Claude Code. Search-replace, database exports, plugin updates and bulk changes are fast to write and need no extra plugin. Avoid it on production unless you review each command: an agent with a shell can do anything your server account can.
REST API
Best for scripts and integrations you write once and run many times, and for agents that need something no MCP tool offers. It is the most complete interface, but the agent has to compose URLs, page through results and join related data itself, which costs requests and tokens.
MCP
Best for working on a live site from a chat with an agent: the site tells the agent what it can do, calls are checked against the user’s permissions, and a well-designed tool returns exactly what a task needs. WordPress provides the Abilities API and the MCP Adapter plugin; plugins add abilities on top. Import Export by RockStarLab, for example, adds abilities to preview and run exports and imports, sync content between sites and read job logs, so you can ask an agent to “export the posts in Brewing Guides to Excel” and get a file. To connect a client, use AI Agent Connection in the plugin’s menu: it creates the configuration for Claude Desktop, Claude Code, Cursor, GitHub Copilot, Gemini CLI and Codex.
Can You Use All Three?
Yes, and agents often do. A typical local setup: Claude Code with a shell for WP-CLI, plus an MCP connection to the same site for the plugin’s import and export tools. On a production site, give the agent MCP only, with a user whose role matches what you want it to do.
FAQ
Is MCP faster than the REST API?
Not per call: each MCP tool call runs WordPress code much like a REST request does, and a local MCP connection also has to start its server first. MCP is faster per task when one tool does what would otherwise take several requests.
Do I need a plugin for MCP in WordPress?
Yes: the MCP Adapter plugin turns WordPress abilities into MCP tools, and plugins such as Import Export by RockStarLab provide the abilities. WordPress core includes the Abilities API since version 6.9.
Can an AI agent break my site through MCP?
It can do whatever the offered tools and the user’s role allow. Use a dedicated user with the lowest role that works and keep backups, as with any automation.
Which one should Claude Code use on a local site?
Both. Claude Code can run WP-CLI in its terminal and also connect to the site over MCP; use WP-CLI for site maintenance and MCP tools for content tasks such as exports and imports.
Related Guides
- WP-CLI Import and Export for WordPress: CSV, Excel and Cron Scripts
- How Content Sync Works: API Keys, Push, Pull and What Gets Copied
- How to Export WordPress Content to JSON for AI and LLMs
Get the free plugin on WordPress.org.

Comments 0
Have a question or a tip to share? Leave it below.