1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
|
"use client"
import { $fetch } from "@lib/api"
import { authClient } from "@lib/auth"
import { useAuth } from "@lib/auth-context"
import { generateId } from "@lib/generate-id"
import { useForm } from "@tanstack/react-form"
import { useMutation, useQuery } from "@tanstack/react-query"
import { Button } from "@ui/components/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@ui/components/dialog"
import { Input } from "@ui/components/input"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@ui/components/select"
import { CopyableCell } from "@ui/copyable-cell"
import { CheckIcon, CopyIcon, ExternalLink, Loader2 } from "lucide-react"
import Image from "next/image"
import { useEffect, useState } from "react"
import { toast } from "sonner"
import { z } from "zod/v4"
import { analytics } from "@/lib/analytics"
import { cn } from "@lib/utils"
import type { Project } from "@repo/lib/types"
import { motion, AnimatePresence } from "motion/react"
const clients = {
cursor: "Cursor",
claude: "Claude Desktop",
vscode: "VSCode",
cline: "Cline",
"gemini-cli": "Gemini CLI",
"claude-code": "Claude Code",
"mcp-url": "MCP URL",
"roo-cline": "Roo Cline",
witsy: "Witsy",
enconvo: "Enconvo",
} as const
const mcpMigrationSchema = z.object({
url: z
.string()
.min(1, "MCP Link is required")
.regex(
/^https:\/\/mcp\.supermemory\.ai\/[^/]+\/sse$/,
"Link must be in format: https://mcp.supermemory.ai/userId/sse",
),
})
interface ConnectAIModalProps {
children: React.ReactNode
open?: boolean
onOpenChange?: (open: boolean) => void
openInitialClient?: "mcp-url" | null
openInitialTab?: "oneClick" | "manual" | null
}
interface ManualMCPHelpLinkProps {
onClick: () => void
}
function ManualMCPHelpLink({ onClick }: ManualMCPHelpLinkProps) {
const [isHovered, setIsHovered] = useState(false)
return (
<button
className="text-xs text-muted-foreground hover:text-foreground hover:underline opacity-70 hover:opacity-100 transition-all relative overflow-hidden"
onClick={onClick}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
type="button"
>
<AnimatePresence mode="wait">
{!isHovered ? (
<motion.span
key="default"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.2 }}
className="inline-block"
>
Having trouble to connect?
</motion.span>
) : (
<motion.span
key="hover"
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.2 }}
className="inline-block underline cursor-pointer"
>
Try Manual MCP config
</motion.span>
)}
</AnimatePresence>
</button>
)
}
export function ConnectAIModal({
children,
open,
onOpenChange,
openInitialClient,
openInitialTab,
}: ConnectAIModalProps) {
const { org } = useAuth()
const [selectedClient, setSelectedClient] = useState<
keyof typeof clients | null
>(openInitialClient || null)
const [internalIsOpen, setInternalIsOpen] = useState(false)
const isOpen = open !== undefined ? open : internalIsOpen
const setIsOpen = onOpenChange || setInternalIsOpen
const [isMigrateDialogOpen, setIsMigrateDialogOpen] = useState(false)
const [selectedProject, setSelectedProject] = useState<string | null>("none")
const [cursorInstallTab, setCursorInstallTab] = useState<
"oneClick" | "manual"
>("oneClick")
const [mcpUrlTab, setMcpUrlTab] = useState<"oneClick" | "manual">(
openInitialTab || "oneClick",
)
const [manualApiKey, setManualApiKey] = useState<string | null>(null)
const [isCopied, setIsCopied] = useState(false)
const [projectId, setProjectId] = useState("default")
useEffect(() => {
if (typeof window !== "undefined") {
const storedProjectId =
localStorage.getItem("selectedProject") ?? "default"
setProjectId(storedProjectId)
}
}, [])
useEffect(() => {
analytics.mcpViewOpened()
}, [])
const { data: projects = [], isLoading: isLoadingProjects } = useQuery({
queryKey: ["projects"],
queryFn: async () => {
const response = await $fetch("@get/projects")
if (response.error) {
throw new Error(response.error?.message || "Failed to load projects")
}
return response.data?.projects || []
},
staleTime: 30 * 1000,
})
const mcpMigrationForm = useForm({
defaultValues: { url: "" },
onSubmit: async ({ value, formApi }) => {
const userId = extractUserIdFromMCPUrl(value.url)
if (userId) {
migrateMCPMutation.mutate({ userId, projectId })
formApi.reset()
}
},
validators: {
onChange: mcpMigrationSchema,
},
})
const extractUserIdFromMCPUrl = (url: string): string | null => {
const regex = /^https:\/\/mcp\.supermemory\.ai\/([^/]+)\/sse$/
const match = url.trim().match(regex)
return match?.[1] || null
}
const migrateMCPMutation = useMutation({
mutationFn: async ({
userId,
projectId,
}: {
userId: string
projectId: string
}) => {
const response = await $fetch("@post/documents/migrate-mcp", {
body: { userId, projectId },
})
if (response.error) {
throw new Error(
response.error?.message || "Failed to migrate documents",
)
}
return response.data
},
onSuccess: (data) => {
toast.success("Migration completed!", {
description: `Successfully migrated ${data?.migratedCount} documents`,
})
setIsMigrateDialogOpen(false)
},
onError: (error) => {
toast.error("Migration failed", {
description: error instanceof Error ? error.message : "Unknown error",
})
},
})
const createMcpApiKeyMutation = useMutation({
mutationFn: async () => {
if (!org?.id) {
throw new Error("Organization ID is required")
}
const res = await authClient.apiKey.create({
metadata: {
organizationId: org?.id,
type: "mcp-manual",
},
name: `mcp-manual-${generateId().slice(0, 8)}`,
prefix: `sm_${org?.id}_`,
})
return res.key
},
onSuccess: (apiKey) => {
setManualApiKey(apiKey)
toast.success("API key created successfully!")
},
onError: (error) => {
toast.error("Failed to create API key", {
description: error instanceof Error ? error.message : "Unknown error",
})
},
})
// biome-ignore lint/correctness/useExhaustiveDependencies(createMcpApiKeyMutation.mutate): we need to mutate the mutation
useEffect(() => {
if (openInitialClient) {
setSelectedClient(openInitialClient as keyof typeof clients)
if (openInitialTab) {
setMcpUrlTab(openInitialTab)
if (org?.id) {
createMcpApiKeyMutation.mutate()
}
}
}
}, [openInitialClient, openInitialTab, org?.id])
function generateInstallCommand() {
if (!selectedClient) return ""
let command = `npx -y install-mcp@latest https://mcp.supermemory.ai/mcp --client ${selectedClient} --oauth=yes`
if (selectedProject && selectedProject !== "none") {
// Remove the "sm_project_" prefix from the containerTag
const projectIdForCommand = selectedProject.replace(/^sm_project_/, "")
command += ` --project ${projectIdForCommand}`
}
return command
}
function getCursorDeeplink() {
return "cursor://anysphere.cursor-deeplink/mcp/install?name=supermemory&config=eyJ1cmwiOiJodHRwczovL2FwaS5zdXBlcm1lbW9yeS5haS9tY3AifQ%3D%3D"
}
const copyToClipboard = () => {
const command = generateInstallCommand()
navigator.clipboard.writeText(command)
analytics.mcpInstallCmdCopied()
toast.success("Copied to clipboard!")
}
return (
<Dialog onOpenChange={setIsOpen} open={isOpen}>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent className="sm:max-w-4xl">
<DialogHeader>
<DialogTitle>Connect supermemory to Your AI</DialogTitle>
<DialogDescription>
Enable your AI assistant to create, search, and access your memories
directly using the Model Context Protocol (MCP).
</DialogDescription>
</DialogHeader>
<div className="space-y-6">
{/* Step 1: Client Selection */}
<div className="space-y-4">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full flex items-center justify-center text-sm font-semibold bg-accent text-accent-foreground">
1
</div>
<h3 className="text-sm font-medium">Select Your AI Client</h3>
</div>
<div className="space-x-2 space-y-2">
{Object.entries(clients)
.slice(0, 7)
.map(([key, clientName]) => (
<button
className={`pr-3 pl-1 rounded-full border cursor-pointer transition-all ${
selectedClient === key
? "border-primary bg-primary/10"
: "border-border hover:border-border/60 hover:bg-muted/50"
}`}
key={key}
onClick={() =>
setSelectedClient(key as keyof typeof clients)
}
type="button"
>
<div className="flex items-center gap-1">
<div className="w-8 h-8 flex items-center justify-center">
<Image
alt={clientName}
className="rounded object-contain"
height={20}
onError={(e) => {
const target = e.target as HTMLImageElement
target.style.display = "none"
const parent = target.parentElement
if (
parent &&
!parent.querySelector(".fallback-text")
) {
const fallback = document.createElement("span")
fallback.className =
"fallback-text text-sm font-bold text-muted-foreground"
fallback.textContent = clientName
.substring(0, 2)
.toUpperCase()
parent.appendChild(fallback)
}
}}
src={
key === "mcp-url"
? "/mcp-icon.svg"
: `/mcp-supported-tools/${key === "claude-code" ? "claude" : key}.png`
}
width={20}
/>
</div>
<span className="text-sm font-medium text-foreground/80">
{clientName}
</span>
</div>
</button>
))}
</div>
</div>
{/* Step 2: One-click Install for Cursor, Project Selection for others, or MCP URL */}
{selectedClient && (
<div className="space-y-4">
<div className="flex justify-between">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-accent text-accent-foreground flex items-center justify-center text-sm font-semibold">
2
</div>
<h3 className="text-sm font-medium">
{selectedClient === "cursor"
? "Install Supermemory MCP"
: selectedClient === "mcp-url"
? "MCP Server Configuration"
: "Select Target Project (Optional)"}
</h3>
</div>
<div className="flex items-center gap-3">
{selectedClient && selectedClient !== "mcp-url" && (
<ManualMCPHelpLink
onClick={() => {
setSelectedClient("mcp-url")
setMcpUrlTab("manual")
if (
!manualApiKey &&
!createMcpApiKeyMutation.isPending
) {
createMcpApiKeyMutation.mutate()
}
}}
/>
)}
<div
className={cn(
"flex-col gap-2 hidden",
(selectedClient === "cursor" ||
selectedClient === "mcp-url") &&
"flex",
)}
>
{/* Tabs */}
<div className="flex justify-end">
<div className="flex bg-muted/50 rounded-full p-1 border border-border">
<button
className={`px-3 py-1.5 text-xs font-medium rounded-full transition-all ${
(
selectedClient === "cursor"
? cursorInstallTab
: mcpUrlTab
) === "oneClick"
? "bg-background text-foreground border border-border shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
onClick={() =>
selectedClient === "cursor"
? setCursorInstallTab("oneClick")
: setMcpUrlTab("oneClick")
}
type="button"
>
{selectedClient === "mcp-url"
? "Quick Setup"
: "One Click Install"}
</button>
<button
className={`px-3 py-1.5 text-xs font-medium rounded-full transition-all ${
(
selectedClient === "cursor"
? cursorInstallTab
: mcpUrlTab
) === "manual"
? "bg-background text-foreground border border-border shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
onClick={() => {
if (selectedClient === "cursor") {
setCursorInstallTab("manual")
} else {
setMcpUrlTab("manual")
if (
!manualApiKey &&
!createMcpApiKeyMutation.isPending
) {
createMcpApiKeyMutation.mutate()
}
}
}}
type="button"
>
Manual Config
</button>
</div>
</div>
</div>
</div>
</div>
{selectedClient === "cursor" ? (
<div className="space-y-4">
{/* Tab Content */}
{cursorInstallTab === "oneClick" ? (
<div className="space-y-4">
<div className="flex flex-col items-center gap-4 p-6 border border-green-500/20 rounded-lg bg-green-500/5">
<div className="text-center">
<p className="text-sm text-foreground/80 mb-2">
Click the button below to automatically install and
configure Supermemory in Cursor
</p>
</div>
<a
href={getCursorDeeplink()}
onClick={() => {
analytics.mcpInstallCmdCopied()
toast.success("Opening Cursor installer...")
}}
>
<img
alt="Add Supermemory MCP server to Cursor"
className="hover:opacity-80 transition-opacity cursor-pointer"
height="40"
src="https://cursor.com/deeplink/mcp-install-dark.svg"
/>
</a>
</div>
</div>
) : (
<div className="space-y-4">
<p className="text-sm text-muted-foreground">
Choose a project and follow the installation steps below
</p>
<div className="max-w-md">
<Select
disabled={isLoadingProjects}
onValueChange={setSelectedProject}
value={selectedProject || "none"}
>
<SelectTrigger className="w-full">
<SelectValue placeholder="Select project" />
</SelectTrigger>
<SelectContent>
<SelectItem value="none">
Auto-select project
</SelectItem>
<SelectItem value="sm_project_default">
Default Project
</SelectItem>
{projects
.filter(
(p: Project) =>
p.containerTag !== "sm_project_default",
)
.map((project: Project) => (
<SelectItem
key={project.id}
value={project.containerTag}
>
{project.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
)}
</div>
) : selectedClient === "mcp-url" ? (
<div className="space-y-4">
{mcpUrlTab === "oneClick" ? (
<div className="space-y-2">
<p className="text-sm text-muted-foreground">
Use this URL to quickly configure supermemory in your AI
assistant
</p>
<div className="relative">
<Input
className="font-mono text-xs w-full pr-10"
readOnly
value="https://mcp.supermemory.ai/mcp"
/>
<Button
className="absolute top-[-1px] right-0 cursor-pointer"
onClick={() => {
navigator.clipboard.writeText(
"https://mcp.supermemory.ai/mcp",
)
analytics.mcpInstallCmdCopied()
toast.success("Copied to clipboard!")
}}
variant="ghost"
>
<CopyIcon className="size-4" />
</Button>
</div>
</div>
) : (
<div className="space-y-3">
<p className="text-sm text-muted-foreground">
Add this configuration to your MCP settings file with
authentication
</p>
{createMcpApiKeyMutation.isPending ? (
<div className="flex items-center justify-center p-8">
<Loader2 className="h-6 w-6 animate-spin text-primary" />
</div>
) : (
<>
<div className="relative">
<pre className="bg-muted border border-border rounded-lg p-4 pr-12 text-xs overflow-x-auto max-w-full">
<code className="font-mono block whitespace-pre-wrap break-all">
{`{
"supermemory-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.supermemory.ai/mcp"],
"env": {},
"headers": {
"Authorization": "Bearer ${manualApiKey || "your-api-key-here"}"
}
}
}`}
</code>
</pre>
<Button
className="absolute top-2 right-2 cursor-pointer h-8 w-8 p-0 bg-muted/80 hover:bg-muted"
onClick={() => {
const config = `{
"supermemory-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.supermemory.ai/mcp"],
"env": {},
"headers": {
"Authorization": "Bearer ${manualApiKey || "your-api-key-here"}"
}
}
}`
navigator.clipboard.writeText(config)
analytics.mcpInstallCmdCopied()
toast.success("Copied to clipboard!")
setIsCopied(true)
setTimeout(() => setIsCopied(false), 2000)
}}
variant="ghost"
size="icon"
>
{isCopied ? (
<CheckIcon className="size-3.5 text-green-600" />
) : (
<CopyIcon className="size-3.5" />
)}
</Button>
</div>
<p className="text-xs text-muted-foreground">
The API key is included as a Bearer token in the
Authorization header
</p>
</>
)}
</div>
)}
</div>
) : (
<div className="max-w-md">
<Select
disabled={isLoadingProjects}
onValueChange={setSelectedProject}
value={selectedProject || "none"}
>
<SelectTrigger className="w-full">
<SelectValue placeholder="Select project" />
</SelectTrigger>
<SelectContent>
<SelectItem value="none">Auto-select project</SelectItem>
<SelectItem value="sm_project_default">
Default Project
</SelectItem>
{projects
.filter(
(p: Project) =>
p.containerTag !== "sm_project_default",
)
.map((project: Project) => (
<SelectItem
key={project.id}
value={project.containerTag}
>
{project.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
)}
</div>
)}
{/* Step 3: Command Line - Show for manual installation or non-cursor clients */}
{selectedClient &&
selectedClient !== "mcp-url" &&
(selectedClient !== "cursor" || cursorInstallTab === "manual") && (
<div className="space-y-4">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-accent text-accent-foreground flex items-center justify-center text-sm font-semibold">
3
</div>
<h3 className="text-sm font-medium">
{selectedClient === "cursor" &&
cursorInstallTab === "manual"
? "Manual Installation Command"
: "Installation Command"}
</h3>
</div>
<div className="relative">
<Input
className="font-mono text-xs w-full pr-10"
readOnly
value={generateInstallCommand()}
/>
<Button
className="absolute top-[-1px] right-0 cursor-pointer"
onClick={copyToClipboard}
variant="ghost"
>
<CopyIcon className="size-4" />
</Button>
</div>
<p className="text-xs text-muted-foreground">
{selectedClient === "cursor" && cursorInstallTab === "manual"
? "Copy and run this command in your terminal for manual installation (or switch to the one-click option above)"
: "Copy and run this command in your terminal to install the MCP server"}
</p>
</div>
)}
{/* Blurred Command Placeholder - Only show when no client selected */}
{!selectedClient && (
<div className="space-y-4">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-accent text-accent-foreground flex items-center justify-center text-sm font-semibold">
3
</div>
<h3 className="text-sm font-medium">Installation Command</h3>
</div>
<div className="relative">
<div className="w-full h-10 bg-muted border border-border rounded-md flex items-center px-3">
<div className="w-full h-4 bg-muted-foreground/20 rounded animate-pulse blur-sm" />
</div>
</div>
<p className="text-xs text-muted-foreground/50">
Select a client above to see the installation command
</p>
</div>
)}
<div className="gap-2 hidden">
<div>
<label
className="text-sm font-medium text-foreground/80 block mb-2"
htmlFor="mcp-server-url-desktop"
>
MCP Server URL
</label>
<p className="text-xs text-muted-foreground mt-2">
Use this URL to configure supermemory in your AI assistant
</p>
</div>
<div className="p-1 bg-muted rounded-lg border border-border items-center flex px-2">
<CopyableCell
className="font-mono text-xs text-primary"
value="https://mcp.supermemory.ai/mcp"
/>
</div>
</div>
{/* TODO: Show when connection successful or not */}
{/*<div>
<h3 className="text-sm font-medium mb-3">What You Can Do</h3>
<ul className="space-y-2 text-sm text-muted-foreground">
<li>• Ask your AI to save important information as memories</li>
<li>• Search through your saved memories during conversations</li>
<li>• Get contextual information from your knowledge base</li>
</ul>
</div>*/}
<div className="flex justify-between items-center pt-4">
<div className="flex items-center gap-4">
<Button
onClick={() =>
window.open(
"https://docs.supermemory.ai/supermemory-mcp/introduction",
"_blank",
)
}
variant="outline"
>
<ExternalLink className="w-2 h-2 mr-2" />
Learn More
</Button>
<Button
onClick={() => setIsMigrateDialogOpen(true)}
variant="outline"
>
Migrate from v1
</Button>
</div>
<Button onClick={() => setIsOpen(false)}>Done</Button>
</div>
</div>
</DialogContent>
{/* Migration Dialog */}
{isMigrateDialogOpen && (
<Dialog
onOpenChange={setIsMigrateDialogOpen}
open={isMigrateDialogOpen}
>
<DialogContent className="sm:max-w-2xl bg-popover border-border text-popover-foreground">
<div>
<DialogHeader>
<DialogTitle>Migrate from MCP v1</DialogTitle>
<DialogDescription className="text-muted-foreground">
Migrate your MCP documents from the legacy system.
</DialogDescription>
</DialogHeader>
<form
onSubmit={(e) => {
e.preventDefault()
e.stopPropagation()
mcpMigrationForm.handleSubmit()
}}
>
<div className="grid gap-4">
<div className="flex flex-col gap-2">
<label className="text-sm font-medium" htmlFor="mcpUrl">
MCP Link
</label>
<mcpMigrationForm.Field name="url">
{({ state, handleChange, handleBlur }) => (
<>
<Input
className="bg-input border-border text-foreground"
id="mcpUrl"
onBlur={handleBlur}
onChange={(e) => handleChange(e.target.value)}
placeholder="https://mcp.supermemory.ai/your-user-id/sse"
value={state.value}
/>
{state.meta.errors.length > 0 && (
<p className="text-sm text-destructive mt-1">
{state.meta.errors.join(", ")}
</p>
)}
</>
)}
</mcpMigrationForm.Field>
<p className="text-xs text-muted-foreground">
Enter your old MCP Link in the format: <br />
<span className="font-mono">
https://mcp.supermemory.ai/userId/sse
</span>
</p>
</div>
</div>
<div className="flex justify-end gap-3 mt-4">
<Button
onClick={() => {
setIsMigrateDialogOpen(false)
mcpMigrationForm.reset()
}}
type="button"
variant="outline"
>
Cancel
</Button>
<Button
disabled={
migrateMCPMutation.isPending ||
!mcpMigrationForm.state.canSubmit
}
type="submit"
>
{migrateMCPMutation.isPending ? (
<>
<Loader2 className="h-4 w-4 animate-spin mr-2" />
Migrating...
</>
) : (
"Migrate"
)}
</Button>
</div>
</form>
</div>
</DialogContent>
</Dialog>
)}
</Dialog>
)
}
|