Adding an MCP Server to the WordPress Core Development Environment

Illustration of an MCP server being connected to WordPress with the Gateway to India and the Taj Mahal Palace in the background.
Via Nano Banana in Gemini: Create a WordPress featured image for a blog post with this title: “Adding an MCP Server to the WordPress Core Dev Environment”. Do not include the title text in the. Give the image an Indian (from Mumbai) design aesthetic as well.

I wanted to hook up Claude Code to be able to interact with my local wordpress-develop core development environment via MCP (Model Context Protocol). I couldn’t find documentation specifically for doing this, so I’m sharing how I did it here.

Assuming you have set up the environment (with Docker) and started it via npm run env:start.

1. Install & Activate the MCP Adapter plugin

The MCP adapter is not currently available as a plugin to install from the plugin directory. You instead have to obtain it from GitHub and install it from the command line. I installed it as a plugin instead of as a Composer package:

cd src/wp-content/plugins
git clone https://github.com/WordPress/mcp-adapter
cd mcp-adapter
composer installCode language: Shell Session (shell)

Next, activate the plugin. Naturally, you can also just activate the “MCP Adapter” plugin from the WP admin. You can also activate it via WP-CLI (but from the project root working directory, since you can’t run this command from inside of the mcp-adapter directory:

npm run env:cli -- plugin activate mcp-adapterCode language: Shell Session (shell)

2. Register the MCP server with Claude

Here’s the command I used to register the wordpress-develop MCP server with Claude:

claude mcp add-json wordpress-develop --scope user '{"command":"npm", "args":["--prefix", "~/repos/wordpress-develop/", "run", "env:cli", "--", "mcp-adapter", "serve", "--server=mcp-adapter-default-server", "--user=admin"]}'Code language: Shell Session (shell)

Here’s the JSON with formatting:

{
	"command": "npm",
	"args": [
		"--prefix",
		"~/repos/wordpress-develop/",
		"run",
		"env:cli",
		"--",
		"mcp-adapter",
		"serve",
		"--server=mcp-adapter-default-server",
		"--user=admin"
	]
}Code language: JSON / JSON with Comments (json)

You may want to remove --scope user if you just want to register the MCP server for the one project. I tend to re-use the same WP environment for multiple projects (core and plugins), so I think it may make it easier for me to install at the user level instead.

You will also need to change the --prefix arg’s ~/repos/wordpress-develop/ value to correspond to where the repo is actually cloned on your system. I include this arg here so that when I start claude inside of a plugin project (e.g. inside src/wp-content/plugins/performance), it is able to successfully run the npm command in the package.json in the ancestor directory. You can remove this --prefix arg if this is not relevant to you.

Change the user from admin according to your needs.

3. Expose all abilities to MCP

Registered abilities are not exposed to MCP by default. This is a safety measure so that AI agents have to be explicitly allowed to perform potentially sensitive actions. So without any plugins active other than the MCP Adapter, prompting Claude with “discover abilities” results in:

No abilities found. The MCP server connection may be unstable. Try reconnecting again with /mcp.

However, since this is a local development environment, there is no concern about this (for me at least). To opt in all abilities to be exposed to MCP by default, you can use the following plugin code:

add_filter(
	'wp_register_ability_args',
	static function ( array $args ): array {
		if ( wp_get_environment_type() === 'local' ) {
			$args['meta']['mcp']['public'] = true;
		}
		return $args;
	}
);Code language: PHP (php)

This is also available in a gist, to facilitate installation via Git Updater.

Note: This filter does not currently apply if your ability is registered by extending Abstract_Ability in the AI plugin.

At this point, I can now open Claude (or re-connect to the MCP server) and see that it is able to see all (er, most) abilities that are registered on my wordpress-develop env with the same prompt “discover abilities”:

3 WordPress abilities available:

core/get-environment-info — Returns runtime context (PHP, database, WordPress version) with the ability name.

core/get-site-info — Returns site information (all fields or filtered subset)

core/get-user-info — Returns current user profile details

When I prompt “what’s the environment info?” it executes the core/get-environment-info ability via MCP and prints out:

  • Environment: local
  • PHP Version: 8.3.26
  • Database Server: 8.4.8 (MySQL)
  • WordPress Version: 7.1-alpha-62161-src

Now the environment just needs more abilities! I’ve filed a Performance Lab issue for us at the Core Performance table to work on adding abilities during Contributor Day at WordCamp Asia tomorrow.


Where I’ve shared this:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *