get_surecookie_ability_names(); // Newer adapter builds ship HttpTransport; older ones only RestTransport. $transport_class = class_exists( '\\WP\\MCP\\Transport\\HttpTransport' ) ? '\\WP\\MCP\\Transport\\HttpTransport' : '\\WP\\MCP\\Transport\\Http\\RestTransport'; try { $adapter->create_server( 'surecookie', 'surecookie/v1', 'mcp', __( 'SureCookie MCP Server', 'surecookie' ), __( 'SureCookie MCP Server for cookie consent settings, consent logs, cookie management, and site scanning workflows.', 'surecookie' ), SURECOOKIE_VERSION, [ $transport_class ], '\\WP\\MCP\\Infrastructure\\ErrorHandling\\ErrorLogMcpErrorHandler', '\\WP\\MCP\\Infrastructure\\Observability\\NullMcpObservabilityHandler', $tools, [], [], // Transport access requires the same capability that gates // ability execution; older adapters ignore this 13th argument. static function (): bool { return current_user_can( SURECOOKIE_CAPABILITY ); } ); } catch ( \Throwable $e ) { // A transport/adapter version mismatch must not fatal the REST API. Logger::get_instance()->log( 'SureCookie MCP server registration failed: ' . $e->getMessage(), 'warning' ); } } /** * Collect the names of all registered surecookie/* abilities. * * @return array * @since 1.1.0 */ private function get_surecookie_ability_names(): array { $abilities = function_exists( 'wp_get_abilities' ) ? wp_get_abilities() : []; $tools = []; foreach ( $abilities as $ability ) { if ( ! is_object( $ability ) || ! method_exists( $ability, 'get_name' ) ) { continue; } $name = $ability->get_name(); if ( is_string( $name ) && strpos( $name, 'surecookie/' ) === 0 ) { $tools[] = $name; } } return $tools; } }