-`). * - `oauth-redirect-sandbox.googleusercontent.com` / `oauth-redirect-test.googleusercontent.com` * — sandbox and test variants of the same proxy; Google always * registers all three simultaneously. * Gemini CLI uses loopback callbacks — the RFC 8252 §7.3 matcher in * AuthorizationController handles those directly, no host list needed. */ private const DCR_HOSTS = array( 'gemini.google.com', 'vertexaisearch.cloud.google.com', 'antigravity.google', 'oauth-redirect.googleusercontent.com', 'oauth-redirect-sandbox.googleusercontent.com', 'oauth-redirect-test.googleusercontent.com', ); /** * Singleton instance. * * @var self|null * @since 0.6.0 */ protected static $instance = null; /** * Private constructor — enforce singleton and A1 (no hook wiring here). * * @since 0.6.0 */ private function __construct() {} /** * Get the shared singleton instance. * * @return self * @since 0.6.0 */ public static function instance(): self { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Connector slug — the registry uses this key to look up the profile. * * @return string * @since 0.6.0 */ public function get_slug(): string { return 'gemini'; } /** * User-facing connector name. * * @return string * @since 0.6.0 */ public function get_name(): string { return __( 'Gemini', 'acrossai-mcp-manager' ); } /** * @return int */ public function get_priority(): int { return 30; } /** * URL to the bundled icon shipped with this plugin. * * @return string * @since 0.6.0 */ public function get_icon_url(): string { return plugins_url( 'assets/gemini-icon.svg', \ACROSSAI_MCP_MANAGER_PLUGIN_FILE ); } /** * Allowed redirect URIs — Gemini Enterprise + Antigravity static * callbacks. Web app + CLI go through DCR and don't need pre-approval. * * @return string[] * @since 0.6.0 */ public function get_redirect_uri_whitelist(): array { return self::REDIRECT_URIS; } /** * Step-by-step HTML instructions for the operator setting up Gemini * manually (Enterprise / Antigravity flow). Web-app users don't hit * this path — their client registers itself via DCR when they paste * the MCP URL. * * @param array $server Server row from the base plugin's * MCP Servers table. * @param string $client_id The freshly-generated OAuth client_id. * @param string $client_secret The freshly-generated OAuth client_secret. * @return string HTML block, escaped where necessary. * @since 0.6.0 */ public function get_setup_instructions( array $server, string $client_id, string $client_secret ): string { unset( $server, $client_secret ); // Server-context + secret are shown separately in render_tab_section. ob_start(); ?>
  1. ' . esc_html( $client_id ) . '' ); ?>
__( 'Gemini wants to connect to your site', 'acrossai-mcp-manager' ), 'subtitle' => __( 'This will let Gemini access the MCP tools this server exposes, acting as your WordPress user.', 'acrossai-mcp-manager' ), 'permissions_bullets' => array( __( 'Read and act on the tools exposed on this MCP server', 'acrossai-mcp-manager' ), __( 'Access the WordPress data your user account has permission to see', 'acrossai-mcp-manager' ), __( 'Connect until you revoke access from the Connectors/Integrations tab', 'acrossai-mcp-manager' ), ), ); } /** * Claim DCR-registered clients whose redirect URIs point at a * Google-owned Gemini host. Prefer host-based matching over substring * name matching — the name field is arbitrary. Falls back to a * whole-word `gemini` regex match on client_name for edge cases where * a client registers with a proxy callback but declares its identity * via the client_name field. * * @param string $client_name DCR-submitted client_name. * @param array $redirect_uris DCR-submitted redirect_uris. * @return bool * @since 0.6.0 */ public function matches_dcr_client( string $client_name, array $redirect_uris ): bool { if ( self::dcr_matches_by_host( $redirect_uris, self::DCR_HOSTS ) ) { return true; } return (bool) preg_match( '/\bgemini\b/i', $client_name ); } /** * Gemini-branded "How to connect" panel. Covers the surfaces that talk * to a remote MCP server today — Gemini on the web, the Gemini CLI * (@google/gemini-cli), and Gemini Enterprise / Antigravity — then links * to acrossai.co/gemini-connectors/ for the fuller walkthrough. DCR * handles registration for web + CLI; Enterprise / Antigravity use the * pre-generated OAuth credentials from the Generate panel above. * * @param string $mcp_url MCP endpoint URL. * @return array Spec for the shared panel renderer. * @since 0.6.0 */ protected function get_setup_spec( string $mcp_url ): array { $spec = array( 'name' => 'Gemini', 'lead' => __( 'Gemini reaches your site over OAuth. You approve once on a WordPress consent screen — no token to copy.', 'acrossai-mcp-manager' ), 'open_label' => __( 'Open Gemini settings', 'acrossai-mcp-manager' ), 'open_url' => 'https://gemini.google.com/personalization-settings', 'steps' => array( array( 'text' => __( 'In Gemini, open Settings > Personal Intelligence', 'acrossai-mcp-manager' ) ), array( 'text' => __( 'Open Connected Apps, then the Connectors tab', 'acrossai-mcp-manager' ) ), array( 'text' => __( 'Click + Custom to open "Connect to an MCP server"', 'acrossai-mcp-manager' ) ), array( 'text' => __( 'Paste the MCP endpoint URL into MCP Server URL', 'acrossai-mcp-manager' ), 'url' => true, 'note' => __( 'The dialog asks for nothing else — there is no name field to fill in.', 'acrossai-mcp-manager' ), ), array( 'text' => __( 'Leave Additional settings empty', 'acrossai-mcp-manager' ), 'note' => __( 'Client ID and Client secret stay blank — Gemini registers itself. Fill them only if it asks, using Generate credentials below.', 'acrossai-mcp-manager' ), ), array( 'text' => __( 'Click Next, then approve the consent screen', 'acrossai-mcp-manager' ), 'open' => true, ), ), 'plan' => __( 'Works on a consumer Google account. Gemini Enterprise provisions MCP servers through its own admin console instead — see the full guide.', 'acrossai-mcp-manager' ), 'other' => array( 'label' => __( 'Gemini CLI (terminal)', 'acrossai-mcp-manager' ), 'desc' => __( 'Run this, then finish the browser sign-in the CLI prints.', 'acrossai-mcp-manager' ), 'cmd' => sprintf( 'gemini mcp add --transport http acrossai %s', $mcp_url ), ), 'docs_url' => 'https://acrossai.co/docs/connect-gemini-troubleshooting/', ); return $spec; } /** * Render the Gemini "How to connect" panel below the standard card. * * @param array $server Server row. * @return void */ }