MCP for Google Tag Manager for WordPress: connect an AI assistant
Connect an AI assistant such as ChatGPT, Claude or Cursor to your WordPress site, and it can read how GTM4WP is set up on that site, explain any of its settings and help you work out why tracking does not work. When you approve a change, the assistant can make that change too. You need no extra MCP server: the free WordPress MCP Adapter plugin connects the assistant to the site.

New in 2.1.0. Experimental. Requires WordPress 6.9 or newer.
GTM4WP 2.0.x: the plugin registers no abilities.
What an AI assistant can do with GTM4WP
To answer a tracking question, an assistant first has to know what the site does. Without access to the site, it can only guess from the screenshots you paste into the chat. Once connected, it reads the real configuration: which container loads, where its code is placed, which features are switched on, which supported plugins are installed, and what Site Health reports.
A few requests that work once the site is connected:
- “Is Google Tag Manager set up correctly on this site? Check Site Health too.”
- “Which GTM container loads here, and where is the container code placed?”
- “Is purchase tracking switched on for this shop, and which order statuses trigger the purchase event?”
- “Did any refund fail to reach Google Analytics this week? Send the failed ones again.”
- “Export my GTM4WP settings so I can copy them to the staging site.”
The assistant changes nothing on its own. Every change is shown to you first, and the assistant waits for your yes (see Changes need your confirmation).
How it works: the Abilities API and MCP
WordPress 6.9 added the Abilities API. A plugin can use it to register abilities: named operations with a description, a defined input and output, and a permission check. Any client that speaks the Abilities API can list them and run them. The WordPress Developer Blog explains the API in more detail.
The Model Context Protocol (MCP) is the standard most AI assistants use to call tools. The WordPress MCP Adapter, a plugin from the WordPress project, turns the abilities of every plugin on your site into MCP tools. GTM4WP does not ship an MCP server of its own: one adapter connection serves every plugin on the site that registers abilities.
What you need
- WordPress 6.9 or newer. On an older WordPress, GTM4WP registers nothing and nothing changes.
- The WordPress MCP Adapter plugin, or any other client of the Abilities API REST routes.
- A WordPress user who may change the GTM4WP settings. By default that is an administrator (the
manage_optionscapability); developers can change it with thegtm4wp_admin_page_capabilityfilter. - An application password for that user.
Connecting your assistant
- Install and activate the WordPress MCP Adapter from the WordPress.org plugin directory (Plugins → Add New Plugin, search for MCP Adapter).
- Create an application password for the user under Users → Profile → Application Passwords.
- Add the site to your assistant. The endpoint is
https://example.com/wp-json/mcp/mcp-adapter-default-server(use your own domain).
The examples below send your username and application password in an Authorization header: the value after Basic is the two joined by a colon and Base64 encoded.
Claude Code
Run this in a terminal:
claude mcp add --transport http my-site https://example.com/wp-json/mcp/mcp-adapter-default-server --header "Authorization: Basic <base64 of username:application-password>"
ChatGPT
Use Codex: the ChatGPT desktop app, the Codex CLI and the Codex IDE extension share one MCP configuration. Add the site to ~/.codex/config.toml (or to .codex/config.toml in a project), as OpenAI’s Codex documentation describes:
[mcp_servers.my-site]
url = "https://example.com/wp-json/mcp/mcp-adapter-default-server"
http_headers = { "Authorization" = "Basic <base64 of username:application-password>" }
The ChatGPT web app cannot connect to the adapter directly. Its developer mode accepts MCP servers with OAuth or with no authentication, and the WordPress MCP Adapter signs in with application passwords only. Never make the adapter reachable without authentication to get around this: anyone could then read and change your settings.
Claude Desktop, Cursor and other clients
The adapter’s documentation uses its remote proxy package:
{
"mcpServers": {
"my-site": {
"command": "npx",
"args": ["-y", "@automattic/mcp-wordpress-remote@latest"],
"env": {
"WP_API_URL": "https://example.com/wp-json/mcp/mcp-adapter-default-server",
"WP_API_USERNAME": "your-username",
"WP_API_PASSWORD": "your-application-password"
}
}
}
}
Then ask the assistant to list the site’s abilities. The eleven gtm4wp/ abilities appear next to those of every other plugin that registers abilities.
Plugins with their own copy of the MCP Adapter
Some plugins ship their own copy of the MCP Adapter. The site can then run that copy instead of the MCP Adapter plugin you installed, even when your installed version is newer. The endpoint and the GTM4WP abilities keep working, but only with the features of the older copy. For example, the MCP protocol revision 2026-07-28, which MCP Adapter 0.7.0 added, is not available.
Rank Math SEO 1.0.279 ships MCP Adapter 0.5.0. In a test on 4 October 2026 with WordPress 7.1.2, its copy replaced MCP Adapter 0.7.0. Elementor 4.3.3 also ships a copy (0.6.1), but in the same test it did not replace the newer MCP Adapter. Other plugins that ship their own copy can behave the same way, and GTM4WP has not tested them. To use the newer MCP Adapter, update the plugin that ships the older copy once its developer includes a newer one.
Elementor sites
On a site that runs Elementor, the endpoint above can return a 404 error with the code rest_no_route. While Elementor’s own MCP feature is turned off, which is its default setting, Elementor switches off the MCP Adapter’s default server. The abilities of every plugin on the site then disappear from the endpoint, including those of GTM4WP. This applies to Elementor 4.3.3 and Elementor Pro 4.3.1 with MCP Adapter 0.7.0 and WordPress 7.1.2, tested on 4 October 2026. To keep the endpoint, open Elementor → Elementor MCP and click Enable MCP access. This also starts Elementor’s own MCP server.
The eleven abilities
GTM4WP registers eleven abilities: six that only read, and five that change settings or contact Google.
| Ability | What it does |
|---|---|
gtm4wp/get-status | Assistants call this first. It reports the plugin version, every container that loads (wp-config.php overrides applied), where the container code is placed, the data layer variable name, which features are available and switched on, which supported plugins are installed, and the configuration problems the plugin shows as admin notices. |
gtm4wp/get-settings | Every option with its current value, filtered by section or option key if needed. On request, each option also comes with its label, description, default, allowed values and documentation link. |
gtm4wp/get-site-health | The plugin’s Site Health status tests and its section of the Site Health Info tab. |
gtm4wp/export-settings | The settings as the JSON file the Export button of the settings screen downloads. |
gtm4wp/get-service-accounts | The stored Google service accounts: label, status and when each was last tested. |
gtm4wp/get-google-data-manager-log | The recent server-side sends of the Google Data Manager integration, newest first, with what became of each. |
gtm4wp/update-settings | Changes one or more options and saves them. |
gtm4wp/import-settings | Replaces every option from an export file. |
gtm4wp/test-service-account | Checks that a stored service account key still works, like the Test button of the settings screen. |
gtm4wp/test-google-data-manager-destination | Checks one Data Manager destination with a validation request, like the Test button of the destinations table. |
gtm4wp/replay-google-data-manager-refunds | Queues failed refund events to be sent again. |
All eleven require the settings capability: a user without it gets a permission error, however the call arrives.
Changes need your confirmation
Five abilities change something or contact Google. Each one tells the assistant how to behave, and GTM4WP adds checks of its own on top.
Changing settings
The assistant reads the current values first, shows you the old and the new value of each option and asks “Confirm this change?”. Every value goes through the same checks as the Save button of the settings screen, and options fixed in wp-config.php cannot be changed. The assistant also sends back a fingerprint of the settings it read. If anyone saved the settings in the meantime (in the settings screen or through another assistant), the change is refused and nothing is saved; the assistant reads the settings again and asks you again.
Importing settings
An import replaces every option of the site, so the assistant exports the current settings first, tells you which site and plugin version the file came from, and asks “Replace all settings on this site?”. The call is refused unless it carries your confirmation.
Sending refunds again
The assistant shows you which refunds would be sent and asks “Send these refunds to Google again?”. The call is refused unless it carries your confirmation, and while the Send refunds option is off. The refunds are queued and sent in the background, with every consent rule applied again. The refunds guide explains the send log.
Testing the Google connection
The two tests sign a request with your service account key, so the assistant tells you before it runs one. They store only the test result, and a passing destination test clears that destination’s failure warning.
What the assistant can see
An ability returns what the GTM4WP settings screen and Site Health already show to the same user, and nothing more: option values (container IDs and Data Manager destinations included), statuses, counts, timestamps and short reason codes. The send log names orders by order number.
It never returns a service account key, the account’s email address or key ID, or an access token, and it carries no data about your visitors or customers. Everything an ability returns is sent to the AI service your assistant runs on, so connect only sites whose configuration you are willing to share with that service.
Turning it off
Two filters control the abilities. Add them to a small plugin or to your theme’s functions.php:
// Register no ability at all.
add_filter( 'gtm4wp_abilities_enabled', '__return_false' );
// Keep the six read-only abilities and withhold the five that change settings
// or contact Google: they are not registered and refuse to run.
add_filter( 'gtm4wp_abilities_allow_write', '__return_false' );
For developers
Without the MCP Adapter, the same abilities run through the WordPress REST API, authenticated with an application password or, from a logged-in browser, with the wp_rest nonce:
GET /wp-json/wp-abilities/v1/abilities?category=gtm4wp
GET /wp-json/wp-abilities/v1/abilities/gtm4wp/get-status/run
POST /wp-json/wp-abilities/v1/abilities/gtm4wp/test-service-account/run {"input":{"id":"..."}}
WordPress picks the HTTP method from each ability’s annotations: read-only abilities run with GET, update-settings and import-settings with DELETE (input in the query string), and the tests and the replay with POST (input in the JSON body).
A module registered through the gtm4wp_register_modules action can add abilities of its own by implementing GTM4WP\Module\AbilitiesInterface on its admin schema. GTM4WP then registers them under its gtm4wp category, and gtm4wp_abilities_enabled switches them off together with the plugin’s own. The actions and filters reference lists every hook.
