← All changes
|
vendor/wordpress/mcp-adapter/includes/Abilities/McpAbilityHelperTrait.php
+4
-9
4.3.0-beta1
→
trunk
View file →
| @@ -20,10 +20,10 @@ | ||
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Checks if ability is publicly exposed via MCP. |
| 23 | 23 | * |
| 24 | - * Validates against the ability's mcp.public metadata flag. | |
| 25 | - * Only abilities with mcp.public=true are accessible via default MCP server. | |
| 24 | + * Validates against the ability's resolved mcp.public metadata flag. | |
| 25 | + * Only abilities with effective MCP public exposure are accessible via default MCP server. | |
| 26 | 26 | * |
| 27 | 27 | * @param string $ability_name The ability name to check. |
| 28 | 28 | * |
| 29 | 29 | * @return bool|\WP_Error True if publicly exposed, WP_Error if not. |
| @@ -34,12 +34,9 @@ | ||
| 34 | 34 | if ( ! $ability ) { |
| 35 | 35 | return new WP_Error( 'ability_not_found', "Ability '{$ability_name}' not found" ); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $meta = $ability->get_meta(); | |
| 39 | - $is_public_mcp = $meta['mcp']['public'] ?? false; | |
| 40 | - | |
| 41 | - if ( ! $is_public_mcp ) { | |
| 38 | + if ( ! McpAbilityExposure::is_public( $ability ) ) { | |
| 42 | 39 | return new WP_Error( |
| 43 | 40 | 'ability_not_public_mcp', |
| 44 | 41 | sprintf( 'Ability "%s" is not exposed via MCP (mcp.public!=true)', $ability_name ) |
| 45 | 42 | ); |
| @@ -58,11 +55,9 @@ | ||
| 58 | 55 | * |
| 59 | 56 | * @return bool True if publicly exposed, false otherwise. |
| 60 | 57 | */ |
| 61 | 58 | protected static function is_ability_mcp_public( \WP_Ability $ability ): bool { |
| 62 | - $meta = $ability->get_meta(); | |
| 63 | - | |
| 64 | - return (bool) ( $meta['mcp']['public'] ?? false ); | |
| 59 | + return McpAbilityExposure::is_public( $ability ); | |
| 65 | 60 | } |
| 66 | 61 | |
| 67 | 62 | /** |
| 68 | 63 | * Gets the MCP type of an ability. |