Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Changed the connect sheet to choice cards with per-client instructions
Damian Legawiece97697f66a83
diff --git a/packages/dashboard/src/components/spree/mcp-connect-sheet.tsx b/packages/dashboard/src/components/spree/mcp-connect-sheet.tsxindex f448bc3d3a..16469fbb72 100644--- a/packages/dashboard/src/components/spree/mcp-connect-sheet.tsx+++ b/packages/dashboard/src/components/spree/mcp-connect-sheet.tsx@@ -6,20 +6,24 @@ import {Button,CopyToClipboardButton,Field,- FieldError,+ FieldLabel,Input,- Label,Sheet,SheetContent,SheetDescription,SheetFooter,SheetHeader,SheetTitle,+ Tabs,+ TabsContent,+ TabsList,+ TabsTrigger,} from '@spree/dashboard-ui'import { useMutation, useQueryClient } from '@tanstack/react-query'import { useState } from 'react'import { useTranslation } from 'react-i18next'import { useOauthApplications } from '../../hooks/use-oauth'+import { ChoiceCardPicker } from './choice-card-picker'type McpConnectSheetProps = {open: boolean@@ -27,35 +31,42 @@ type McpConnectSheetProps = {}/**- * The clients whose callback we can fill in for the merchant.+ * A client we can fill the callback in for.*- * A redirect URI is where authorization codes are delivered, so a wrong one- * sends them to whoever controls that host. For the clients we know, the- * merchant should never have to find or type it — they pick a name. Anything- * else is "Something else", where a developer supplies the callback from the- * client's own documentation.+ * The redirect URI is where authorization codes are delivered, so a wrong+ * one sends them to whoever controls that host. For the clients we know the+ * merchant should never have to find or type it — they pick a name.+ *+ * `surfaces` are the ways that client connects. A desktop or web app takes+ * the address pasted into its settings; a terminal client takes a command.*/const KNOWN_CLIENTS = [- { id: 'claude', name: 'Claude', redirectUri: 'https://claude.ai/api/mcp/auth_callback' },{- id: 'chatgpt',+ value: 'claude',+ name: 'Claude',+ redirectUri: 'https://claude.ai/api/mcp/auth_callback',+ surfaces: [+ { id: 'app', command: null },+ { id: 'cli', command: (url: string) => `claude mcp add --transport http spree ${url}` },+ ],+ },+ {+ value: 'chatgpt',name: 'ChatGPT',redirectUri: 'https://chatgpt.com/connector_platform_oauth_redirect',+ surfaces: [+ { id: 'app', command: null },+ { id: 'cli', command: (url: string) => `codex mcp add spree --url ${url}` },+ ],},] as const-/**- * Connecting an agent, in two steps: choose which one, then take away the- * address and the id it asks for.- *- * The client is registered when the merchant picks it, rather than seeded- * into every store — a store that never connects anything carries no- * registrations, and the sheet shows one id (the one just created) instead- * of every id at once.- */+const OTHER = 'other'+export function McpConnectSheet({ open, onOpenChange }: McpConnectSheetProps) {const { t } = useTranslation()const queryClient = useQueryClient()+ const [choice, setChoice] = useState<string>(KNOWN_CLIENTS[0].value)const [created, setCreated] = useState<OauthApplication | null>(null)const [customName, setCustomName] = useState('')const [customUri, setCustomUri] = useState('')@@ -67,6 +78,7 @@ export function McpConnectSheet({ open, onOpenChange }: McpConnectSheetProps) {// actually answers on.const apiOrigin = import.meta.env.VITE_SPREE_API_URL || window.location.originconst endpoint = `${apiOrigin}/api/v3/admin/mcp`+ const selected = KNOWN_CLIENTS.find((client) => client.value === choice)const register = useMutation({mutationFn: (params: { name: string; redirect_uri: string }) =>@@ -77,8 +89,10 @@ export function McpConnectSheet({ open, onOpenChange }: McpConnectSheetProps) {},})- async function choose(name: string, redirectUri: string) {+ async function connect() {setFailure(null)+ const name = selected ? selected.name : customName.trim()+ const redirectUri = selected ? selected.redirectUri : customUri.trim()// Picking the same client twice is reconnecting it, not registering a// second one — two rows with two ids would leave a merchant guessing@@ -99,15 +113,20 @@ export function McpConnectSheet({ open, onOpenChange }: McpConnectSheetProps) {function reset(next: boolean) {onOpenChange(next)if (next) return+ setChoice(KNOWN_CLIENTS[0].value)setCreated(null)setCustomName('')setCustomUri('')setFailure(null)}+ const canConnect = selected+ ? !register.isPending+ : !register.isPending && Boolean(customName.trim() && customUri.trim())+return (<Sheet open={open} onOpenChange={reset}>- <SheetContent className="flex w-full flex-col overflow-y-auto sm:max-w-xl">+ <SheetContent className="flex w-full flex-col sm:max-w-xl"><SheetHeader><SheetTitle>{created@@ -119,7 +138,7 @@ export function McpConnectSheet({ open, onOpenChange }: McpConnectSheetProps) {</SheetDescription></SheetHeader>- <div className="flex flex-1 flex-col gap-6 px-4">+ <div className="flex flex-1 flex-col gap-6 overflow-y-auto px-4">{failure ? (<Alert variant="destructive"><AlertDescription>{failure}</AlertDescription>@@ -127,108 +146,180 @@ export function McpConnectSheet({ open, onOpenChange }: McpConnectSheetProps) {) : null}{created ? (- <>- <div className="flex flex-col gap-2">- <p className="font-medium text-sm">{t('admin.mcp_connect.endpoint_label')}</p>- <div className="flex items-center gap-2 rounded-md bg-muted px-3 py-2">- <code className="flex-1 truncate font-mono text-xs">{endpoint}</code>- <CopyToClipboardButton- value={endpoint}- aria-label={t('admin.mcp_connect.copy_endpoint')}- />- </div>- </div>-- <div className="flex flex-col gap-2">- <p className="font-medium text-sm">{t('admin.mcp_connect.client_id_label')}</p>- <p className="text-muted-foreground text-xs">- {t('admin.mcp_connect.client_id_help')}- </p>- <div className="flex items-center gap-2 rounded-md bg-muted px-3 py-2">- <code className="flex-1 truncate font-mono text-xs">{created.client_id}</code>- <CopyToClipboardButton- value={created.client_id}- aria-label={t('admin.mcp_connect.copy_client_id')}- />- </div>- </div>-- <ol className="flex list-decimal flex-col gap-2 pl-5 text-sm">- <li>{t('admin.mcp_connect.step_paste')}</li>- <li>{t('admin.mcp_connect.step_sign_in')}</li>- <li>{t('admin.mcp_connect.step_approve')}</li>- </ol>-- <Alert variant="info">- <AlertDescription>{t('admin.mcp_connect.bounded_note')}</AlertDescription>- </Alert>- </>+ <ConnectInstructions+ client={KNOWN_CLIENTS.find((candidate) => candidate.name === created.name)}+ clientId={created.client_id}+ endpoint={endpoint}+ />) : (<>- <div className="flex flex-col gap-2">- {KNOWN_CLIENTS.map((client) => (- <Button- key={client.id}- variant="outline"- className="justify-start"- disabled={register.isPending}- onClick={() => choose(client.name, client.redirectUri)}- >- {client.name}- </Button>- ))}- </div>-- {/* Anything we do not know a callback for. A developer reads it- from the client's documentation; a merchant picks a name- above and never sees this. */}- <div className="flex flex-col gap-3 border-t pt-4">- <p className="font-medium text-sm">{t('admin.mcp_connect.other_title')}</p>- <Field>- <Label htmlFor="mcp-other-name">- {t('admin.fields.oauth_application.name.label')}- </Label>- <Input- id="mcp-other-name"- value={customName}- onChange={(event) => setCustomName(event.target.value)}- placeholder={t('admin.fields.oauth_application.name.placeholder')}- />- </Field>- <Field>- <Label htmlFor="mcp-other-uri">- {t('admin.fields.oauth_application.redirect_uri.label')}- </Label>- <Input- id="mcp-other-uri"- value={customUri}- onChange={(event) => setCustomUri(event.target.value)}- placeholder="https://example.com/oauth/callback"- />- <FieldError />- <p className="text-muted-foreground text-xs">- {t('admin.fields.oauth_application.redirect_uri.help')}- </p>- </Field>- <Button- variant="outline"- className="self-start"- disabled={register.isPending || !customName.trim() || !customUri.trim()}- onClick={() => choose(customName.trim(), customUri.trim())}- >- {t('admin.mcp_connect.other_cta')}- </Button>- </div>+ <ChoiceCardPicker+ options={[+ ...KNOWN_CLIENTS.map((client) => ({+ value: client.value as string,+ label: client.name,+ description: t(`admin.mcp_connect.clients.${client.value}`),+ })),+ {+ value: OTHER,+ label: t('admin.mcp_connect.other_title'),+ description: t('admin.mcp_connect.other_help'),+ },+ ]}+ value={choice}+ onChange={setChoice}+ />++ {/* Only once "Something else" is the choice: a merchant picking+ a known client never sees a callback field. */}+ {selected ? null : (+ <div className="flex flex-col gap-4 rounded-lg border p-4">+ <Field>+ <FieldLabel htmlFor="mcp-other-name">+ {t('admin.fields.oauth_application.name.label')}+ </FieldLabel>+ <Input+ id="mcp-other-name"+ value={customName}+ onChange={(event) => setCustomName(event.target.value)}+ placeholder={t('admin.fields.oauth_application.name.placeholder')}+ />+ </Field>+ <Field>+ <FieldLabel htmlFor="mcp-other-uri">+ {t('admin.fields.oauth_application.redirect_uri.label')}+ </FieldLabel>+ <Input+ id="mcp-other-uri"+ value={customUri}+ onChange={(event) => setCustomUri(event.target.value)}+ placeholder="https://example.com/oauth/callback"+ />+ <p className="text-muted-foreground text-xs">+ {t('admin.fields.oauth_application.redirect_uri.help')}+ </p>+ </Field>+ </div>+ )}</>)}</div><SheetFooter>- <Button variant="outline" onClick={() => reset(false)}>- {created ? t('admin.common.done') : t('admin.common.cancel')}- </Button>+ {created ? (+ <Button onClick={() => reset(false)}>{t('admin.common.done')}</Button>+ ) : (+ <>+ <Button disabled={!canConnect} onClick={connect}>+ {t('admin.mcp_connect.continue')}+ </Button>+ <Button variant="outline" onClick={() => reset(false)}>+ {t('admin.common.cancel')}+ </Button>+ </>+ )}</SheetFooter></SheetContent></Sheet>)}++/**+ * What to do with the registration, per surface.+ *+ * A desktop or web client takes the address pasted into its settings; a+ * terminal client takes a command. Tabbed rather than listed, because a+ * merchant on claude.ai should not have to read past a shell command.+ */+function ConnectInstructions({+ client,+ clientId,+ endpoint,+}: {+ client?: (typeof KNOWN_CLIENTS)[number]+ clientId: string+ endpoint: string+}) {+ const { t } = useTranslation()+ const cli = client?.surfaces.find((surface) => surface.command)++ const address = (+ <div className="flex flex-col gap-4">+ <CopyableValue+ label={t('admin.mcp_connect.endpoint_label')}+ value={endpoint}+ copyLabel={t('admin.mcp_connect.copy_endpoint')}+ />+ <CopyableValue+ label={t('admin.mcp_connect.client_id_label')}+ help={t('admin.mcp_connect.client_id_help')}+ value={clientId}+ copyLabel={t('admin.mcp_connect.copy_client_id')}+ />+ <ol className="flex list-decimal flex-col gap-2 pl-5 text-sm">+ <li>{t('admin.mcp_connect.step_paste')}</li>+ <li>{t('admin.mcp_connect.step_sign_in')}</li>+ <li>{t('admin.mcp_connect.step_approve')}</li>+ </ol>+ </div>+ )++ return (+ <div className="flex flex-col gap-4">+ {cli?.command ? (+ <Tabs defaultValue="app">+ <TabsList>+ <TabsTrigger value="app">+ {t(`admin.mcp_connect.surfaces.${client?.value}.app`)}+ </TabsTrigger>+ <TabsTrigger value="cli">+ {t(`admin.mcp_connect.surfaces.${client?.value}.cli`)}+ </TabsTrigger>+ </TabsList>+ <TabsContent value="app" className="pt-4">+ {address}+ </TabsContent>+ <TabsContent value="cli" className="flex flex-col gap-4 pt-4">+ <CopyableValue+ label={t('admin.mcp_connect.run_label')}+ value={cli.command(endpoint)}+ copyLabel={t('admin.mcp_connect.copy_command')}+ />+ <p className="text-muted-foreground text-sm">+ {t('admin.mcp_connect.cli_then_sign_in')}+ </p>+ </TabsContent>+ </Tabs>+ ) : (+ address+ )}++ <Alert variant="info">+ <AlertDescription>{t('admin.mcp_connect.bounded_note')}</AlertDescription>+ </Alert>+ </div>+ )+}++function CopyableValue({+ label,+ help,+ value,+ copyLabel,+}: {+ label: string+ help?: string+ value: string+ copyLabel: string+}) {+ return (+ <div className="flex flex-col gap-2">+ <p className="font-medium text-sm">{label}</p>+ {help ? <p className="text-muted-foreground text-xs">{help}</p> : null}+ <div className="flex items-center gap-2 rounded-md bg-muted px-3 py-2">+ <code className="flex-1 truncate font-mono text-xs">{value}</code>+ <CopyToClipboardButton value={value} aria-label={copyLabel} />+ </div>+ </div>+ )+}diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 19ed64ee68..c726d85abc 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -6421,8 +6421,26 @@"copy_endpoint": "نسخ العنوان","copy_client_id": "نسخ معرّف العميل","other_title": "شيء آخر",- "other_cta": "تسجيل ومتابعة",- "bounded_note": "لن يحصل الوكيل أبدًا على أكثر مما لديك، وفقط على ما توافق عليه."+ "bounded_note": "لن يحصل الوكيل أبدًا على أكثر مما لديك، وفقط على ما توافق عليه.",+ "clients": {+ "claude": "claude.ai وClaude Desktop وClaude Code",+ "chatgpt": "ChatGPT وCodex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai وتطبيق سطح المكتب",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "أي عميل آخر يدعم MCP",+ "continue": "متابعة",+ "run_label": "نفّذ هذا الأمر",+ "copy_command": "نسخ الأمر",+ "cli_then_sign_in": "سيفتح المتصفح لتسجيل الدخول والموافقة على ما يمكن للوكيل فعله."}}}diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 2c87364d78..9e30ec61de 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -6381,8 +6381,26 @@"copy_endpoint": "Adresse kopieren","copy_client_id": "Client-ID kopieren","other_title": "Etwas anderes",- "other_cta": "Registrieren und fortfahren",- "bounded_note": "Ein Agent erhält nie mehr als Sie selbst haben, und nur das, was Sie genehmigen."+ "bounded_note": "Ein Agent erhält nie mehr als Sie selbst haben, und nur das, was Sie genehmigen.",+ "clients": {+ "claude": "claude.ai, Claude Desktop und Claude Code",+ "chatgpt": "ChatGPT und Codex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai & Desktop",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "Jeder andere Client, der MCP spricht",+ "continue": "Weiter",+ "run_label": "Diesen Befehl ausführen",+ "copy_command": "Befehl kopieren",+ "cli_then_sign_in": "Es öffnet den Browser zum Anmelden und Genehmigen dessen, was der Agent tun darf."}}}diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex dfc9616741..67e1159a08 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -6381,8 +6381,26 @@"copy_endpoint": "Copy address","copy_client_id": "Copy client ID","other_title": "Something else",- "other_cta": "Register and continue",- "bounded_note": "An agent never gets more than you have, and only what you approve."+ "bounded_note": "An agent never gets more than you have, and only what you approve.",+ "clients": {+ "claude": "claude.ai, Claude Desktop and Claude Code",+ "chatgpt": "ChatGPT and Codex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai & Desktop",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "Any other client that speaks MCP",+ "continue": "Continue",+ "run_label": "Run this",+ "copy_command": "Copy command",+ "cli_then_sign_in": "It will open your browser to sign in and approve what the agent may do."}}}diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.jsonindex 43b909df49..b3b550038a 100644--- a/packages/dashboard/src/locales/es.json+++ b/packages/dashboard/src/locales/es.json@@ -6381,8 +6381,26 @@"copy_endpoint": "Copiar dirección","copy_client_id": "Copiar ID de cliente","other_title": "Otra cosa",- "other_cta": "Registrar y continuar",- "bounded_note": "Un agente nunca obtiene más de lo que usted tiene, y solo lo que usted aprueba."+ "bounded_note": "Un agente nunca obtiene más de lo que usted tiene, y solo lo que usted aprueba.",+ "clients": {+ "claude": "claude.ai, Claude Desktop y Claude Code",+ "chatgpt": "ChatGPT y Codex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai y Desktop",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "Cualquier otro cliente que hable MCP",+ "continue": "Continuar",+ "run_label": "Ejecute esto",+ "copy_command": "Copiar comando",+ "cli_then_sign_in": "Se abrirá el navegador para iniciar sesión y aprobar lo que el agente puede hacer."}}}diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 81c4a857eb..2de5e3542e 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -6381,8 +6381,26 @@"copy_endpoint": "Copier l'adresse","copy_client_id": "Copier l'identifiant client","other_title": "Autre chose",- "other_cta": "Enregistrer et continuer",- "bounded_note": "Un agent n'obtient jamais plus que vous, et uniquement ce que vous approuvez."+ "bounded_note": "Un agent n'obtient jamais plus que vous, et uniquement ce que vous approuvez.",+ "clients": {+ "claude": "claude.ai, Claude Desktop et Claude Code",+ "chatgpt": "ChatGPT et Codex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai et Desktop",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "Tout autre client parlant MCP",+ "continue": "Continuer",+ "run_label": "Exécutez ceci",+ "copy_command": "Copier la commande",+ "cli_then_sign_in": "Votre navigateur s'ouvrira pour vous connecter et approuver ce que l'agent peut faire."}}}diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex e8b101fd4a..5c5feca880 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -6449,8 +6449,26 @@"copy_endpoint": "Kopiuj adres","copy_client_id": "Kopiuj identyfikator klienta","other_title": "Coś innego",- "other_cta": "Zarejestruj i kontynuuj",- "bounded_note": "Agent nigdy nie dostanie więcej niż masz Ty i tylko to, co zatwierdzisz."+ "bounded_note": "Agent nigdy nie dostanie więcej niż masz Ty i tylko to, co zatwierdzisz.",+ "clients": {+ "claude": "claude.ai, Claude Desktop i Claude Code",+ "chatgpt": "ChatGPT i Codex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai i Desktop",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "Dowolny inny klient obsługujący MCP",+ "continue": "Dalej",+ "run_label": "Uruchom to",+ "copy_command": "Kopiuj polecenie",+ "cli_then_sign_in": "Otworzy przeglądarkę, abyś mógł się zalogować i zatwierdzić uprawnienia agenta."}}}diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex ff5dfd4e79..a472acacfe 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -6368,8 +6368,26 @@"copy_endpoint": "复制地址","copy_client_id": "复制客户端 ID","other_title": "其他",- "other_cta": "注册并继续",- "bounded_note": "代理获得的权限绝不会超过您自己的,且仅限于您批准的部分。"+ "bounded_note": "代理获得的权限绝不会超过您自己的,且仅限于您批准的部分。",+ "clients": {+ "claude": "claude.ai、Claude Desktop 和 Claude Code",+ "chatgpt": "ChatGPT 和 Codex"+ },+ "surfaces": {+ "claude": {+ "app": "Claude.ai 与桌面版",+ "cli": "Claude Code"+ },+ "chatgpt": {+ "app": "ChatGPT",+ "cli": "Codex"+ }+ },+ "other_help": "任何其他支持 MCP 的客户端",+ "continue": "继续",+ "run_label": "运行此命令",+ "copy_command": "复制命令",+ "cli_then_sign_in": "它会打开浏览器,让您登录并批准代理可以执行的操作。"}}}