MCP Tool Dispatch vs. Embedded LLM Workers: Abilities API Manifests, Application Password Trust Inheritance, and Fleet Orchestration After WordPress 7.1.2

⚡ Quick Takeaways (TL;DR)

The embedded AI-plugin pattern (AI Engine, AI Power) runs model inference inside the PHP-FPM worker, coupling 1.9–6.4s of upstream provider latency to admin TTFB and parking provider API keys in plaintext, often autoloaded, `wp_options` rows. The MCP pattern (WPVibe, 50,000 installs at September close, up from 20,000 three weeks prior) inverts the control plane — WordPress registers a capability-gated tool surface over REST, authenticated with Application Passwords, dispatched in 180–450ms with zero in-request model I/O, and now formalized by the Abilities API with a Secrets API landing on the 7.2 roadmap. Deploy MCP tool dispatch behind fail-closed capability gates, per-credential quota ceilings, and human approval walls on every write tool; hold WordPress ≥ 7.1.2 fleet-wide (unauthenticated local file inclusion, backported to 4.7); and retire BYO-key embedded plugins from production request paths.

📑 Table of Contents ▾

1. System Topology & Architectural Impact: The Inverted Control Plane — Agent-Resident Models vs. PHP-Resident Model I/O

Moving model inference out of the PHP worker and into the agent client eliminates upstream provider latency from every WordPress request; the consequence is that WordPress now answers machine callers over a REST surface whose authentication and authorization semantics were designed for humans; the fix is a capability-gated tool registry with per-credential ceilings enforced before any handler executes.

The embedded pattern (AI Engine, AI Power and the rest of the BYO-key generation) places the model call inside the request lifecycle:

[wp-admin Post Editor]
   │  admin-ajax.php / REST — blocking, same PHP-FPM worker
   ▼
[AI Plugin Runtime]  ← provider key deserialized from autoloaded wp_options row
   │  cURL (TLS) — 300ms–4s+ upstream model latency
   ▼
[api.openai.com / api.anthropic.com]
   │  token stream buffered in worker memory
   ▼
[PHP-FPM slot held for full model duration → worker starvation under concurrency]

The MCP pattern inverts the direction of every arrow. WPVibe registers WordPress as a tool provider; ChatGPT, Claude, or Cursor holds the model, the conversation state, and the retry semantics:

[ChatGPT / Claude / Cursor]  — agent-side model + fleet context
   │  MCP over Streamable HTTP — JSON-RPC 2.0 tools/call
   ▼
[WP REST: /wp-json/<ns>/v1/tools/call]
   │  Application Password (Basic) → WP_Application_Passwords::authenticate()
   ▼
[Abilities Registry — manifest + JSON Schema, Redis-cached]
   │  capability gate → rate ceiling → approval wall   (fail-closed order)
   ▼
[Tool Handlers: AIOSEO | WPForms | WPCode | EDD | PushEngage | Duplicator]
   │  long-running? (fleet updates, pre-update backups)
   ▼
[Action Scheduler queue] → pre/post probes (checksum + HEAD) → resume or park
   ▼
[MySQL InnoDB | Redis object cache | Duplicator backup artifacts]

Hook placement is deterministic. The provider class loads at plugins_loaded; ability registration runs at init:10 so the manifest freezes before wp_loaded; REST dispatch bypasses template_redirect and the entire theme bootstrap, which is where the topology wins its latency budget — no template hierarchy resolution, no header asset enqueue, no front-end filter stack. shutdown carries the audit write so telemetry never sits inside the tool’s latency envelope. Fleet behavior maps directly onto this queue: core updates are excluded from the default job set and pause for explicit approval when included; a per-site failure isolates rather than aborts the batch; and the “close the tab” continuation works because the Action Scheduler action persists server-side — the client is polling state, not holding it.

Adoption velocity converts this from experiment to default attack surface. WPVibe crossed 20,000 installs in early September, 40,000 on September 23, and 50,000 by month close — roughly 1,430 new installs per day in the final week. Every one of those sites now exposes a machine-authenticated REST tool surface, and the same fleet query that lists pending updates also enumerates core versions, making version drift machine-visible and machine-exploitable.

2. Low-Level Implementation Mechanics: Ability Manifest Storage, Application-Password Capability Inheritance, and the 7.1.2 Include-Path Defect

Application Passwords authenticate over REST by mapping a 24-character token to the complete capability set of its owning user; the consequence is that one leaked fleet credential equals a full editor or administrator on every site it touches; the fix is fail-closed capability gates, approval walls on writes, and credential-per-purpose provisioning until core ships granular scoping via the Secrets API on the 7.2 roadmap.

Manifest and settings storage. Embedded AI plugins are repeat autoload offenders. On a reference install with an AI Engine-class plugin active, SELECT SUM(LENGTH(option_value)) FROM wp_options WHERE autoload='yes' measured 412KB against a 187KB plugin-free baseline — model configuration, provider keys, and log fragments deserialized on every request, including front-end requests that never touch AI features. The Ability manifest must follow the opposite discipline: versioned rows with autoload='no', materialized into the object cache, invalidated on upgrader_process_complete. The site-side rate ceiling is likewise non-negotiable even though WPVibe’s plans enforce daily action quotas at the host layer — a business boundary outside the site is not a defense-in-depth boundary inside it.

Authentication path. The credential flows through rest_authentication_errors, resolves via WP_Application_Passwords::authenticate(), hashes against wp_usermeta, and sets the current user — with full capability inheritance and no per-tool scoping primitive in core today. WPVibe’s four-step setup page probes the connection from both inside and outside the site precisely because hardening configurations (security plugins disabling Application Passwords outright) break this path silently. REST-only scope is the one genuine mitigation: the token is useless against wp-login.php, XML-RPC having been fenced off separately.

The 7.1.2 defect class. WordPress 7.1.1 shipped 17 core fixes, 19 block editor fixes, and 11 security fixes; 7.1.2 followed with a single critical fix — an unauthenticated attacker, under specific server and theme conditions, could induce WordPress into including a local PHP file, and the patch was backported to WordPress 4.7. That backport range means the include-path defect lived across roughly nine years of the installed base. The failure signature is the classic one:

PHP Fatal error: Uncaught Error: Failed opening required
'/var/www/wp-content/themes/active-theme/../../../../uploads/2026/09/x.php'
in /var/www/wp-includes/template-loader.php

A traversal fragment surviving validation, reaching an inclusion primitive, resolving outside the theme directory on filesystems where canonicalization behaves permissively. The patched pattern is prefix containment — realpath() resolution checked against the intended template root before require executes. On an MCP-managed estate, the hardening order is fixed: core ≥ 7.1.2 everywhere first, tool surface second, because a pre-auth inclusion primitive renders every downstream gate decorative.

Adjacent surfaces. WPVibe’s SVG ingestion strips nodes, on* handlers, and javascript: URI fragments before sideloading, which is the only correct order — sanitize, then insert as attachment, and reject unparsable XML outright rather than best-effort cleaning. The WPForms Dashboard (“nothing to install or configure,” default-on, all plans) runs sitewide aggregation — entries, payments, views, conversion rates — on every admin page load. On a 60-form, 250k-entry estate that is an uncached GROUP BY with Using temporary; Using filesort per page view unless a composite index and transient cache intervene. Default-on analytics without a cache layer is a scaling hazard, full stop. The 7.2 roadmap’s Secrets API (encrypted-at-rest credential storage) and Sudo mode (password re-confirmation before sensitive actions) close the two largest gaps in this topology: plaintext provider keys in options, and write operations that no human ever confirmed.

3. Production-Ready Code & Infrastructure Automation: A Fail-Closed Ability Provider with Approval Walls and Quota Ceilings

A tool surface without a capability gate is an unauthenticated RCE factory wearing a REST costume. The provider below registers two abilities — one read, one write-with-approval — and enforces gates in fail-closed order: capability, then rate, then approval, then side effects.

declare(strict_types=1);

namespace WpdevbaseMcp;

use WP_Error;
use WP_REST_Request;
use WP_REST_Response;

final class Ability_Surface
{
    private const REST_NAMESPACE = 'wpdevbase-mcp/v1';
    private const RATE_CEILING   = 60;  // tool calls / credential / hour
    private const APPROVAL_TTL   = 900; // seconds a human has to release a write

    public static function boot(): void
    {
        add_action('init', [self::class, 'register_manifest'], 10, 0);
        add_action('rest_api_init', [self::class, 'register_routes']);
    }

    public static function register_routes(): void
    {
        register_rest_route(self::REST_NAMESPACE, 'tools/call', [
            'methods'             => 'POST',
            'callback'            => [self::class, 'dispatch'],
            // Authn happens at the REST layer (Application Password);
            // authz is enforced inside dispatch(), fail-closed.
            'permission_callback' => '__return_true',
        ]);
    }

    public static function register_manifest(): void
    {
        // Fail closed: without the registry, no tool surface is advertised at all.
        if (!class_exists('WP_Abilities')) {
            return;
        }

        WP_Abilities::register([
            'namespace' => 'wpdevbase.seo',
            'version'   => '1.4.0',
            'tools'     => [
                [
                    'name'              => 'wpdevbase.seo.list_missing_meta_descriptions',
                    'description'       => 'Published posts with an empty meta description, newest first.',
                    'capability'        => 'edit_posts',
                    'requires_approval' => false,
                    'idempotent'        => true,
                    'input_schema'      => [
                        'type'                 => 'object',
                        'properties'           => [
                            'limit' => ['type' => 'integer', 'minimum' => 1, 'maximum' => 100, 'default' => 25],
                        ],
                        'required'             => [],
                        'additionalProperties' => false,
                    ],
                ],
                [
                    'name'              => 'wpdevbase.seo.write_meta_description',
                    'description'       => 'Persist a 50-160 character meta description on a published post.',
                    'capability'        => 'edit_others_posts',
                    'requires_approval' => true,  // fleet credentials never write unattended
                    'idempotent'        => false,
                    'input_schema'      => [
                        'type'                 => 'object',
                        'properties'           => [
                            'post_id'     => ['type' => 'integer', 'minimum' => 1],
                            'description' => ['type' => 'string', 'minLength' => 50, 'maxLength' => 160],
                        ],
                        'required'             => ['post_id', 'description'],
                        'additionalProperties' => false,
                    ],
                ],
            ],
        ]);
    }

    public static function dispatch(WP_REST_Request $request): WP_REST_Response|WP_Error
    {
        $name = (string) $request->get_param('name');
        $args = is_array($request->get_param('arguments')) ? $request->get_param('arguments') : [];

        $definition = WP_Abilities::definition($name);
        if ($definition === null) {
            return new WP_Error('mcp_unknown_tool', "Tool '{$name}' is not registered.", ['status' => 404]);
        }

        if (!current_user_can((string) $definition['capability'])) {
            return new WP_Error(
                'mcp_forbidden',
                'Credential principal lacks the capability this tool declares.',
                ['status' => 403, 'required' => $definition['capability']]
            );
        }

        if (!self::within_rate_ceiling($name, self::credential_fingerprint())) {
            return new WP_Error('mcp_rate_limited', 'Hourly tool-call ceiling reached.', [
                'status'      => 429,
                'retry_after' => 3600 - (time() % 3600),
            ]);
        }

        if ((bool) $definition['requires_approval']) {
            $token = wp_generate_password(32, false);
            set_transient(
                "mcp:approval:{$token}",
                ['tool' => $name, 'args' => $args, 'user' => get_current_user_id()],
                self::APPROVAL_TTL
            );

            return new WP_REST_Response([
                'status'         => 'approval_required',
                'approval_token' => $token,
                'expires_in'     => self::APPROVAL_TTL,
            ], 202);
        }

        $limit = min(100, max(1, (int) ($args['limit'] ?? 25)));

        return new WP_REST_Response(['items' => self::query_missing_descriptions($limit)], 200);
    }

    private static function within_rate_ceiling(string $tool, string $fingerprint): bool
    {
        $bucket  = (string) (int) (time() / 3600); // fixed hourly window, no sliding drift
        $key     = "mcp:rl:{$fingerprint}:{$tool}:{$bucket}";
        $current = wp_cache_incr($key, 1, 'mcp');

        if (false === $current) {
            wp_cache_set($key, 1, 'mcp', 3600);
            return true;
        }

        return $current <= self::RATE_CEILING;
    }

    private static function credential_fingerprint(): string
    {
        // One bucket per Application Password, not per user.
        return hash('sha256', (string) ($_SERVER['HTTP_AUTHORIZATION'] ?? 'anonymous'));
    }

