Automattic\WooCommerce\Internal\MCP
MCPAdapterProvider::should_include_ability_by_default
Check if an ability should be included in the deprecated WooCommerce MCP endpoint.
REST-derived abilities can opt in to the deprecated WooCommerce MCP endpoint. Require explicit metadata so semantic/domain abilities can use WooCommerce namespaces without expanding the deprecated MCP tool list. This intentionally allows abilities from any namespace to opt in to the deprecated endpoint while keeping namespace and transport exposure separate.
Method of the class: MCPAdapterProvider{}
No Hooks.
Returns
true|false. Whether to include the ability by default.
Usage
$result = MCPAdapterProvider::should_include_ability_by_default( $ability_id ): bool;
- $ability_id(string) (required)
- Ability ID.
MCPAdapterProvider::should_include_ability_by_default() MCPAdapterProvider::should include ability by default code WC 10.9.4
private static function should_include_ability_by_default( string $ability_id ): bool {
// Keep the pre-check to avoid triggering _doing_it_wrong() for stale or mocked registry IDs.
if ( function_exists( 'wp_get_ability' ) && function_exists( 'wp_has_ability' ) && wp_has_ability( $ability_id ) ) {
$ability = wp_get_ability( $ability_id );
if ( $ability ) {
// Strict boolean required: truthy values like 1 or "true" are intentionally excluded.
return true === $ability->get_meta_item(
RestAbilityFactory::EXPOSE_IN_DEPRECATED_MCP_META_KEY,
false
);
}
}
return false;
}