Lesson 1.1. What the Abilities API Is

Ten plugins, ten APIs

A typical client site runs an SEO plugin, a form, a store, a cache and half a dozen more extensions. Each can do something useful: show a page's SEO meta, clear the cache, create a coupon. And each exposes it in its own way: its own admin page, its own REST route, its own AJAX action, its own docs, or none at all.

Now imagine an AI agent connects to the site and asks: "What can you do?" The site can't answer. There is no single place that records what it can do and who is allowed to do it.

The Abilities API is that place.

Agenda

In 10 minutes you will:

  • say what the Abilities API is in one sentence;
  • take apart the three parts an ability is made of;
  • see the abilities WordPress core already has;
  • find your site's ability registry through REST and WP-CLI.

Theory

Definition

The Abilities API is the list of what your site can do and what it allows. Nothing more, nothing else.

It has been part of WordPress core since 6.9. Core, the theme and plugins add their actions to the list. Each such action is an ability.

The three parts of an ability

PartWhat it answersExample
What it isname namespace/action, label, description, categoryforwp-seo-helper/get-meta
What it takes and returnsinput_schema and output_schema (JSON Schema)ID or slug → SEO title, description
Who is allowedpermission_callbackcurrent_user_can( 'edit_posts' )

Plus execute_callback, the code that performs the action, and meta with hints: whether the action only reads (readonly), destroys something (destructive), or gives the same result when called again (idempotent).

What an ability looks like in code

A real registration from our plugin 4WP SEO Helper (shortened):

PHP
add_action( 'wp_abilities_api_init', function () {
	wp_register_ability(
		'forwp-seo-helper/get-meta',
		array(
			'label'               => __( 'Get SEO meta of a post', '4wp-seo-helper' ),
			'description'         => __( 'SEO meta of one post or page by ID or slug.', '4wp-seo-helper' ),
			'category'            => 'forwp-seo-helper',
			'input_schema'        => array( /* id or slug */ ),
			'output_schema'       => array( /* raw and effective SEO meta */ ),
			'execute_callback'    => array( $this, 'get_meta' ),
			'permission_callback' => array( $this, 'can_read' ), // current_user_can( 'edit_posts' )
			'meta'                => array(
				'annotations' => array(
					'readonly'    => true,
					'destructive' => false,
					'idempotent'  => true,
				),
			),
		)
	);
} );

The plugin describes what it can do. It doesn't care who calls it: PHP code, a REST client, a block in the editor or an AI agent. We'll go through registration in detail in module 2.

What core already has

WordPress registers its own categories (site, user) and abilities:

AbilityWhat it returnsWho is allowed
core/get-site-infoname, description, URL, language, WordPress versionmanage_options
core/get-user-infothe current user's dataanyone logged in
core/get-environment-infoenvironment: PHP, database, environment typemanage_options

Note: even "just site info" is available only to an administrator. Permissions are part of the ability, not an add-on.

One registry, many doors

flowchart LR
  C["Core"] --> R["wp_register_ability"]
  T["Theme"] --> R
  P["Plugins"] --> R
  R --> REG["Registry"]
  REG --> PHP["PHP<br/>wp_get_abilities()"]
  REG --> REST["REST<br/>/wp-json/wp-abilities/v1/"]
  REG --> JS["JavaScript"]
  REG --> MCP["MCP Adapter → AI app"]
  1. Register. Categories on the wp_abilities_api_categories_init hook, abilities on wp_abilities_api_init.
  2. Registry. Everything goes into one registry: wp_get_abilities(), wp_get_ability(), wp_has_ability().
  3. Check. Before running, WordPress validates the input against the schema and calls permission_callback.
  4. Call. The same list is available in PHP, through REST, in JavaScript and through the MCP Adapter for AI apps.

Code / commands

BASH
# Abilities an administrator can see
curl -s https://site.test/wp-json/wp-abilities/v1/abilities -u admin:'APP PASS WORD' | jq '.[].name'

# Categories
curl -s https://site.test/wp-json/wp-abilities/v1/categories -u admin:'APP PASS WORD' | jq '.[].slug'

# The same from PHP
wp eval 'foreach ( wp_get_abilities() as $a ) { echo $a->get_name(), PHP_EOL; }'

# Call a read-only ability: GET + /run
curl -s https://site.test/wp-json/wp-abilities/v1/abilities/core/get-site-info/run -u admin:'APP PASS WORD'

REST shows only abilities with meta.show_in_rest (or meta.public). By default an ability is not shown in REST: a deliberate decision in core.

Trade-offs

OptionSimplerCosts moreWhen to choose
Your own REST route for each actiona familiar toolevery client learns your API separately; AI knows nothing about itonly your own front end needs the action
Abilityone standard, schemas and permissions in one place, available to REST and MCPyou need to think through the name, schemas, permissionsdifferent clients will call the action, AI among them
BothREST for your own UI, an ability for everyone elsetwo contracts to maintaina large plugin with its own interface

The course principle: start simple. Not every function deserves to become an ability, only actions a person will actually ask for.

Common mistakes

SymptomCauseFix
The ability isn't in /wp-abilities/v1/abilitiesshow_in_rest is not enabledmeta.show_in_rest => true (module 2)
wp_register_ability triggers _doing_it_wrongcalled outside the wp_abilities_api_init hookregister only on this hook
A guest gets 401 on /wp-abilities/v1/abilitiesthe list is available only to logged-in users (read)request with an Application Password
"The Abilities API is a plugin"confusion with the Feature Plugin before 6.9since WordPress 6.9 it's core

Practice

  1. Create an Application Password for the administrator of a local site.
  2. Get the list of abilities through REST and through wp eval.
  3. Call core/get-site-info through /run and find the WordPress version in the response.

Result: you see the list of what your site can do, and you got a response from one ability.

Quiz

  1. The Abilities API is: a) a plugin for AI; b) the list of what a site can do and allows; c) a new REST namespace for posts.
  2. Which part of an ability decides who may call it?
  3. On which hook are abilities registered?
  4. Why doesn't core/get-site-info answer a guest?

<details> <summary>Answers</summary>

  1. b.
  2. permission_callback.
  3. wp_abilities_api_init (categories: wp_abilities_api_categories_init).
  4. Its permission_callback requires manage_options.

</details>

FAQ

No. Since WordPress 6.9 the Abilities API is part of core. A separate plugin (MCP Adapter) is needed only to hand abilities to AI apps through MCP.

A REST route is an address for HTTP requests. An ability is a description of an action: name, input and output schemas, permissions, hints about behavior. An ability can be called from PHP, through REST and through MCP.

WordPress core, the theme and plugins. Each under its own namespace, so the owner is visible: core/…, forwp-seo-helper/….

No. The agent sees only what was opened for MCP, and only if the user it works on behalf of has the permissions. How to set this up: modules 5–7.

Save your progress

Sign in or create a free account to mark lessons as completed and continue the whole course. You will come back to this lesson.