WordPress 7.2 Abilities API Implementation: Schema for Custom AI Capabilities, Plugin Integration, and REST Endpoint Exposure — Developer Blueprint

WordPress 7.2 Abilities API Implementation: Schema for Custom AI Capabilities, Plugin Integration, and REST Endpoint Exposure — Developer Blueprint

La WordPress 7.2 Abilities API represents the native framework for exposing structured, machine-readable, and automatically discoverable application capabilities. Unlike traditional hooks or custom post types, the Abilities API provides a deterministic interface for AI agents, third-party plugins, and MCP (Model Context Protocol) systems, allowing for recording, validating, and executing operations with precise JSON-LD schemas and centralized authorization callbacks.

For Italian publishers, SaaS and newsrooms that are implementing Generative Engine Optimization (GEO) and integration of Agencic content workflows, The ability to expose custom capabilities through REST endpoints creates attack surfaces for automation, interoperability between plugins, and coordinated orchestration of editorial processes. This technical guide describes the complete lifecycle: category registration, definition of AI-ready semantic schemas, security callbacks, and end-to-end testing of REST exposure.

Fundamental Architecture: Abilities vs Traditional Hooks

A traditional WordPress hook is an event or a filter: it executes code when an event occurs (e.g. save_post) or modify a value during the transition. It lacks structural semantics: no external tool knows which hooks are available, what parameters are expected, what permissions are required.

The Abilities API makes the site’s capabilities both machine-readable and executable, providing a standard registry of the actions that the site can perform. An ability is a discrete unit of work: it has a unique name (plugin-slug/action-name), a description readable from the LLM, JSON Schema schemas for input and output, execution callbacks, and authorization.

The strategic advantage: provides a standardized library for discovering and executing WordPress capabilities, This allows external AI tools, MCP agents, administrative dashboards, and third-party plugins to self-configure their operations without hardcoding.

Recording Cycle: Categories and Ability

Step 1: Registration of the Category

Each ability belongs to a category. The category organizes the abilities into semantic spaces (e.g. content-management, analytics, media processing). To add custom capabilities, you must first register a skill category by connecting to wp_abilities_api_categories_init. The registration function accepts a unique category slug and an array of metadata.

Implementation

