| @@ -52,8 +52,15 @@ | ||
| 52 | 52 | |
| 53 | 53 | /** Path segment of the pretty per-site endpoint. */ |
| 54 | 54 | public const SITE_ENDPOINT_PATH = 'xspeed/mcp'; |
| 55 | 55 | |
| 56 | + /** | |
| 57 | + * Fires after a NEW token replaces the stored one (Rotate, or a Connect | |
| 58 | + * after Disconnect). Mcp_Hub listens and sends the token to the Hub, | |
| 59 | + * which holds a copy and would otherwise go on presenting the old one. | |
| 60 | + */ | |
| 61 | + public const TOKEN_CHANGED_ACTION = 'xspeed_mcp_token_changed'; | |
| 62 | + | |
| 56 | 63 | /** Default scopes granted on connect. */ |
| 57 | 64 | private const DEFAULT_SCOPES = array( 'read', 'write' ); |
| 58 | 65 | |
| 59 | 66 | /** |
| @@ -219,8 +226,16 @@ | ||
| 219 | 226 | return array(); |
| 220 | 227 | } |
| 221 | 228 | $out = array(); |
| 222 | 229 | foreach ( Mcp_Tools::catalog() as $name => $spec ) { |
| 230 | + // A hidden tool is a private broker stage. This summary is the | |
| 231 | + // dashboard's answer to "what can an agent do here", so listing one | |
| 232 | + // would advertise it in the one place a user reads — the second | |
| 233 | + // enumerator of the same catalog, and the one tools/list's own | |
| 234 | + // filter does not cover. | |
| 235 | + if ( ! empty( $spec['hidden'] ) ) { | |
| 236 | + continue; | |
| 237 | + } | |
| 223 | 238 | $out[] = array( |
| 224 | 239 | 'name' => (string) $name, |
| 225 | 240 | 'description' => isset( $spec['description'] ) ? (string) $spec['description'] : '', |
| 226 | 241 | 'write' => ! empty( $spec['write'] ), |
| @@ -397,8 +412,13 @@ | ||
| 397 | 412 | ), |
| 398 | 413 | false |
| 399 | 414 | ); |
| 400 | 415 | |
| 416 | + if ( ! $existing ) { | |
| 417 | + /** This action is documented in Mcp_Pairing::TOKEN_CHANGED_ACTION. */ | |
| 418 | + do_action( self::TOKEN_CHANGED_ACTION, $token ); | |
| 419 | + } | |
| 420 | + | |
| 401 | 421 | return self::public_status(); |
| 402 | 422 | } |
| 403 | 423 | |
| 404 | 424 | /** |
| @@ -428,8 +448,11 @@ | ||
| 428 | 448 | 'scopes' => $scopes, |
| 429 | 449 | ), |
| 430 | 450 | false |
| 431 | 451 | ); |
| 452 | + | |
| 453 | + /** This action is documented in Mcp_Pairing::TOKEN_CHANGED_ACTION. */ | |
| 454 | + do_action( self::TOKEN_CHANGED_ACTION, $token ); | |
| 432 | 455 | |
| 433 | 456 | return self::public_status(); |
| 434 | 457 | } |
| 435 | 458 | |