wordpress-mcp

v2.0.1
@junis/wordpress-mcp Checked 2 days ago Published 25 days ago

MCP server for the WordPress REST API: content of any post type, taxonomies, media, users, comments, plugins, ACF fields and WooCommerce products

A Model Context Protocol server for the WordPress REST API. It lets an AI agent read and manage a WordPress site: posts, pages and custom post types, categories, tags and custom taxonomies, media, users, comments and plugins, plus Advanced Custom Fields values and WooCommerce products. Many tools change the live site (publish, overwrite, delete, install plugins, manage users). Read Security before giving an agent write access, and consider WORDPRESS_READ_ONLY=true or WORDPRESS_DISABLED_TOOLS. Set these environment variables in your MCP client configuration. Nothing is read from files.

Summary extracted from the README.

wordpress-mcp

A Model Context Protocol server for the WordPress REST API. It lets an AI agent read and manage a WordPress site: posts, pages and custom post types, categories, tags and custom taxonomies, media, users, comments and plugins, plus Advanced Custom Fields values and WooCommerce products.

Many tools change the live site (publish, overwrite, delete, install plugins, manage users). Read Security before giving an agent write access, and consider WORDPRESS_READ_ONLY=true or WORDPRESS_DISABLED_TOOLS.

Based on mcp-wp by InstaWP. Not affiliated with or endorsed by the WordPress Foundation, Automattic (WooCommerce), WP Engine (ACF) or InstaWP.

Requirements

  • Node.js 22 or later
  • A WordPress site with the REST API (WordPress 5.6 or later for application passwords)
  • A WordPress user and an application password for it. Create a dedicated user with the lowest role that covers what the agent should do (for example Editor for content; Administrator only if it must manage users or plugins).

Configuration

Set these environment variables in your MCP client configuration. Nothing is read from files.

Variable Required Default Description
WORDPRESS_API_URL yes Site address, e.g. https://example.com or https://example.com/blog. An address that already ends in /wp-json/wp/v2 works too. Must be https:// (see below)
WORDPRESS_USERNAME WordPress user name. Set together with the password; without both only public data can be read
WORDPRESS_PASSWORD Application password of that user (spaces are fine)
WOO_CONSUMER_KEY WooCommerce REST API consumer key, used for the WooCommerce tools instead of the application password. Set together with the secret
WOO_CONSUMER_SECRET WooCommerce consumer secret
WORDPRESS_SQL_ENDPOINT /mcp/v1/query Route below /wp-json/ used by execute_sql_query (see SQL query tool)
WORDPRESS_DISABLED_TOOLS (none) Comma-separated tool names not offered to the agent, e.g. delete_user,create_plugin,execute_sql_query. Unknown names are ignored with a warning at startup
WORDPRESS_READ_ONLY false true offers only the tools that do not change the site (this also hides execute_sql_query and find_content_by_url)
WORDPRESS_TIMEOUT_MS 120000 Timeout per request (1,000–600,000)
WORDPRESS_MAX_RESPONSE_BYTES 52428800 Largest WordPress response accepted (50 MB)
WORDPRESS_MAX_RESULT_CHARS 1000000 Largest tool result returned to the agent, in characters; longer lists are cut and marked truncated: true
WORDPRESS_MAX_CONCURRENCY 8 Most WordPress requests in flight at once for the whole process (1–32)
WORDPRESS_MEDIA_MAX_BYTES 26214400 Largest file create_media downloads (25 MB)
WORDPRESS_ALLOW_INSECURE_HTTP false true allows an http:// site address

Example for Claude Desktop, Claude Code or any MCP client that starts stdio servers:

{
  "mcpServers": {
    "wordpress": {
      "command": "npx",
      "args": ["-y", "@junis/wordpress-mcp@2.0.1"],
      "env": {
        "WORDPRESS_API_URL": "https://example.com",
        "WORDPRESS_USERNAME": "<user name>",
        "WORDPRESS_PASSWORD": "<application password>"
      }
    }
  }
}

Pin a version as above so an update is a deliberate change.

Tools

Kinds: read does not change the site; create adds something new; overwrite changes or removes existing data (destructiveHint: true). Every tool carries the matching MCP annotations. Full input schemas are in the tools/list response.

Content (posts, pages, custom post types)

content_type is the post type slug: post, page, or a custom type such as product.

Tool Kind What it does
list_content read List items with filters (search, slug, status, author, categories, tags, parent, dates) and pagination
get_content read One item by ID
create_content create New item; status defaults to draft
update_content overwrite Change fields of an item (including meta, acf and other fields via custom_fields)
delete_content overwrite Trash an item, or delete it permanently with force: true
discover_content_types read Content types of the site (cached 5 minutes)
find_content_by_url overwrite Find the item behind a URL of the site by its slug. Reads only, unless update_fields is given: then it writes those fields to the item it found. The URL is only parsed, never fetched
get_content_by_slug read Find an item by slug in one or more content types

