diff --git a/apps/web/components/views/mcp/installation-dialog-content.tsx b/apps/web/components/views/mcp/installation-dialog-content.tsx index d2813f75..4c04c6ac 100644 --- a/apps/web/components/views/mcp/installation-dialog-content.tsx +++ b/apps/web/components/views/mcp/installation-dialog-content.tsx @@ -13,10 +13,13 @@ import { SelectTrigger, SelectValue, } from "@ui/components/select"; +import { Label } from "@ui/components/label"; import { CopyIcon } from "lucide-react"; import { useState } from "react"; import { toast } from "sonner"; import { analytics } from "@/lib/analytics"; +import { $fetch } from "@repo/lib/api"; +import { useQuery } from "@tanstack/react-query"; const clients = { cursor: "Cursor", @@ -30,44 +33,124 @@ const clients = { "claude-code": "Claude Code", } as const; +interface Project { + id: string; + name: string; + containerTag: string; + createdAt: string; + updatedAt: string; + isExperimental?: boolean; +} + export function InstallationDialogContent() { const [client, setClient] = useState("cursor"); + const [selectedProject, setSelectedProject] = useState("none"); + + // Fetch projects + 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, + }); + + // Generate installation command based on selected project + function generateInstallCommand() { + let command = `npx -y install-mcp@latest https://api.supermemory.ai/mcp --client ${client} --oauth=yes`; + + if (selectedProject && selectedProject !== "none") { + // Remove the "sm_project_" prefix from the containerTag + const projectId = selectedProject.replace(/^sm_project_/, ''); + command += ` --project ${projectId}`; + } + + return command; + } + return ( Install the supermemory MCP Server - Select the app you want to install supermemory MCP to, then run the + Select the app and project you want to install supermemory MCP to, then run the following command: -
- - setClient(value as keyof typeof clients)} + value={client} + > + + + + + {Object.entries(clients).map(([key, value]) => ( + + {value} + + ))} + + +
+ +
+ + + + Default Project + + {projects + .filter((p: Project) => p.containerTag !== "sm_project_default") + .map((project: Project) => ( + + {project.name} + + ))} + + +
+ +
+ + +
+