| @@ -19,8 +19,9 @@ | ||
| 19 | 19 | use WPMedia\MCP\OAuth\Auth\CimdResolver; |
| 20 | 20 | use WPMedia\MCP\OAuth\Auth\ClaudeClientVerifier; |
| 21 | 21 | use WPMedia\MCP\OAuth\Auth\ConsentEndpoint; |
| 22 | 22 | use WPMedia\MCP\OAuth\Auth\Discovery\Endpoints as DiscoveryEndpoints; |
| 23 | +use WPMedia\MCP\OAuth\Auth\Discovery\HealthCheck as DiscoveryHealthCheck; | |
| 23 | 24 | use WPMedia\MCP\OAuth\Auth\RevokeEndpoint; |
| 24 | 25 | use WPMedia\MCP\OAuth\Auth\Rewrite; |
| 25 | 26 | use WPMedia\MCP\OAuth\Auth\Router; |
| 26 | 27 | use WPMedia\MCP\OAuth\Auth\SecretManager; |
| @@ -115,8 +116,9 @@ | ||
| 115 | 116 | $this->context = new Context(); |
| 116 | 117 | |
| 117 | 118 | $this->register_auth_router(); |
| 118 | 119 | $this->register_discovery( $this->context ); |
| 120 | + $this->register_discovery_health_check( $this->context ); | |
| 119 | 121 | $this->register_transport( $this->context ); |
| 120 | 122 | |
| 121 | 123 | add_action( 'init', [ SecretManager::class, 'ensure_secret' ], 5 ); |
| 122 | 124 | add_action( 'init', [ $this, 'maybe_flush_rewrite_rules' ], 20 ); |
| @@ -167,8 +169,20 @@ | ||
| 167 | 169 | add_action( 'template_redirect', [ $discovery, 'handle_request' ] ); |
| 168 | 170 | } |
| 169 | 171 | |
| 170 | 172 | /** |
| 173 | + * Wire the Site Health self-check for the .well-known discovery documents. | |
| 174 | + * | |
| 175 | + * @param Context $context OAuth server context. | |
| 176 | + * @return void | |
| 177 | + */ | |
| 178 | + private function register_discovery_health_check( Context $context ): void { | |
| 179 | + $health_check = new DiscoveryHealthCheck( $context ); | |
| 180 | + | |
| 181 | + add_filter( 'site_status_tests', [ $health_check, 'add_test' ] ); | |
| 182 | + } | |
| 183 | + | |
| 184 | + /** | |
| 171 | 185 | * Wire MCP server + abilities registration. |
| 172 | 186 | * |
| 173 | 187 | * @param Context $context OAuth server context. |
| 174 | 188 | * @return void |
| @@ -173,9 +187,9 @@ | ||
| 173 | 187 | * @param Context $context OAuth server context. |
| 174 | 188 | * @return void |
| 175 | 189 | */ |
| 176 | 190 | private function register_transport( Context $context ): void { |
| 177 | - $registrar = new ServerRegistrar( new Server(), $context ); | |
| 191 | + $registrar = new ServerRegistrar( new Server( $context ), $context ); | |
| 178 | 192 | |
| 179 | 193 | add_action( 'wp_abilities_api_categories_init', [ $registrar, 'ensure_default_category' ] ); |
| 180 | 194 | add_action( 'wp_abilities_api_init', [ $registrar, 'ensure_shared_abilities_registered' ] ); |
| 181 | 195 | add_action( 'mcp_adapter_init', [ $registrar, 'register_server' ] ); |