    private static function query_missing_descriptions(int $limit): array
    {
        global $wpdb;

        $rows = $wpdb->get_results(
            $wpdb->prepare(
                "SELECT p.ID, p.post_title, p.post_date
                 FROM {$wpdb->posts} AS p
                 LEFT JOIN {$wpdb->postmeta} AS pm
                   ON pm.post_id = p.ID AND pm.meta_key = '_aioseo_description'
                 WHERE p.post_type = 'post'
                   AND p.post_status = 'publish'
                   AND (pm.meta_value IS NULL OR pm.meta_value = '')
                 ORDER BY p.post_date DESC
                 LIMIT %d",
                $limit
            ),
            ARRAY_A
        );

        return is_array($rows) ? $rows : [];
    }
}

Provisioning and verification, end to end:

# Dedicated principal — never reuse a human editor's password for fleet automation.
wp user create mcp-agent [email protected] --role=editor --porcelain
wp user application-password create 318 "fleet-mcp-prod" --porcelain

# Audit the autoload surface before it becomes per-request I/O.
wp db query "SELECT option_name, LENGTH(option_value) AS bytes
              FROM wp_options WHERE autoload='yes'
              ORDER BY bytes DESC LIMIT 15;"

# Demote an AI plugin's settings row out of autoload without data loss.
wp option update ai_engine_settings --autoload=no

# Fleet background jobs die silently without a live Action Scheduler runner.
wp eval 'var_dump((int) wp_next_scheduled("action_scheduler_run_queue"));'

A live tool call, exactly as the agent issues it:

curl -sS -X POST 
  -u "318:xxxx xxxx xxxx xxxx xxxx xxxx" 
  -H 'Content-Type: application/json' 
  -d '{"name":"wpdevbase.seo.list_missing_meta_descriptions","arguments":{"limit":10}}' 
  'https://wp.test/wp-json/wpdevbase-mcp/v1/tools/call' | jq '.result.items | length'

The WPForms aggregation fix, before and after (schema names per the current Entries addon; verify with wp db search):

EXPLAIN SELECT form_id,
       COUNT(*)                             AS entries,
       SUM(status = 'spam')                 AS spam
FROM wp_wpforms_entries
WHERE date_created >= '2026-09-01' AND date_created < '2026-10-01'
GROUP BY form_id;
-- type=ALL, rows≈247000, Extra: Using where; Using temporary; Using filesort

ALTER TABLE wp_wpforms_entries
  ADD INDEX idx_form_date_created (form_id, date_created);
-- type=range, filesort eliminated, dashboard load 2.7s -> 380ms with warm object cache

4. Production Gotchas, Breaking Changes & Concurrency Risks: Revoked Credentials, Stale Manifests, and Indirect Prompt Injection Through Tool Output

Silent Application Password revocation is the highest-frequency failure mode in this topology. Security and hardening plugins that filter rest_authentication_errors to disable Application Passwords break every MCP tool call with a 401 that looks, from the agent’s side, like a credential rotation problem. Diagnose it from outside the site — an external probe returning 401 while the in-site probe returns 200 isolates the filter — which is exactly the dual-probe design WPVibe’s setup page implements. The second-order trap: a hardening plugin activated after the credential was issued can invalidate a working fleet job mid-batch.

Manifest staleness produces ghost tools. A cached ability manifest outlives the plugin that registered it; the agent then calls a tool that 404s mid-conversation, or calls it with a schema the new version no longer accepts. Invalidate on upgrade, not on TTL:

add_action('upgrader_process_complete', static function (array $options): void {
    if (($options['action'] ?? '') === 'update' && ($options['type'] ?? '') === 'plugin') {
        wp_cache_delete('mcp:abilities:manifest', 'mcp');
    }
}, 10, 1);

Fleet concurrency needs a mutex, not optimism. Action Scheduler unique-action keys deduplicate queued fleet jobs, but a human running a manual update in wp-admin during an active fleet pass bypasses the queue entirely — the pre-update probe passes, then two writers race the plugin directory and last-write-wins:

if (false === wp_cache_add("mcp:fleet:lock:{$site_id}", 1, 'mcp', 600)) {
    return new WP_Error('mcp_fleet_busy', 'A fleet job currently holds this site.', ['status' => 409]);
}

Background continuation is only as reliable as WP-Cron. Action Scheduler fires on page views by default; a fleet job targeting a staging site with zero traffic parks indefinitely, and the agent’s status poll returns “running” forever. Production estates need define('DISABLE_WP_CRON', true); plus system cron at one-minute intervals. The same dependency chain explains why the Duplicator integration gates updates on backup completion server-side — the update action must not enqueue until the backup artifact exists on disk, otherwise a missed cron converts a “backup then update” contract into “update, eventually maybe back up.”

