Abilities and MCP: making your WordPress plugin callable by AI agents
The Abilities API has been in WordPress Core since 6.9, and the MCP Adapter is now a WordPress.org plugin. How to register typed, permission-checked abilities, expose them over REST and MCP, and keep AI clients safely limited.
Arman Azij
6 min read
Why plugin authors keep hearing about MCP
AI coding tools and desktop assistants now speak MCP, the Model Context Protocol, as the standard way to call tools on other systems. WordPress has its own path into that world, and it is built from two pieces: the Abilities API, which has been in WordPress Core since 6.9, and the official MCP Adapter, which turns registered abilities into tools an AI client can call. The adapter reached the WordPress.org plugin directory with version 0.7.0 in October, and 0.7.1 followed on October 16.
That makes this a good moment for plugin authors to look at abilities, because an ability is useful even if you never touch AI. It is a typed, permission-checked, discoverable description of something your plugin can do. MCP is one consumer of that description, the REST API is another. As a Core contributor I find it useful to think of the Abilities API the way I think of the REST API ten years ago: a contract that other code can rely on, and that is worth getting right early.
What an ability is
An ability is a named unit of functionality with a schema for its input, a schema for its output, a permission check and a callback. Names use a namespace/ability-name form, for example my-plugin/get-post-count. Abilities are grouped into categories, and categories must be registered before the abilities that use them.
Registration happens on two dedicated hooks. Categories go on wp_abilities_api_categories_init, abilities on wp_abilities_api_init. Registering outside those hooks triggers _doing_it_wrong() and the registration fails.
add_action( 'wp_abilities_api_categories_init', static function () {
wp_register_ability_category( 'my-plugin', array(
'label' => __( 'My Plugin', 'my-plugin' ),
'description' => __( 'Content statistics.', 'my-plugin' ),
) );
} );
add_action( 'wp_abilities_api_init', static function () {
wp_register_ability( 'my-plugin/get-post-count', array(
'label' => __( 'Get post count', 'my-plugin' ),
'description' => __( 'Counts published items of a post type.', 'my-plugin' ),
'category' => 'my-plugin',
'input_schema' => array(
'type' => 'object',
'properties' => array( 'post_type' => array( 'type' => 'string' ) ),
),
'output_schema' => array( 'type' => 'integer' ),
'permission_callback' => static fn() => current_user_can( 'edit_posts' ),
'execute_callback' => static function ( $input ) {
return (int) wp_count_posts( $input['post_type'] ?? 'post' )->publish;
},
'meta' => array( 'show_in_rest' => true ),
) );
} );
Schemas are JSON Schema, a subset of draft 4, and they are mandatory whenever there is a value to pass or return. That is the part people skip and should not: the schema is what lets a client, human or AI, call your ability correctly without reading your code.
Around registration there is a small family of helpers: wp_has_ability(), wp_get_ability(), wp_get_abilities(), wp_unregister_ability(), and the matching category functions. PHP code can run an ability directly with wp_get_ability( 'my-plugin/get-post-count' )->execute(). The wp_before_execute_ability and wp_after_execute_ability actions fire around every run, which makes them the right place for logging. The wp_register_ability_args filter lets you change another plugin's ability, or Core's, at registration time.
The REST side
Set meta.show_in_rest to true and an ability gets endpoints under the wp-abilities/v1 namespace:
GET /wp-abilities/v1/categoriesand/categories/{slug}GET /wp-abilities/v1/abilitiesand/abilities/{name}/wp-abilities/v1/abilities/{name}/run, which executes it
These endpoints require an authenticated user, and application passwords are the recommended way in for external tools. The permission callback still runs on every call, so a REST client gets exactly the access the user behind it has.
From abilities to MCP tools
The MCP Adapter is an official package from the AI Building Blocks for WordPress initiative. Since 0.6.0 it requires WordPress 6.9 or newer, and the standalone Abilities API plugin is no longer a supported setup. Since 0.7.0 you install it as a regular plugin from the directory. Bundling it into your own plugin as a Composer library is deprecated in that release, which matters if you followed an earlier tutorial that did exactly that.
The adapter creates a default MCP server. Instead of turning every ability into its own tool, it exposes three: discover abilities, get ability info, and execute ability. The AI client discovers what your site can do, reads the schema, and then executes. An ability only shows up there when it is explicitly marked public. The February developer post describes the flag as meta.mcp.public, and the 0.6.0 release notes add that meta.public also counts unless meta.mcp.public opts out. Core abilities can be opted in with the wp_register_ability_args filter.
'meta' => array(
'show_in_rest' => true,
'mcp' => array( 'public' => true ),
),
There are two ways to connect a client:
- Local, over STDIO. The client launches WP-CLI:
wp --path=/path/to/site mcp-adapter serve --server=mcp-adapter-default-server --user=editor. This is the right choice for a local development site. - Remote, over HTTP. The client runs
npx -y @automattic/mcp-wordpress-remote@latestwithWP_API_URLpointing athttps://example.com/wp-json/mcp/mcp-adapter-default-server, plus a username and an application password.
Claude Desktop, Cursor, Claude Code and VS Code all read a small JSON config with that command. The details differ per client, for example VS Code uses a servers key where the others use mcpServers.
Security: treat the AI client as a user
The most important sentence in the adapter's guidance is that MCP clients act as logged-in WordPress users. Everything follows from that:
- Write a real
permission_callbackwith the minimum capability the ability needs. Never use__return_trueon anything that changes data. - Give MCP access its own WordPress user with a limited role, not your administrator account.
- On public sites reached over HTTP, prefer read-only abilities. Keep write abilities for local or tightly controlled setups.
- Use application passwords, and revoke them when a tool is no longer used.
- Log ability runs through
wp_after_execute_ability, so you can see what an agent actually did.
This is the same discipline WordPress developers already apply to REST endpoints and AJAX handlers. The difference is that the caller is now software deciding on its own which ability to call, so a missing capability check gets found faster.
Where to start with your own plugin
- Pick two or three things users already do through your settings screens or REST routes, and register them as abilities with full input and output schemas.
- Start read-only: reports, counts, lookups. Add write abilities later, behind narrow capabilities.
- Turn on
show_in_restand test the endpoints with an application password before you think about MCP. - Install the MCP Adapter plugin on a local site, mark one ability public, and connect your editor over STDIO.
- Keep your plugin working without either: abilities register only on their own hooks, so older sites simply never call your registration code.
Takeaways
- The Abilities API has been in Core since WordPress 6.9; it is a typed, permission-checked contract for what your plugin can do.
- Register categories on
wp_abilities_api_categories_initand abilities onwp_abilities_api_init, always with schemas. show_in_restgives youwp-abilities/v1endpoints; the MCP Adapter plugin turns public abilities into MCP tools.- Install the adapter as a plugin, not a bundled Composer library, from 0.7.0 on.
- MCP clients are logged-in users. Capability checks, a dedicated low-privilege user and read-only defaults are not optional.