Content results are cleaned for a language model: title, content and excerpt are plain strings; scripts, styles, srcset and layout attributes are removed from HTML (text, links, images and videos stay; a single tag longer than 8 KB is dropped; cleaning takes linear time, so hostile markup cannot stall the server); yoast_head, yoast_head_json, _links, guid, date_gmt, modified_gmt, ping_status, comment_status and class_list are dropped; ACF image attachments become {ID, id, url, alt, width, height} (the ID is what ACF writes expect) and ACF relation posts {ID, post_title, post_name, post_type}. Bodies are included in list_content, so one call usually replaces a get_content per item. status filters accept one status or a comma-separated list (publish, draft).

Taxonomies (categories, tags, custom taxonomies)

Tool Kind What it does
discover_taxonomies read Taxonomies of the site, optionally for one content type (cached 5 minutes)
list_terms read Terms of a taxonomy with filters and pagination
get_term read One term by ID
create_term create New term
update_term overwrite Change a term
delete_term overwrite Delete a term permanently (terms have no trash)
assign_terms_to_content overwrite Set the terms of one taxonomy on an item (replace, or add with append: true)
get_content_terms read Full terms assigned to an item (up to 500)

WooCommerce (read only)

Uses wc/v3. Authenticates with WOO_CONSUMER_KEY/WOO_CONSUMER_SECRET when set, otherwise with the application password (the user needs the Shop manager or Administrator role).

Tool Kind What it does
list_woo_products read Products with pricing, SKU, stock, categories, images, attributes and meta_data (custom fields; keys starting with _ are left out of custom_meta)
get_woo_product read One product by ID
get_woo_product_variations read Variations of a variable product
search_woo_products read Search by name, SKU or description

Advanced Custom Fields

Uses the core routes (/wp/v2/{type}/{id}), which carry ACF values when the field group has Show in REST API enabled (ACF 5.11 or later).

Tool Kind What it does
get_acf_fields read ACF values of one item
update_acf_fields overwrite Overwrite the given ACF values of one item
list_acf_content_fields read id, title, slug and ACF values for a page of items

Plugins

Tool Kind What it does
list_plugins read Installed plugins with a status (default active)
get_plugin read One installed plugin, e.g. akismet/akismet
activate_plugin overwrite Activate an installed plugin (runs its code on the site)
deactivate_plugin overwrite Deactivate a plugin
create_plugin overwrite Install a plugin from WordPress.org and activate it (default)
search_plugin_repository read Search the public WordPress.org directory (does not touch the site)
get_plugin_details read Details of a WordPress.org plugin (does not touch the site)

Media

Tool Kind What it does
list_media read Media library items
create_media create Download a file from a public http(s) URL and upload it. Accepted: JPEG, PNG, GIF, WebP, AVIF, HEIC, BMP, TIFF, ICO, MP4, WebM, MOV, OGV, MP3, M4A, WAV, OGG and PDF; nothing containing "svg". The file extension comes from the checked type, never from the URL
edit_media overwrite Change title, alt text, caption or description
delete_media overwrite Delete a media item and its files (force: true)

Users

Tool Kind What it does
list_users read Users with search and pagination (context: edit adds e-mail addresses and roles)
get_user read One user by ID
create_user create, destructive New account with roles and password. Can create administrators, so it is marked destructiveHint: true
update_user overwrite Change an account, including roles and password
delete_user overwrite Delete an account permanently (force: true and reassign required)

Comments

Tool Kind What it does
list_comments read Comments with filters and pagination
get_comment read One comment by ID
create_comment create Post a comment
update_comment overwrite Change a comment or its status (approve, hold, spam, trash)
delete_comment overwrite Trash a comment, or delete it permanently with force: true

SQL query tool

Tool Kind What it does
execute_sql_query overwrite One SELECT / WITH … SELECT / EXPLAIN query through a custom route. Marked as able to change data (readOnlyHint: false, destructiveHint: true) because the route decides what runs; not offered with WORDPRESS_READ_ONLY=true

WordPress has no SQL route. The tool works only if the site owner adds one at WORDPRESS_SQL_ENDPOINT (default /wp-json/mcp/v1/query) that accepts POST {"query": "..."}, requires manage_options and runs only read-only queries, for example in a small plugin:

