| @@ -24,8 +24,10 @@ | ||
| 24 | 24 | declare(strict_types=1); |
| 25 | 25 | |
| 26 | 26 | namespace ThinkRank\Mcp; |
| 27 | 27 | |
| 28 | +use ThinkRank\Abilities\Abilities_Registrar; | |
| 29 | + | |
| 28 | 30 | if ( ! defined( 'ABSPATH' ) ) { |
| 29 | 31 | exit; // Exit if accessed directly. |
| 30 | 32 | } |
| 31 | 33 | |
| @@ -68,11 +70,15 @@ | ||
| 68 | 70 | |
| 69 | 71 | /** |
| 70 | 72 | * Whether the active MCP credential is limited to read-only tools. |
| 71 | 73 | * |
| 74 | + * Public because the initialize instructions tell the assistant which | |
| 75 | + * scope this session has, so it can read that as a granted limitation | |
| 76 | + * rather than retrying a tool that will keep refusing (#491). | |
| 77 | + * | |
| 72 | 78 | * @return bool |
| 73 | 79 | */ |
| 74 | - private static function is_read_only(): bool { | |
| 80 | + public static function is_read_only(): bool { | |
| 75 | 81 | if ( null !== self::$read_only_override ) { |
| 76 | 82 | return self::$read_only_override; |
| 77 | 83 | } |
| 78 | 84 | return Mcp_Pairing::is_read_only(); |
| @@ -210,8 +216,17 @@ | ||
| 210 | 216 | private static function abilities(): array { |
| 211 | 217 | if ( ! function_exists( 'wp_get_abilities' ) ) { |
| 212 | 218 | return []; |
| 213 | 219 | } |
| 220 | + | |
| 221 | + // Our abilities reach the registry through `wp_abilities_api_init`, | |
| 222 | + // which fires once from whichever Abilities API copy owns the global | |
| 223 | + // functions. When a foreign copy owns them our callback can be missed | |
| 224 | + // entirely, leaving this filter with nothing to match and the client | |
| 225 | + // with a connected-but-empty tool list (#241). This replays the | |
| 226 | + // registration once, and is a no-op on a healthy request. | |
| 227 | + Abilities_Registrar::ensure_registered(); | |
| 228 | + | |
| 214 | 229 | $out = []; |
| 215 | 230 | foreach ( wp_get_abilities() as $ability ) { |
| 216 | 231 | if ( ! is_object( $ability ) || ! method_exists( $ability, 'get_name' ) ) { |
| 217 | 232 | continue; |