Skip to content

PoC: consume abilities via the wordpress-abilities package - #430

Draft
nikmclaughlin wants to merge 3 commits into
WordPress:trunkfrom
nikmclaughlin:poc/consume-wordpress-abilities
Draft

nikmclaughlin wants to merge 3 commits into
WordPress:trunkfrom
nikmclaughlin:poc/consume-wordpress-abilities

Conversation

@nikmclaughlin

@nikmclaughlin nikmclaughlin commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

This PoC proves the pattern of using a central provider package for consuming WP Abilities to expose as tools via MCP, instead of authoring abilities directly in this plugin. It is ⚠️ not intended to be merged ⚠️ , and instead serves as a basis for discussion and iteration on that pattern before the proposed package (currently under personal ownership: https://github.com/nikmclaughlin/wordpress-abilities ) can be migrated to proper WordpPress/ GH ownership.

The proposed package's 18 canonical abilities are registered with the WP Abilities API via a new Registrar::register_all() (filter-gated in McpAdapter::instance()) and exposed through the default MCP server's layered discovery design, thereby making them accessible to MCP clients.

Why?

As outlined in #402, the MCP Adapter needs a set of Abilities for interacting with core WP entities (posts, users, media, etc.) so it can expose those as tools that enable WordPress site management through agentic workflows.

Providing those abilities from a central provider package:

  1. eases the maintenance burden for the Core AI team to develop and test experimental abilities across canonical plugins
  2. provides a single path for iterating and promoting abilities to WP Core, and
  3. gives ecosystem developers a way to consume experimental abilities from a canonical source without adding a full dependency on one of the canonical plugins.

Once the consumption pattern has been validated, the provider package is intended for migration to the WordPress GH org, at which point a separate PR can be cut to use those abilities in production. To clarify, that means that this PR deliberately does not close #426. That issue stays open through roadmap steps 3–4, and this PoC is a design-feedback draft, not a merge candidate.

How?

  • P1 — Dependency wiring: wordpress-abilities dependency added to composer.json, pinned to an open PR that adds some missing meta flags so all 18 abilities are exposed via MCP (details below). The package includes its own optional autoloader, but MCP Adapter can continue using Jetpack Autoloader without issue.
  • P2 — Ability Registration: In McpAdapter::instance(), immediately after the wp_abilities_api_init subscription:
    if ( (bool) apply_filters( 'mcp_adapter_register_wordpress_abilities', true ) ) {
        Registrar::register_all();
    }
    Handles registration of the packaged abilities with the WP Abilities API. Exposure to MCP is still resolved at the adapter layer by McpAbilityExposure, preserving its default-secure, explicit-opt-in model.

Not in scope

  • No changes to MCP's default server: per docs/guides/default-server.md, layered discovery is the intended design; tool-type abilities intentionally don't auto-discover into tools/list. The PoC's regression test pins tools/list at exactly the 3 meta-tools to ensure packaged abilities don't leak into context prematurely.
  • No settings or end-user-facing UI.
  • No package internals exposed beyond the registry.

Use of AI tools

Tool(s):

  • Goose (agent) for planning and implementation.

Models (via Ollama cloud):

  • GLM 5.3 for planning and orchestration,
  • GLM 5.3 Flash for implementation, validation, and testing.

Testing Instructions

Automated checks (all green on this branch)

Run from the repo root:

composer install       # resolves wordpress/abilities at the pinned dev-add/mcp-public-meta#00d65cf
npm run lint:php       # phpcs — 0 errors
npm run lint:php:stan  # phpstan (level 8) — no errors
npm run test:php       # full suite: 556 tests / 4,945 assertions — OK (1 pre-existing multisite skip)

The new coverage lives in tests/phpunit/Integration/WordpressAbilitiesConsumptionTest.php (13 cases). It pins: all 18 package abilities register with provenance; the content/media categories declare without backfill; tools/list stays at exactly the 3 meta-tools; discovery → get-ability-info → execute-ability work through the meta-tools; exposure resolves 10 abilities via meta.public and 8 via meta.mcp.public through McpAbilityExposure; the mcp_adapter_register_wordpress_abilities opt-out filter yields zero package registrations with the adapter trio intact; and registration is idempotent (no duplicates, no _doing_it_wrong notices).

Manual end-to-end (validated live on both environments)

Stable WordPress (the adapter's test env):

  1. Start the environment and confirm the adapter + package load: npm run wp-env:start.
  2. Call tools/list on the default server — it should return exactly the three meta-tools (mcp-adapter-discover-abilities, mcp-adapter-get-ability-info, mcp-adapter-execute-ability) and nothing else.
  3. Run discover-abilities — all 18 package abilities appear, each with label + description
  4. Run get-ability-info for core/content-create — it returns the ability's full input/output schema plus its meta.
  5. Run execute-ability with core/content-create as an admin — the call returns success: true, the post exists (wp post list to verify), and a follow-up execute-ability with core/content-query reads it back.
  6. Permission checks: a logged-out request is rejected (REST 401 rest_forbidden); a subscriber can read through the meta-tools but is denied on write abilities.

Trunk WordPress (7.2-beta3):

  1. Boot a trunk env against this branch and repeat the discovery checks: the backported trio (core/content-query, core/settings-get, core/users-query) self-skips since core provides them, so each lists only once with core provenance while all 12 wp/* experimental abilities still register from the package copy, and reads/writes behave identically to stable.

Changelog entries

Added in CHANGELOG.md:

## [Unreleased]

### Added
- PoC: consume core abilities from the `wordpress-abilities` package. Provided abilities are registered with WordPress and then surfaced through the default server's layered-discovery meta-tools.

Open questions for the team

  1. Consumption via central package vs. writing into the plugin: Do we want to continue down this path? Are the tradeoffs I outlined above worth the additional overhead of one more package?
  2. Migration to WordPress/ canonical repo: If we want a standalone package, can we move that under WP organizational ownership?
  3. instance() vs. init(): I wasn't sure which method was the correct spot for registering bundled abilities but opted for instance() to keep it closer to the plugin's own ability registration. Need confirmation of where that should land in the plugin lifecycle.
  4. Default-on vs. opt-in — the PoC registers all abilities as default-on behind the filter. This provides the smoothest setup experience (install the plugin and it "just works"), but needs confirmation.
  5. meta.mcp.public vs. meta.public: the pinned PR adds the MCP-specific meta.mcp.public flag to the media & terms abilities so they are exposed on the MCP surface in testing. Other abilities already included the higher-level meta.public flag, but the source PRs for media and terms did not. We need to decide if those abilities should also be exposed by default, which level of flag is appropriate if so, and then merge those changes to the abilities package for distribution.
Open WordPress Playground Preview

Register the canonical `wordpress/abilities` package via
Registrar::register_all() at plugin load, filter-gated by a new
mcp_adapter_register_wordpress_abilities filter (default true for the
PoC). The call passes no public_only argument: the Registrar's gate
probes only the high-level meta.public, while MCP visibility resolves
at the adapter layer via McpAbilityExposure (meta.mcp.public first,
falling back to meta.public) — the media/terms abilities opt in through
the MCP-specific flag alone.

Package abilities surface through the default server's layered-discovery
meta-tools; DefaultServerFactory is unchanged and tools/list stays at
exactly the three meta-tools.

The dependency is pinned to the open package PR branch
(wordpress/abilities: dev-add/mcp-public-meta#00d65cf) until the team
decides on meta.mcp.public and Packagist publishing.

Gates: composer install (pin verified), npm run lint:php, npm run
lint:php:stan, npm run test:php — all green.
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.10%. Comparing base (55c17ce) to head (3176cc8).

Files with missing lines Patch % Lines
includes/Core/McpAdapter.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #430      +/-   ##
============================================
- Coverage     93.12%   93.10%   -0.03%     
- Complexity     1382     1383       +1     
============================================
  Files            59       59              
  Lines          4016     4018       +2     
============================================
+ Hits           3740     3741       +1     
- Misses          276      277       +1     
Flag Coverage Δ
unit 93.10% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nikmclaughlin nikmclaughlin changed the title PoC: consume the wordpress/abilities package via Registrar::register_all() (proposal #426, step 2 of 4) PoC: consume abilities via the wordpress-abilities package Oct 31, 2026
@nikmclaughlin nikmclaughlin changed the title PoC: consume abilities via the wordpress-abilities package PoC: consume abilities via the wordpress-abilities package Oct 31, 2026
@euvoor

euvoor commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Small test coverage gap in WordpressAbilitiesConsumptionTest: PACKAGE_ABILITIES = self::HIGH_LEVEL_PUBLIC + self::MCP_META_PUBLIC uses PHP array union. Both lists start at index 0, so the result contains 10 names, not 18; all eight media/terms names are dropped. I evaluated the exact constants from 3176cc8 to confirm this.

That weakens the registration, discovery and opt-in/out assertions using this constant. The separate checks of MCP_META_PUBLIC still run. Concatenating the lists and asserting a count of 18 would make the combined checks cover the intended set.

Comment thread composer.json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/nikmclaughlin/wordpress-abilities.git"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Use wordpress-abilities as central ability provider

3 participants