add_action('rest_api_init', function () {
    register_rest_route('mcp/v1', '/query', [
        'methods' => 'POST',
        'permission_callback' => fn () => current_user_can('manage_options'),
        'callback' => function (WP_REST_Request $request) {
            global $wpdb;
            $query = trim((string) $request->get_param('query'));
            if (stripos($query, 'SELECT') !== 0) {
                return new WP_Error('invalid_query', 'Only SELECT queries allowed', ['status' => 400]);
            }
            $results = $wpdb->get_results($query, ARRAY_A);
            if ($wpdb->last_error) {
                return new WP_Error('query_error', $wpdb->last_error, ['status' => 400]);
            }
            return ['results' => $results, 'num_rows' => count($results)];
        },
    ]);
});

The server refuses obvious writes before sending a query, but that check is not a security boundary: the route must enforce read-only access itself, ideally with a database user that only has SELECT rights. The database contains user e-mail addresses and password hashes. Results over 50,000 characters are cut and marked truncated: true. Disable the tool with WORDPRESS_DISABLED_TOOLS=execute_sql_query if you do not use it.

Security

  • HTTPS is required by default. The application password is sent with every request (HTTP Basic authentication), so over http:// anyone on the network path can read it. The server refuses to start with an http:// address unless WORDPRESS_ALLOW_INSECURE_HTTP=true is set, and then prints a warning at every start. Use that only for a local development site.
  • Credentials stay on the site. They are read from environment variables only and never logged. Requests are built below the configured /wp-json/ root only; content_type, taxonomy and plugin arguments must be plain identifiers and cannot name users, plugins, settings, themes or other non-content routes, other namespaces or other hosts. Redirects are followed only for GET requests and only within the same origin. A core request (below /wp-json/wp/v2/) may be redirected only within /wp-json/wp/v2/ and never into users, plugins, settings or the other protected routes unless the request was already for that route. A WooCommerce or SQL-route request may be redirected only within its own namespace (for example /wp-json/wc/v3/ or /wp-json/mcp/v1/). A redirect of a write request, or to /wp-admin/, another namespace or another address, is refused, so neither the credentials nor a request body go anywhere else.
  • Error text is scrubbed. Errors returned to the agent contain the HTTP status, the WordPress error code and its message with HTML tags, credentials and the site address removed.
  • create_media cannot reach internal services or local files. It downloads only from public addresses (every resolved address is checked; private, loopback, link-local, cloud metadata (including the cloud platform address 168.63.129.16), CGNAT, multicast and IPv4-mapped or IPv4-translated addresses are refused), connects to the address it checked, checks every redirect again, accepts only the listed image, video, audio and PDF types, and stops at WORDPRESS_MEDIA_MAX_BYTES. The DNS lookup counts toward the timeout and stops on cancellation, and no HTTP proxy from the environment (HTTP_PROXY, NODE_USE_ENV_PROXY) or shared keep-alive connection is used, since either could reach a different address. No credentials are sent to the source.
  • Limits. Requests time out (WORDPRESS_TIMEOUT_MS), responses are size-limited (WORDPRESS_MAX_RESPONSE_BYTES), requests are limited process-wide (WORDPRESS_MAX_CONCURRENCY), tool results are capped (WORDPRESS_MAX_RESULT_CHARS) and every argument has bounds (IDs, page sizes at most 100, string and list lengths, date formats). When the MCP client cancels a call, its WordPress requests and downloads are aborted, and a call still waiting for a free request slot leaves the queue.
  • Logging. The server writes no files. At start it prints its version and warnings; each call writes one line to stderr with the tool name, outcome and duration. Arguments and results are not logged.
  • What it cannot protect against. The agent can do whatever the WordPress user may do. A prompt injected through content the agent reads (a post, a comment, a product description) could ask it to publish, delete, change users or install plugins. Give the WordPress user the lowest role that works, turn off tools you do not need with WORDPRESS_DISABLED_TOOLS or use WORDPRESS_READ_ONLY=true, and require human confirmation for destructive tools in your MCP client. Tool results can contain personal data (user and commenter names, e-mail addresses for privileged users, IP addresses of commenters).

Report vulnerabilities as described in SECURITY.md.

Development

npm ci
npm run typecheck
npm test        # unit and end-to-end tests against local fake servers; no network access
npm run build   # writes dist/

License

The npm package contains the TypeScript source (src/) and build configuration next to the compiled JavaScript, so it is its own Corresponding Source under the GPL; npm run build recreates dist/.

GPL-3.0-or-later (LICENSE). Copyright © 2026 TOOEASY Inc. for the modifications. This project is a modified version of mcp-wp by InstaWP and its contributors, licensed under GPL-3.0-or-later; see NOTICE.

LICENSE, NOTICE, SECURITY.md and CHANGELOG.md are included in the package (files on npm).