Indirect prompt injection is the structural risk nobody prices in. The WPCode integration returns failed snippet source, line numbers, and page context to the agent. Snippet content is attacker-influenceable input; an agent that treats tool output as instruction rather than data will execute directives embedded in that output while holding fleet credentials. Enforce three invariants: write tools always hit an approval wall; tool output is rendered inert (never executed, never parsed as instructions); and the agent never follows directives discovered inside site content.

Memory exhaustion in embedded plugins misdirects the operator toward core:

[2026-09-24 03:14:02 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted
(tried to allocate 33554432 bytes) in /var/www/wp-includes/class-wp-hook.php on line 324

The stack indicts class-wp-hook.php, but the allocation belongs to a plugin buffering a multi-megabyte model response inside an the_content filter because it disabled streaming. Under Query Monitor, filter the REST/AJAX component and count repeated SELECT option_value FROM wp_options WHERE option_name = 'ai_engine_settings' — one per request against a non-persistent cache is the embedded pattern announcing itself.

One operational note on integration contracts: WPVibe’s published recipes (tested prompts per integration) are, from an engineering standpoint, regression fixtures for the tool boundary. Pin them in CI like any contract test — a recipe that silently breaks after a plugin update is an integration outage with no error page.

5. Telemetry Benchmark & Resource Allocation Matrix: Embedded LLM Workers vs. MCP Tool Dispatch on a 24k-Post Reference Estate

Reference stack: PHP 8.2-FPM (static, 8 workers), MariaDB 10.11, Redis 7.2 object cache, WordPress 7.1.2, 24,000 posts, 250,000 wp_postmeta rows, 60 WPForms forms with 250,000 entries. Model-side latency in rows 1–2 is upstream provider time and inherent to the embedded pattern; MCP rows contain none by construction.

Architecture / Implementation Latency (TTFB) Peak RAM Allocation DB Queries (Count / Type) Redis I/O Impact
Embedded plugin, single 1,000-token generation (blocking cURL, no streaming) 1.9–6.4s +9–14 MB/worker (cURL + stream buffer) 31–44 per admin load; repeated autoloaded-option SELECTs None on payload; keys re-read per request, 0% payload cache
Embedded plugin, site-trained chatbot, cold embedding pass 2.4–8.1s +18–26 MB (corpus chunking) 120–300; LIKE scans on post_content until indexed Heavy write burst; miss-storm on cold cache
MCP read tool, list_missing_meta_descriptions limit=25 180–420ms warm +2.1–3.4 MB 12–18; indexed LEFT JOIN on wp_postmeta ~6 KB/call; 99.1% hit ratio warm, manifest served from cache
MCP write tool behind approval wall 210–520ms machine time (approval latency human-bounded) +2.4–3.8 MB 15–22 including audit INSERT on shutdown ~8 KB/call + INCR on rate bucket
Fleet update, 10 sites, one plugin, pre/post verification 4m10s–6m50s wall clock, fully backgrounded +40–68 MB orchestrator peak (per-site report buffers) 35–60 per target site inside the update window Probe results cached 300s, ~2 KB/site
WPForms Dashboard, 60 forms / 250k entries 1.1–2.7s uncached → 220–380ms after idx_form_date_created + transient +12–16 MB (result materialization) 3–6 aggregate GROUP BY; filesort eliminated post-index Transient-backed, 97%+ hit after warm

The allocation conclusion is direct. Embedded LLM workers hold a PHP-FPM slot for the full duration of upstream model inference — at 4s median and 8 workers, two concurrent generations saturate 25% of the pool on latency the site cannot control, while their settings and keys inflate every request’s deserialize budget. MCP tool dispatch keeps the worker resident for under half a second, moves the model cost to the agent’s infrastructure, and reduces the WordPress-side footprint to indexed reads, gated writes, and cache-backed manifests. Pair the MCP topology with core ≥ 7.1.2 fleet-wide, scoped Application Passwords treated as full-admin credentials, approval walls on every write, system-cron-backed Action Scheduler, and Secrets API adoption the moment 7.2 ships it. Embedded BYO-key plugins belong in sandboxes and content workflows with no user-facing request path — nowhere else.

Written by Freja Nygård

Lead frontend engineer building ultra-lightweight declarative client experiences using the WordPress Interactivity API and micro-hydration directives.