add_action('wp_abilities_api_categories_init', function () {
    wp_register_ability_category(
        'ai-content-ops',
        array(
            'label' => __( 'AI Content Operations', 'my-publisher' ),
            'description' => __( 'Generate, process, and orchestrate structured content via LLM providers.', 'my-publisher' ),
        )
    );
};

Step 2: Registration of the Ability with Schema

To record a custom ability, call wp_register_ability() inside the hook wp_abilities_api_init, by passing a name in format plugin-slug/ability-name and an array $args containing at least label, description, category, output_schema, execute_callback, and permission_callback.

The following example implements an ability for the semantic restyling of articles via the vision model Gemini:

add_action('wp_abilities_api_init', function () {
    wp_register_ability(
        'publisher/restyle-article-semantic',
        array(
            'label' => __( 'Restyle Article via Vision Model', 'publisher-plugin' ),
            'description' => __( 'Analyzes article structure via Gemini Vision API, identifies missing semantic sections (summary, entity mentions, call-to-action), and generates JSON-LD suggestions for GEO compliance.', 'publisher-plugin' ),
            'category' => 'ai-content-ops',
            'input_schema' => array(
                'type' => 'object',
                'properties' => array(
                    'post_id' => array(
                        'type' => 'integer',
                        'description' => 'The post ID to restyle.',
                    ( ),
                    'include_vision_analysis' => array(
                        'type' => 'boolean',
                        'description' => 'Extract entities and visual semantics via Gemini 3.7.',
                        'default' => true,
                    ( ),
                    'target_schema_types' => array(
                        'type' => 'array',
                        'items' => array( 'type' => 'string' ),
                        'description' => 'Desired schema.org types: e.g., ["NewsArticle", "FAQPage", "BreadcrumbList"].',
                    ( ),
                ( ),
                'required' => array( 'post_id' ),
            ( ),
            'output_schema' => array(
                'type' => 'object',
                'properties' => array(
                    'post_id' => array(
                        'type' => 'integer',
                        'description' => 'The processed post ID.',
                    ( ),
                    'semantic_sections' => array(
                        'type' => 'object',
                        'description' => 'Identified semantic sections: title, summary, entities, faq, cta.',
                    ( ),
                    'json_ld_suggestions' => array(
                        'type' => 'array',
                        'description' => 'Array of suggested JSON-LD blocks for AI readiness.',
                    ( ),
                    'execution_time_ms' => array(
                        'type' => 'integer',
                        'description' => 'Latency in milliseconds.',
                    ( ),
                ( ),
                'required' => array( 'post_id', 'semantic_sections', 'json_ld_suggestions' ),
            ( ),
            'execute_callback' => 'publisher_restyle_article_execute',
            'permission_callback' => 'publisher_restyle_article_permission',
            'meta' => array(
                'show_in_rest' => true,
                'annotations' => array(
                    'readonly' => false,
                    'destructive' => false,
                    'idempotent' => false,
                    'instructions' => 'Transforms article semantic structure and validates compliance with GEO schema standards.',
                ( ),
            ( ),
        )
    );
}

function publisher_restyle_article_execute( $input ) {
    $post_id = $input['post_id'] ?? 0;
    $post = get_post( $post_id );

    if ( ! $post ) {
        return new WP_Error(
            'ability_post_not_found',
            sprintf( 'Post %d not found.', $post_id)
        );
    }

    $start_time = microtime(true);

    // Call the Gemini Vision API for structural analysis
    $vision_analysis = publisher_call_gemini_vision($post);
    $semantic_sections = publisher_extract_semantic_sections( $vision_analysis );
    $json_ld_suggestions = publisher_generate_json_ld( $semantic_sections );

    $end_time = microtime(true);

    return array(
        'post_id' => $post_id,
        'semantic_sections' => $semantic_sections,
        'json_ld_suggestions' => $json_ld_suggestions,
        'execution_time_ms' => (int) ( ( $end_time - $start_time ) * 1000 ),
    );
}

function publisher_restyle_article_permission( $input ) {
    return current_user_can( 'edit_posts' ) ? true : new WP_Error(
        'rest_forbidden',
        __( 'You do not have permission to restyle articles.' ),
        array( 'status' => 403 )
    );
}

Design Scheme for AI Readiness

The schema provided for capabilities is not just documentation; it is the primary way AI agents understand what your capability does and how to use it. Write it as you would write documentation for a developer who has never seen your plugin.

Best Practices for Input Schema

  • Explicit types: Specification integer, string, boolean, array for each parameter. Do not rely on the implicit casting.
  • Descriptions for each property: Include descriptions for each parameter. AI agents use them to determine which parameter corresponds to which user intent. A parameter called id Without a description it is ambiguous; one with a description like “The post ID of the item to update” is not.
  • Marchia required vs optional: The array required In JSON Schema it is used by the registry for automatic validation. The optional parameters should have sensible defaults defined.
  • Use enum for bound values: If a parameter accepts only a fixed set of values (post-states, ordering), list them.

Best Practice for Output Schema

  • It documents the successful structure: which keys are guaranteed, which are optional.
  • Include side effects in the ability description (e.g., “Create a draft post and trigger the hook”) save_post“).
  • Each property of the schema must have a description. AI agents read the descriptions of the scheme literally — treat it like a contract.

REST Endpoint Exposure and Authentication

The REST exposure is disabled by default. A plugin accepts it for ability with meta.show_in_rest. Once enabled, authenticated clients can list the abilities under /wp-json/wp-abilities/v1/abilities, Retrieve one per namespace and name, and call its endpoint /run.

// Discover all the available abilities
GET /wp-json/wp-abilities/v1/abilities
Authorization: Bearer {token}

// Discover a specific ability
GET /wp-json/wp-abilities/v1/abilities/publisher/restyle-article-semantic
Authorization: Bearer {token}

// Execute the ability
POST /wp-json/wp-abilities/v1/abilities/publisher/restyle-article-semantic/run
Content-Type: application/json
Authorization: Bearer {token}

{
  "post_id": 42,
  "include_vision_analysis": true,
  "target_schema_types": ["NewsArticle", "FAQPage"]
}

Authentication: Application Passwords vs OAuth2

The REST endpoints of Abilities use the standard WordPress authentication. Cookie-based authentication is available for same-origin requests. The official REST documentation recommends Application Passwords for external access and also allows for custom authentication plugins.

For MCP bridges or AI agents:

  • Application Passwords: Generates a long-term token from the WordPress admin, with limited scope. Suitable for persistent service accounts.
  • OAuth 2.0: If the publisher allows third-party delegated access, implement OAuth2 via a plugin (OAuth2 Provider It is maintained actively in 2026).
  • JWT: Temporary and stateless tokens for headless architectures; JWT Authentication for WP REST APIs It is maintained in 2026.

Plugin Integration Pattern: Cross-Plugin Interoperability

Plugins can call each other the registered abilities safely, without any deep pairing or hidden hooks. This is the fundamental pattern for multi-stage workflows in Italian newsrooms.

Scenario: Content Triage Workflow

Let's assume three plugins:

  • publisher-seo: exhibits publisher-seo/analyze-keyphrases
  • publisher-fact-check: exhibits publisher-fact-check/validate-claims
  • publisher-orchestrator: calls the two previous abilities in sequence
add_action('wp_abilities_api_init', function () {
    wp_register_ability(
        'publisher-orchestrator/content-quality-gate',
        array(
            'label' => __( 'Content Quality Gate', 'publisher-orchestrator' ),
            'description' => __( 'Runs SEO analysis and fact-checking on a post draft. Stops if claims fail validation.', 'publisher-orchestrator' ),
            'category' => 'content-workflow',
            'input_schema' => array(
                'type' => 'object',
                'properties' => array(
                    'post_id' => array(
                        'type' => 'integer',
                        'description' => 'Draft post to validate.',
                    ( ),
                ( ),
                'required' => array( 'post_id' ),
            ( ),
            'output_schema' => array(
                'type' => 'object',
                'properties' => array(
                    'post_id' => array( 'type' => 'integer'),
                    'seo_analysis' => array( 'type' => 'object' ),
                    'fact_check' => array( 'type' => 'object' ),
                    'gate_status' => array(
                        'type' => 'string',
                        'enum' => array( 'pass', 'fail', 'review' ),
                        'description' => 'Quality gate outcome.',
                    ( ),
                ( ),
            ( ),
            'execute_callback' => 'publisher_orchestrator_quality_gate',
            'permission_callback' => function() {
                return current_user_can('edit_posts');
            },
        )
    );
}

function publisher_orchestrator_quality_gate( $input ) {
    $post_id = $input['post_id'];

    // Step 1: Call ability SEO
    $seo_ability = wp_get_ability('publisher-seo/analyze-keyphrases');
    $seo_result = $seo_ability->execute( array( 'post_id' => $post_id );
    if ( is_wp_error( $seo_result ) ) {
        return $seo_result;
    }

    // Step 2: Call ability fact-check
    $fact_ability = wp_get_ability('publisher-fact-check/validate-claims');
    $fact_result = $fact_ability->execute( array( 'post_id' => $post_id );
    if ( is_wp_error( $fact_result ) ) {
        return $fact_result;
    }

    // Step 3: Determine the gate status
    $gate_status = ( $fact_result['failed_claims'] > 0 ) ? 'fail' : 'pass';

    return array(
        'post_id' => $post_id,
        'seo_analysis' => $seo_result,
        'fact_check' => $fact_result,
        'gate_status' => $gate_status,
    );
}

Notes: Controlling the HTTP Verb and Behavior

The annotations readonly, destructive, Idempotent They drive the HTTP verb on the REST endpoint. This is critical for security and for communicating to clients the type of operation.

  • readonly: true → GET (no state modification)
  • destructive: true → DELETE (permanently removes data)
  • idempotent: true → PUT (repeated executions = same result)
  • No annotation: POST (creation or mutable state)
'meta' => array(
    'annotations' => array(
        'readonly' => false, // Modifies post 'destructive' => false, // Does not delete 'idempotent' => false, // Can produce different results ),
( ),

Preparation Schema for AI Client and MCP

WordPress 7.1 has introduced wp_prepare_json_schema_for_client(), a function that converts WordPress internal schemas (with callbacks, required at the property level, etc.) into the standard Draft 4 JSON Schema compatible with AI tools, MCP adapters, and frontend validators.

WordPress 7.1 adds a shared layer of JSON Schema preparation that makes REST schemas, Abilities APIs, and AI providers portable by default.

// In your REST endpoint or MCP bridge
$ability = wp_get_ability('publisher/restyle-article-semantic');
$input_schema = $ability->get_input_schema();

// Prepare for AI client
$prepared_schema = wp_prepare_json_schema_for_client(
    $input_schema,
    array( 'profile' => 'draft-04' )
);

// Now compatible with Gemini, Claude, or MCP agents

Maintain the canonical WordPress schema for server-side use; prepare only one copy for clients. This prevents the server-side validation from losing the callbacks it needs.

End-to-end testing and validation

Authorisation tests

Head that permission_callback correctly denies access to unauthorized users:

// Test: Subscriber user cannot execute
$user = wp_create_user( 'subscriber', 'pass', subscriber@test.local'');
wp_update_user_meta($user, 'wp_user_level', 0);

wp_set_current_user( $user );
$ability = wp_get_ability('publisher/restyle-article-semantic');
$result = $ability->execute( array( 'post_id' => 42 );

assert( is_wp_error( $result ), 'Should deny subscriber.' );

Input Validation Tests

The plugin's JSON Schema validates input before execution:

// Invalid input: post_id is a string instead of an integer wp_set_current_user( 1 );
$ability = wp_get_ability('publisher/restyle-article-semantic'); $result = $ability->execute(array( 'post_id' => '42'));

// WordPress automatically validates against input_schema assert( is_wp_error( $result ), 'Should fail type validation.' );

REST Endpoint Test

// Discover ability via REST
$response = wp_remote_get(
    home_url( '/wp-json/wp-abilities/v1/abilities/publisher/restyle-article-semantic' ),
    array(
        'headers' => array(
            'Authorization' => 'Bearer ' . wp_create_nonce( 'wp_rest' ),
        ( ),
    )
);

assert( 200 === wp_remote_retrieve_response_code( $response );
$data = json_decode(wp_remote_retrieve_body( $response ), true);
assert( 'publisher/restyle-article-semantic' === $data['name']);

Integration with GEO and Content Enrichment

According to'GEO Content Engineering approach, The Abilities API enables the Semantic Content Enrichment automatic. The abilities can:

The result: articles natively AI-ready, visible in AI Overviews and the STRUCTURED_DATA schema according to GEO.

Compliance and Security

  • Required Callback Permission: Each ability requires an authorization callback. Check the sensible minimum capability.
  • Input Validation: JSON Schema automatically validates input before execution. Bad input never reaches the callback.
  • GDPR Compliance: If an ability accesses user data, it documents the processing in the description and logs the executions for audit trail.
  • MCP Bridge Gating: WordPress core does not automatically expose a specific provider-specific MCP endpoint or plugin manifest. A bridge must authenticate with WordPress, select the allowed abilities, translate schemas, apply its limits, and map errors to the client. It should expose fewer operations than the user can perform with WordPress, not every ability discovered.

FAQ

What is the difference between an Ability and a Custom REST Endpoint?

A Custom REST Endpoint is a single HTTP route with proprietary logic. An Ability is a semantic units of work with structured schematics, authorization, and annotations. An Ability it can It can be exposed via REST, but its true strength is in its machine-readable discovery and orchestration: AI agents, third-party plugins, and client MCPs know how to use it without hardcoding.

Can I record an Ability without exposing REST (show_in_rest: false)?

If no external client needs the ability, omit it show_in_rest and calls the internability internally via wp_get_ability(). This is useful for internal operations that only the core of the plugin orchestrates, not public ones.

How do I manage dependencies between abilities? (e.g., SEO + Fact-Check in sequence)

The Core provides recording, discovery, validation, and execution. It does not create a workflow planner from a field. depends_on Customized. If multiple operations need to be performed in a fixed order, implement a server-side ability that handles the transaction or allow a revised orchestration level to call a separate ability. This is exactly the pattern publisher-orchestrator/content-quality-gate shown above.

What is the best way to version an Ability?

Do not directly modify a registered ability: create a new ability with the versioned name (e.g. publisher/restyle-article-semantic-v2). Keep the old one for backward compatibility. Gradually update the clients to the new version. This avoids breaking changes in legacy orchestrators that depend on v1.

How do I integrate MCP (Model Context Protocol) with my Ability?

Creates an MCP bridge that:

  1. Authenticates in WordPress via Application Password
  2. Discover the abilities through GET /wp-json/wp-abilities/v1/abilities
  3. Convert any scheme using wp_prepare_json_schema_for_client(schema, 'draft-04')
  4. Expose as MCP Tool (one per ability)
  5. When an LLM invokes a MCP Tool, it calls the REST endpoint. POST /wp-json/wp-abilities/v1/abilities/{name}/run

See WordPress 7.2 AI Client Deep Dive for the complete implementation.

Conclusion

La WordPress 7.2 Abilities API It transforms the way plugins communicate, AI agents orchestrate editors, and the MCP bridge exposes WordPress capabilities. By recording ability with precise JSON Schema schemas, centralized authorization callbacks, and semantic annotations, Italian newsroom developers build deterministic, testable, and GDPR-compliant multi-stage workflows.

The key: treats the schemes as public contracts. Write them as if a novice LLM would use them without reading the code. Maintain server-side conventions, prepare copies for AI clients. Address authorization and end-to-end input validation. Integrate with GEO Content Engineering to ensure that the enriched content is natively AI-ready.

The Ability API is not a technical detail — it is the basic infrastructure for the Generative Engine Optimization, Editorial automation and the decentralized future of WordPress as an application platform.

Related articles