Skip to content

Fix: register MCP resource URI under meta.mcp.uri - #29

Merged
oxyc merged 1 commit into
masterfrom
fix/php-errors
Jun 23, 2026
Merged

oxyc merged 1 commit into
masterfrom
fix/php-errors

Conversation

@oxyc

@oxyc oxyc commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

Kinsta production logs (site medihealth, ~448 errors/day) show:

[ERROR] ... Resource URI not found in ability meta for 'gds/block-types-list'

(also gds/site-map, gds/design-theme-json, gds/acf-fields), emitted by WP\MCP\Domain\Resources\RegisterAbilityAsMcpResource in the WordPress/mcp-adapter dependency.

Root cause

The four MCP resource abilities declared their uri and mimeType at the top level of meta. As of WordPress/mcp-adapter 0.5.0, the adapter resolves the resource URI from meta.mcp.uri (the canonical location); top-level meta.uri / meta.mimeType are deprecated. When mcp.uri is absent the adapter returns a resource_uri_not_found WP_Error, which is what flooded the logs.

The adapter's lookup (for reference):

// RegisterAbilityAsMcpResource::get_uri()
$uri = $this->get_mcp_meta( 'uri', 'string' ); // reads mcp.uri first
if ( null === $uri ) {
    return new WP_Error( 'resource_uri_not_found',
        "Resource URI not found in ability meta for '%s'. URI must be provided at 'mcp.uri'." );
}

Fix

  • Move uri and mimeType into meta.mcp for all four resource abilities (BlockCatalogResource, SiteMapResource, ThemeJsonResource, AcfFieldsResource). This is the canonical, non-deprecated location and resolves both the error and the _doing_it_wrong deprecation notices.
  • Update HelpAbility to read meta.mcp.uri with a top-level fallback so the help index (and HelpAbilityTest::test_resources_include_uri) keeps working.
  • annotations is intentionally left at the top level because SchemaValidationTest::test_all_abilities_have_annotations asserts on meta.annotations.

Verification

  • php -l clean on all changed files
  • composer lint (Pint) — passed
  • composer stan (PHPStan, level per repo config) — no errors
  • Full PHPUnit suite requires the wp-env DB harness (not runnable in this environment)

🤖 Generated with Claude Code

The four MCP resource abilities (gds/block-types-list, gds/site-map,
gds/design-theme-json, gds/acf-fields) declared their resource URI and
mimeType at the top level of `meta`. WordPress/mcp-adapter >= 0.5.0
expects these under the `mcp` namespace (`meta.mcp.uri`); the top-level
location is deprecated. When the adapter's RegisterAbilityAsMcpResource
cannot resolve `mcp.uri`, it returns a `resource_uri_not_found` WP_Error,
which surfaced in production as:

  [ERROR] Resource URI not found in ability meta for 'gds/block-types-list'

(also gds/site-map, gds/design-theme-json, gds/acf-fields) ~448x/day on
the medihealth site.

Move `uri` and `mimeType` into `meta.mcp` (the canonical, non-deprecated
location) and update HelpAbility to read `meta.mcp.uri` with a top-level
fallback so the help index and its test keep working. Annotations are
left at the top level since the integration suite asserts on that key.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oxyc
oxyc merged commit f1ae4aa into master Jun 23, 2026
2 checks passed
oxyc added a commit that referenced this pull request Jun 24, 2026
…mcp (#30)

PR #29 moved the resource `uri`/`mimeType` for the four MCP resource
abilities (gds/block-types-list, gds/site-map, gds/design-theme-json,
gds/acf-fields) out of top-level `meta` and into `meta.mcp`, on the
assumption that medihealth runs WordPress/mcp-adapter >= 0.5.0 (which
reads `meta.mcp.uri`).

The `resource_uri_not_found` error is still firing in production on
medihealth (~83x/day, latest 2026-06-24 08:02) despite #29 being
deployed (gds-mcp dev-master f1ae4aa, deployed 2026-06-23 16:57).

Root cause: the error text in production is
"...URI must be provided in ability meta data." — this is the PRE-0.5.0
adapter message. v0.5.0's message is "...URI must be provided at
'mcp.uri'." The pre-0.5.0 RegisterAbilityAsMcpResource::get_uri() reads
ONLY top-level `meta.uri` and has no knowledge of `meta.mcp.uri`. So
medihealth's actually-running adapter is < 0.5.0 even though its
composer.lock pins v0.5.0 (ref 7bfc49f4) — the deployed vendor/ is stale
relative to the lockfile. By moving `uri` exclusively into `meta.mcp`,
#29 removed the only location the deployed adapter reads, so the URI
became unresolvable and the error persists.

Fix: declare `uri`/`mimeType` in BOTH top-level `meta` AND `meta.mcp`
for all four resource abilities. This is adapter-version agnostic:
- adapter < 0.5.0 finds top-level `meta.uri`;
- adapter >= 0.5.0 finds `meta.mcp.uri` first (so no deprecation
  `_doing_it_wrong` notice is triggered).

HelpAbility already reads `meta.mcp.uri ?? meta.uri`, and the meta-shape
tests (HelpAbilityTest::test_resources_include_uri, SchemaValidationTest)
remain satisfied.

Note: the real underlying issue is the adapter-version skew on
medihealth (deployed vendor < lockfile). This change makes gds-mcp
robust across adapter versions regardless, but medihealth should also be
redeployed so vendor/wordpress/mcp-adapter actually matches v0.5.0.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
oxyc added a commit that referenced this pull request Jul 31, 2026
…recation (#31)

mcp-adapter 0.5.0 resolves resource meta through get_mcp_meta(), which
prefers meta.mcp.{key} and logs a deprecation notice when it falls back to
the top-level key. #29/#30 moved uri/mimeType into meta.mcp but left
annotations at the top level, so every WP-CLI run logged four notices:

  Ability meta key "annotations" is deprecated. Use "mcp.annotations"
  instead. | Context: {"ability":"gds/block-types-list", ...}

Mirror annotations into meta.mcp for the four resource abilities. The
top-level copy stays: RegisterAbilityAsMcpTool still reads only
$ability_meta['annotations'] in 0.5.0, and adapters < 0.5.0 read top-level
for resources too.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant