Make WordPress Core

Opened 44 hours ago

Last modified 21 hours ago

#66799 assigned enhancement

Abilities API: Add an open world annotation

Reported by: gziolo Owned by: gziolo
Priority: normal Milestone: 7.3
Component: Abilities API Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

​WordPress for the Agentic Web outlines a vision for making WordPress capabilities easy to discover and use from the agents people already bring to their sites. To support that vision, ability authors need a standard way to declare whether an ability can interact with public or open-ended entities or stays within a bounded environment.

MCP defines openWorldHint as an optional boolean. If omitted, it ​defaults to `true`. Clients therefore have no way to distinguish a bounded tool from a potentially open-world tool unless it explicitly declares false.

Core defines readonly, destructive, and idempotent as behavioral annotations, but has no native annotation for this distinction. Adding one lets authors declare the interaction boundary in the ability itself, regardless of how callers access it.

Proposed change

Add open_world as an optional bool|null under meta.annotations in WP_Ability:

  • true: At least one supported execution path can interact with public or open-ended entities, such as searching the public web or sending data to a caller-supplied destination.
  • false: All supported execution paths stay within a bounded environment, such as the connected account's private catalog. A network call alone does not make an ability open-world.
  • null or omitted: The ability does not declare this property. Core should keep it unspecified rather than infer either boolean value.

open_world is independent of readonly. A public web search can be both read-only and open-world. Like the existing annotations, it describes behavior and does not change permissions, execution, or exposure.

Core scope and tests

  • Document open_world alongside the existing annotations and add it to the annotation defaults in WP_Ability with a value of null.
  • Test that registration preserves explicit true and false in ability metadata. Test that omission and explicit null both remain unspecified.
  • Verify that existing abilities without the annotation continue to register and that the annotation does not affect permissions, execution, or exposure.

Change History (9)

This ticket was mentioned in ​PR #16201 on ​WordPress/wordpress-develop by ​@avinashzala01.


43 hours ago
#1

  • Keywords has-patch has-unit-tests added

What

Adds open_world as an optional bool|null annotation under meta.annotations, next to readonly, destructive and idempotent.

  • true: at least one supported execution path can interact with public or open-ended entities.
  • false: all supported execution paths stay within a bounded environment.
  • null or omitted: not declared. Core does not infer a value.

Like the other annotations it is a hint. It does not change permissions, execution or exposure.

Changes

  • WP_Ability::$default_annotations gets open_world => null.
  • The annotations docblocks in abilities-api.php, WP_Abilities_Registry and WP_Ability document the new key.
  • WP_REST_Abilities_V1_List_Controller declares open_world in the response schema and in the annotations collection filter, as it already does for the other three.

Core's own abilities are not changed. They can opt in separately.

Testing

  • New test_open_world_annotation covers explicit true, false and null, and omission.
  • Existing tests that hard-code the default annotations array now include the new key.
  • npm run test:php -- --group abilities-api passes on single site (940 tests) and multisite (945).
  • PHPCS reports no errors on the changed files.

#2 follow-up: @avinashzala01
43 hours ago

@gziolo

Beyond the ticket's scope list
The REST list controller declares the annotation keys explicitly in two places: the response schema and the annotations collection filter. Both use additionalProperties: true, so open_world would be returned either way, but it would have no description in the schema and would not be a documented filter. I added it there for consistency with readonly, destructive and idempotent. Happy to drop that part if it should be a separate change.

Open questions

  1. Naming: open_world follows the snake_case of readonly, but MCP calls it openWorldHint. Is the mapping meant to live in an MCP adapter?
  2. Core abilities: should core's own abilities set open_world => false explicitly, as they do for destructive and idempotent? I left them untouched. That can be a follow-up if wanted.

Not covered
No dedicated REST test for the new schema entry. It is covered only by the existing abilities tests.

Use of AI tools

  • AI assistance: Yes
  • Tool: Claude Code
  • Used for: Reviewing the existing annotation code, writing the patch and tests, and drafting this comment. I reviewed the changes and checked the test results myself.

#3 @gziolo
42 hours ago

  • Owner set to gziolo
  • Status new → assigned

#4 in reply to: ↑ 2 @nikskyverge
34 hours ago

Replying to avinashzala01:

  1. Core abilities: should core's own abilities set open_world => false explicitly, as they do for destructive and idempotent? I left them untouched. That can be a follow-up if wanted.

IMO this will need to be considered per-ability and will hinge on how we define "external" sources. I don't think we need answers for this before adding the annotation to the API itself (i.e. not a blocker for this ticket), but I'll share a bit here to seed the conversation going forward.

Guidance

The MCP project has guidance on deciding when to flag hints and how to interpret them in this blog post: ​https://blog.modelcontextprotocol.io/posts/2026-03-16-tool-annotations/

A key excerpt there re: the open world hint is:

openWorldHint is different. It’s about where the tool reaches and what its output might carry back, which matters after the call as much as before. It’s also the hint most sensitive to deployment context. “External” might mean anything outside a corporate network or anything beyond the local machine, depending on where the server runs. The safest posture is to treat anything a tool considers external as a potential source of untrusted content.

And then later for "example client behavior", the suggestion for openWorldHint is:

Scrutinize output for untrusted content; flag a trust-boundary cross.

WP Context

The handling and enforcement will be the responsibility of consuming clients, but I think the application for our context within WP is to use this flag to mark any process that might touch off-site or user-generated content. When deciding on flags for core abilities, this would include querying or fetching things like comment content, usernames, and possibly media uploads, but might also include fetching certain sets of posts.

Some edge cases that come to mind in trying to define "external" in our context:

  1. Content generated by authenticated non-admins (editor, author, etc.) which might be fetched in an admin context
  2. Content or settings that come from plugins that might interact with external APIs
  3. Results from core/get-environment-info which is external to the WP context
  4. Media queries depending on upload permissions

Any of these might touch data that is considered "external" to the site or it's admins, as opposed to abilities like core/term-create that would be more clearly scoped within WP internals. Taking the MCP implementation as one example, this external data might then be passed to an agent with admin permissions where it carries risk of privilege escalation via prompt injection. This kind of risk also applies in the case of workflows where external data returned from one ability might be passed as input to subsequent abilities.

Last edited 34 hours ago by nikskyverge (previous) (diff)

#5 @avinashzala01
26 hours ago

Replying to nikskyverge:

Thanks for the guidance and the MCP write-up. That settles my question about core abilities: I agree they should be considered one by one, and I'll leave them out of this patch so the annotation can land first.

The first CI run on PR ​16201 failed because the generated REST schema fixture (tests/qunit/fixtures/wp-api-generated.js) was missing the new open_world entry. I pushed a fix, which adds only that block, and CI is now green.

Remaining question: open_world vs. MCP's openWorldHint. If the mapping is meant to live in an MCP adapter, the snake_case name looks right as it matches readonly, destructive and idempotent. Please say if you would prefer something else.

@gziolo: since you now own the ticket, do you want to keep the PR as it is, or would you rather change the scope? For example, I can drop the REST schema entries into a separate change, or add the per-ability follow-up for core abilities once the definition of "external" is settled.

#6 @gziolo
23 hours ago

@avinashzala01, the mapping from open_world to MCP’s openWorldHint is tracked in ​https://github.com/WordPress/mcp-adapter/issues/464, so we can keep the snake_case name in Core.

I agree with @nikskyverge that adding the annotation to the API and annotating individual core abilities should be separate steps. Keeping the REST schema and filter entries in this patch also makes sense for consistency with the existing annotations.

MCP defaults to true when openWorldHint is omitted. Core should preserve an unspecified value, and we should explicitly set meta.annotations.open_world to false only when all supported execution paths meet the bounded-environment criteria we establish for WordPress. We can continue discussing those criteria without blocking this API addition.

To add to the considerations raised, embeds in post content are another case worth examining, particularly when an ability resolves or returns third-party content. We should also distinguish WordPress’s existing content sanitization from protection against prompt injection: content can be safe to render and still contain instructions intended to influence an agent. Neither sanitization nor an open_world: false annotation should be treated as a guarantee that returned content is trusted.

​@gziolo commented on ​PR #16201:


23 hours ago
#7

Thanks for working on this, @avinash-addweb! The change looks good and is almost ready. I have some feedback to share.

In the places where the new annotation is documented, please add a @since entry. We did the same when meta.public was added, for example @since 7.1.0 Added the public meta argument.

I think we can spend some time trying to iron out the description. The phrase "public or open-ended entities" is hard to follow. The word "public" is also used by the public meta key, which has a different meaning. Would you like to try a different wording? One idea is to say that when the value is true, the ability may interact with systems outside of the site, such as remote HTTP services or email recipients. When the value is false, the ability only interacts with the site itself. Feel free to propose something else. It would be good to use the same wording in all places.

Could you also add a test for the REST API? Query parameters arrive as strings, so it would be good to check that meta[annotations][open_world]=true is treated as a boolean. The existing test_filter_by_annotation test does this for readonly, so you can follow its structure.

#8 @avinashzala01
21 hours ago

Thanks for the review, @gziolo. Pushed ​abc4456g with the changes:

  • Added @since 7.3.0 entries wherever the annotation is documented.
  • Reworded the description using your suggestion (systems outside of the site, such as remote HTTP services or email recipients; false means the ability only interacts with the site itself), with the same wording in the docblocks, the code comment, the REST schema and the generated fixture.
  • Added test_filter_by_open_world_annotation, following test_filter_by_annotation. It passes 'true' and 'false' as strings and checks they are coerced to booleans, and that an ability without the annotation matches neither.


I used 7.3.0 for @since to match the milestone. Let me know if you would prefer a different version.

#9 @gziolo
21 hours ago

Bringing it over here as it wasn't pulled from GitHub: I approved the PR. I plan to leave some time for others to review and share feedback before committing it.

Last edited 21 hours ago by gziolo (previous) (diff)
Note: See TracTickets for help on using tickets.