$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.1.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();
?>
-
' . esc_html( $client_id ) . ''
);
?>
__( 'Claude wants to connect to your site', 'acrossai-mcp-manager' ),
'subtitle' => __( 'This will let Claude 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' ),
),
);
}
/**
* Anthropic-owned hostnames used for DCR attribution. Includes both the
* current `claude.ai` origin and the forward-compat `claude.com` target
* Anthropic has announced. Kept in sync with `get_redirect_uri_whitelist()`.
*/
private const DCR_HOSTS = array( 'claude.ai', 'claude.com', 'anthropic.com' );
/**
* Claim DCR-registered clients whose redirect URIs point at an
* Anthropic-owned host. Host matching is preferred over the previous
* substring-on-client-name check because the client_name is
* self-declared free text — a redirect URI at `claude.ai` is a much
* stronger identity signal.
*
* As a fallback, we still substring-match the client_name for the edge
* case where a DCR registration ships without an explicit host we
* recognize (e.g., a wrapper client using a proxy callback). Kept
* intentionally narrow — no `anthropic` fallback since that string
* could show up in a third-party OpenAI-competitor's client_name.
*
* @param string $client_name DCR-submitted client_name.
* @param array $redirect_uris DCR-submitted redirect_uris.
* @return bool
*/
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;
}
// Name-only fallback — trimmed regex ensures 'claude' appears as a
// standalone token, not embedded in another brand's name.
return (bool) preg_match( '/\bclaude\b/i', $client_name );
}
/**
* Claude's undocumented-but-stable deep link into the Add custom
* connector modal, with the name and server URL already filled in.
*
* Anthropic's own documentation describes the manual path only, so this
* is a convenience that must never become load-bearing: every step it
* saves is still written out below it, and a changed or withdrawn link
* costs the operator one extra copy-paste rather than the connection.
*
* Deliberately scoped to the personal surface. `/customize/connectors`
* is a per-account page; Team and Enterprise Owners add connectors in
* Organization settings, which no link can target, so the panel points
* them at the section below instead of implying one button covers all.
*
* @param string $mcp_url This server's MCP endpoint.
*/
public function get_one_click_connect_url( string $mcp_url ): string {
return 'https://claude.ai/customize/connectors?modal=add-custom-connector'
. '&connectorName=' . rawurlencode( $this->get_connector_name() )
. '&connectorUrl=' . rawurlencode( $mcp_url );
}
/**
* F024 (2026-07-11): Claude-branded MCP URL setup instructions.
* Replaces the AbstractConnectorProfile default with step-by-step
* guides covering every Claude surface — the web app at claude.ai, the
* Claude for Desktop native app, and the Claude Code CLI — plus a link
* to acrossai.co/claude-connectors/ for anything not covered here.
*
* Rendered as an always-visible panel inside the connector card via
* {@see self::render_card_body()}, and also returned to the JS layer
* after "Generate credentials" so the same steps appear in the result
* area. Both surfaces pass this HTML through wp_kses_post at the render
* boundary — inline HTML is safe; scripts are stripped.
*
* @param string $mcp_url MCP endpoint URL.
* @return array Spec for the shared panel renderer.
*/
protected function get_setup_spec( string $mcp_url ): array {
// $mcp_url is not always an absolute URL. DiscoveryConnectorAdapter
// builds this panel once per pageload, before any server is chosen, and
// passes the sentinel `__ACROSSAI_MCP_URL__` for Quick Connect Step 10
// to substitute client-side. The sentinel has no scheme and no host, so
// asking whether IT is publicly reachable answered "no" on every site —
// which disabled 1-click in the wizard even on public https sites, and
// left the %s below empty. Step 10's substitution is a plain string
// replace, so it could never undo a button rendered disabled.
//
// Both answers are properties of this site's own address rather than of
// the per-server route, so fall back to it whenever what we were handed
// has no host. On the server edit screen, where a real URL does arrive,
// this resolves to exactly the same decision as before.
$probe = '' === (string) wp_parse_url( $mcp_url, PHP_URL_HOST ) ? rest_url( '/' ) : $mcp_url;
$reachable = LocalEnvironment::is_publicly_reachable( $probe );
$host = (string) wp_parse_url( $probe, PHP_URL_HOST );
$spec = array(
'name' => 'Claude',
'lead' => __( 'Claude reaches your site over OAuth. You approve once on a WordPress consent screen — no token to copy.', 'acrossai-mcp-manager' ),
'one_click_url' => $this->get_one_click_connect_url( $mcp_url ),
'one_click_label' => __( 'Connect to Claude (1-click)', 'acrossai-mcp-manager' ),
'one_click_help' => __( 'Opens claude.ai with this server pre-filled. Confirm there to add and connect.', 'acrossai-mcp-manager' ),
'blocked_reason' => $reachable ? '' : sprintf(
/* translators: %s: this site's hostname, e.g. "mysite.local". */
__( 'Claude connects from Anthropic\'s servers, so it needs a public https:// address. %s only resolves on your machine. Expose it with a tunnel (ngrok, Cloudflare Tunnel), or connect once the site is live.', 'acrossai-mcp-manager' ),
$host
),
'open_label' => __( 'Open Claude settings', 'acrossai-mcp-manager' ),
'open_url' => 'https://claude.ai/customize/connectors',
'steps' => array(
array( 'text' => __( 'In claude.ai, go to Settings > Connectors', 'acrossai-mcp-manager' ) ),
array( 'text' => __( 'Click Add custom connector', 'acrossai-mcp-manager' ) ),
array(
'text' => __( 'Give the connector a name', 'acrossai-mcp-manager' ),
'copy' => $this->get_connector_name(),
'note' => __( 'Anything works — the name is only so you recognise this connector in your list. This one matches the site.', 'acrossai-mcp-manager' ),
),
array(
'text' => __( 'Paste the MCP endpoint URL as the server URL', 'acrossai-mcp-manager' ),
'url' => true,
),
array(
'text' => __( 'Click Add, then Connect, and approve the consent screen', 'acrossai-mcp-manager' ),
'open' => true,
),
),
'plan' => __( 'Free, Pro and Max accounts. On Team and Enterprise, only Owners can add connectors.', 'acrossai-mcp-manager' ),
'other' => array(
'label' => __( 'Claude Code (terminal)', 'acrossai-mcp-manager' ),
'desc' => __( 'Run this, then finish the browser sign-in Claude Code prints.', 'acrossai-mcp-manager' ),
'cmd' => sprintf( 'claude mcp add --transport http acrossai %s', $mcp_url ),
),
'docs_url' => 'https://acrossai.co/docs/connect-claude-troubleshooting/',
);
return $spec;
}
/**
* Override the shared card body so the Claude "How to connect" panel
* renders on the tab immediately, without requiring the operator to
* click Generate first. The base implementation only fires the setup
* HTML through JS after a Generate response; that hides the onboarding
* steps behind an action step and confused operators evaluating whether
* to connect at all. Rendering here keeps the URL + Generate row on top
* (single most important action) and appends the guide underneath.
*
* @param array $server Server row.
* @return void
*/
// F021 Phase 9 (2026-07-11): render_tab_section is now inherited from
// AbstractConnectorProfile::render_default_card. The base plugin's shared
// CSS + JS bundle (enqueued via Admin\Main::maybe_enqueue_ai_connectors_app)
// handles all card layout, Generate/Regenerate buttons, and copy behavior.
// This class is now pure metadata: get_slug + get_name + get_icon_url +
// get_redirect_uri_whitelist + get_setup_instructions + get_consent_branding +
// (F024) matches_dcr_client + get_mcp_url_setup_html.
}