YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
feat(connections): add Grok CLI as an MCP client (#4385)
Louis Beaumontbbeaca2f1b75
diff --git a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx b/apps/screenpipe-app-tauri/components/settings/connections-section.tsxindex 0488b1ce1..d60a75d60 100644--- a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx@@ -183,9 +183,11 @@ import {getClaudeConfigPath,getCodexConfigPath,getCursorMcpConfigPath,+ getGrokConfigPath,getInstalledMcpVersion,isCodexMcpInstalled,isCursorMcpInstalled,+ isGrokMcpInstalled,} from "@/lib/hooks/use-hardcoded-tiles";type McpCommand = { command: string; args: string[]; env?: Record<string, string> };@@ -220,6 +222,7 @@ async function detectInstalledConnectionIds(): Promise<Set<string>> {addIf("perplexity", macAppExists("Perplexity")),addIf("krisp", macAppExists("Krisp")),addIf("codex", getCodexConfigPath().then(pathExists)),+ addIf("grok", getGrokConfigPath().then(pathExists)),addIf("claude-code", hasClaudeCode),]);return detected;@@ -289,6 +292,7 @@ async function detectInstalledConnectionIds(): Promise<Set<string>> {...program("Krisp", "Krisp.exe"),])),addIf("codex", getCodexConfigPath().then(pathExists)),+ addIf("grok", getGrokConfigPath().then(pathExists)),addIf("obsidian", getObsidianConfigPath().then(path => !!path && pathExists(path))),addIf("claude-code", hasClaudeCode),]);@@ -374,6 +378,7 @@ async function detectInstalledConnectionIds(): Promise<Set<string>> {...desktop("krisp.desktop", "Krisp.desktop"),])),addIf("codex", getCodexConfigPath().then(pathExists)),+ addIf("grok", getGrokConfigPath().then(pathExists)),addIf("claude-code", hasClaudeCode),]);return detected;@@ -484,6 +489,50 @@ async function uninstallCodexMcp(): Promise<void> {await writeFile(configPath, new TextEncoder().encode(next ? `${next}\n` : ""));}+// Grok CLI stores MCP servers as an array under `mcp.servers[]` in+// ~/.grok/user-settings.json, each entry tagged with `id`/`label`/`enabled`+// (see superagent-ai/grok-cli src/utils/settings.ts McpServerConfig).+function buildGrokMcpServer(config: McpCommand): Record<string, unknown> {+ const server: Record<string, unknown> = {+ id: "screenpipe",+ label: "screenpipe",+ enabled: true,+ transport: "stdio",+ command: config.command,+ args: config.args,+ };+ if (config.env && Object.keys(config.env).length > 0) server.env = config.env;+ return server;+}++function buildGrokMcpJson(config: McpCommand): string {+ return JSON.stringify({ mcp: { servers: [buildGrokMcpServer(config)] } }, null, 2);+}++async function installGrokMcp(): Promise<void> {+ const configPath = await getGrokConfigPath();+ let config: Record<string, unknown> = {};+ try { config = JSON.parse(await readTextFile(configPath)); } catch { /* fresh */ }+ const mcp = (config.mcp && typeof config.mcp === "object" ? config.mcp : {}) as Record<string, unknown>;+ const servers = (Array.isArray(mcp.servers) ? mcp.servers : []) as Record<string, unknown>[];+ const next = servers.filter((s) => s?.id !== "screenpipe");+ next.push(buildGrokMcpServer(await buildMcpConfig()));+ mcp.servers = next;+ config.mcp = mcp;+ await mkdir(await dirname(configPath), { recursive: true });+ await writeFile(configPath, new TextEncoder().encode(JSON.stringify(config, null, 2)));+}++async function uninstallGrokMcp(): Promise<void> {+ const configPath = await getGrokConfigPath();+ let config: Record<string, unknown> = {};+ try { config = JSON.parse(await readTextFile(configPath)); } catch { return; }+ const mcp = (config.mcp && typeof config.mcp === "object" ? config.mcp : null) as Record<string, unknown> | null;+ if (!mcp || !Array.isArray(mcp.servers)) return;+ mcp.servers = (mcp.servers as Record<string, unknown>[]).filter((s) => s?.id !== "screenpipe");+ await writeFile(configPath, new TextEncoder().encode(JSON.stringify(config, null, 2)));+}+// ---------------------------------------------------------------------------// Grid tile icons// ---------------------------------------------------------------------------@@ -533,11 +582,22 @@ function CursorLogo({ className }: { className?: string }) {}+function GrokLogo({ className }: { className?: string }) {+ return (+ <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" className={className}>+ <rect width="512" height="512" rx="115" fill="#000"/>+ <path fill="#fff" d="M318 150h54L216 362h-54z"/>+ <path fill="#fff" d="M300 244h52v118h-52z"/>+ </svg>+ );+}+// Source of truth for integration glyphs; INTEGRATION_ICON_KEYS derives from it.const INTEGRATION_ICONS: Record<string, React.ReactNode> = {claude: <ClaudeLogo />,cursor: <CursorLogo className="w-5 h-5 rounded" />,codex: <img src="/images/codex.svg" alt="Codex" className="w-5 h-5 rounded" />,+ grok: <GrokLogo className="w-5 h-5 rounded" />,"claude-code": <Terminal className="h-5 w-5" />,warp: <img src="/images/warp.png" alt="Warp" className="w-5 h-5 rounded" />,chatgpt: <img src="/images/openai.png" alt="ChatGPT" className="w-5 h-5 rounded" />,@@ -1299,6 +1359,67 @@ function CodexPanel({ onConnected, onDisconnected }: { onConnected?: () => void;);}+function GrokPanel({ onConnected, onDisconnected }: { onConnected?: () => void; onDisconnected?: () => void }) {+ const [state, setState] = useState<"idle" | "installing" | "installed">("idle");+ useEffect(() => { isGrokMcpInstalled().then(ok => { if (ok) setState("installed"); }); }, []);++ const manualConfig = useMemo(() => buildGrokMcpJson({+ command: "npx",+ args: ["-y", "screenpipe-mcp@latest"],+ }), []);++ const handleConnect = async () => {+ try {+ setState("installing");+ await installGrokMcp();+ setState("installed");+ onConnected?.();+ } catch (error) {+ console.error("failed to install grok mcp:", error);+ await message(+ "Failed to write Grok CLI MCP config.\n\nManually add a screenpipe entry to the mcp.servers array in ~/.grok/user-settings.json with command npx and args [\"-y\", \"screenpipe-mcp@latest\"].",+ { title: "Grok CLI MCP Setup", kind: "error" }+ );+ setState("idle");+ }+ };++ const handleDisconnect = async () => {+ try { await uninstallGrokMcp(); } catch (e) { console.warn("grok config remove failed:", e); }+ setState("idle");+ onDisconnected?.();+ };++ return (+ <div className="space-y-3">+ <p className="text-xs text-muted-foreground">Give Grok CLI access to your screen & audio history via MCP.</p>+ <div className="flex flex-wrap gap-2">+ {state === "installed" ? (+ <Button onClick={handleDisconnect} variant="outline" size="sm" className="gap-1.5 h-7 text-xs normal-case font-sans tracking-normal">+ <LogOut className="h-3 w-3" />disconnect+ </Button>+ ) : (+ <Button onClick={handleConnect} disabled={state === "installing"} size="sm" className="gap-1.5 h-7 text-xs normal-case font-sans tracking-normal">+ {state === "installing" ? (<><Loader2 className="h-3 w-3 animate-spin" />connecting...</>) : (<><Download className="h-3 w-3" />connect</>)}+ </Button>+ )}+ <Button variant="outline" onClick={() => openUrl("https://github.com/superagent-ai/grok-cli")} size="sm" className="gap-1.5 h-7 text-xs normal-case font-sans tracking-normal">+ <ExternalLink className="h-3 w-3" />grok cli+ </Button>+ </div>+ {state === "installed" && (+ <p className="text-xs text-muted-foreground">+ <strong>connected!</strong> start a new <code>grok</code> session and ask: "what did I do in the last 5 minutes?"+ </p>+ )}+ <details className="text-xs text-muted-foreground">+ <summary className="cursor-pointer">manual config</summary>+ <pre className="mt-2 bg-muted border border-border rounded-lg p-3 text-xs font-mono text-foreground overflow-x-auto whitespace-pre-wrap">{manualConfig}</pre>+ </details>+ </div>+ );+}+function ClaudeCodePanel() {const [copied, setCopied] = useState(false);const cmd = "claude mcp add screenpipe -- npx -y screenpipe-mcp@latest";@@ -3627,6 +3748,7 @@ export function ConnectionsSection({const [claudeInstalled, setClaudeInstalled] = useState(false);const [cursorInstalled, setCursorInstalled] = useState(false);const [codexInstalled, setCodexInstalled] = useState(false);+ const [grokInstalled, setGrokInstalled] = useState(false);const [chatgptConnected, setChatgptConnected] = useState(false);const [browserUrlDetected, setBrowserUrlDetected] = useState(false);const [browserUrlConnected, setBrowserUrlConnected] = useState(false);@@ -3667,6 +3789,7 @@ export function ConnectionsSection({});isCursorMcpInstalled().then(setCursorInstalled).catch(() => {});isCodexMcpInstalled().then(setCodexInstalled).catch(() => {});+ isGrokMcpInstalled().then(setGrokInstalled).catch(() => {});commands.chatgptOauthStatus().then(res => {setChatgptConnected(res.status === "ok" && res.data.logged_in);}).catch(() => {});@@ -3786,6 +3909,7 @@ export function ConnectionsSection({{ id: "claude", name: "Claude Desktop", icon: "claude", connected: claudeInstalled, detected: detectedConnectionIds.has("claude") },{ id: "cursor", name: "Cursor", icon: "cursor", connected: cursorInstalled, detected: detectedConnectionIds.has("cursor") },{ id: "codex", name: "Codex", icon: "codex", connected: codexInstalled, detected: detectedConnectionIds.has("codex") },+ { id: "grok", name: "Grok CLI", icon: "grok", connected: grokInstalled, detected: detectedConnectionIds.has("grok") },{ id: "claude-code", name: "Claude Code", icon: "claude-code", connected: false, detected: detectedConnectionIds.has("claude-code") },{ id: "warp", name: "Warp", icon: "warp", connected: false, detected: detectedConnectionIds.has("warp") },{ id: "chatgpt", name: "ChatGPT", icon: "chatgpt", connected: chatgptConnected, detected: detectedConnectionIds.has("chatgpt") },@@ -3859,7 +3983,7 @@ export function ConnectionsSection({category: CONNECTION_CATEGORY_BY_ID[tile.id] ?? tile.category ?? "Other",description: tile.description ?? CONNECTION_HARDCODED_DESCRIPTIONS[tile.id],}));- }, [os, claudeInstalled, cursorInstalled, codexInstalled, chatgptConnected, browserUrlConnected, browserUrlDetected, integrations, appleCalendarConnected, googleCalendarConnected, googleDocsConnected, googleSheetsConnected, gmailConnected, customMcpConnected, customMcpServerCount, krispConnected, plaudConnected, excalidrawConnected, inputMonitoringGranted, importedSkillsCount, detectedConnectionIds]);+ }, [os, claudeInstalled, cursorInstalled, codexInstalled, grokInstalled, chatgptConnected, browserUrlConnected, browserUrlDetected, integrations, appleCalendarConnected, googleCalendarConnected, googleDocsConnected, googleSheetsConnected, gmailConnected, customMcpConnected, customMcpServerCount, krispConnected, plaudConnected, excalidrawConnected, inputMonitoringGranted, importedSkillsCount, detectedConnectionIds]);const isDefaultView = !search.trim() && categoryFilter === ALL_CONNECTION_CATEGORIES;@@ -3927,6 +4051,10 @@ export function ConnectionsSection({onConnected={() => setCodexInstalled(true)}onDisconnected={() => setCodexInstalled(false)}/>;+ case "grok": return <GrokPanel+ onConnected={() => setGrokInstalled(true)}+ onDisconnected={() => setGrokInstalled(false)}+ />;case "claude-code": return <ClaudeCodePanel />;case "chatgpt": return <ChatGptPanel />;case "user-browser": return <UserBrowserCard />;diff --git a/apps/screenpipe-app-tauri/lib/constants/connections.ts b/apps/screenpipe-app-tauri/lib/constants/connections.tsindex 7c4f41f59..7c5fb0d51 100644--- a/apps/screenpipe-app-tauri/lib/constants/connections.ts+++ b/apps/screenpipe-app-tauri/lib/constants/connections.ts@@ -22,6 +22,7 @@ export const CONNECTION_CATEGORY_BY_ID: Record<string, string> = {claude: "Desktop",cursor: "Desktop",codex: "Desktop",+ grok: "Desktop","claude-code": "Desktop",warp: "Desktop",chatgpt: "Desktop",@@ -155,6 +156,7 @@ export const CONNECTION_HARDCODED_DESCRIPTIONS: Record<string, string> = {"claude": "Search your screen & audio from Claude Desktop via MCP","cursor": "Give Cursor AI access to your screen history via MCP","codex": "Give Codex access to your screen & audio via MCP",+ "grok": "Give Grok CLI access to your screen & audio via MCP","claude-code": "Add screen memory to the Claude Code CLI","warp": "Search screen history from Warp terminal via MCP","chatgpt": "Search your screen history from ChatGPT",@@ -204,6 +206,7 @@ export const DEVICE_CONNECTION_ORDER = ["claude","cursor","codex",+ "grok","claude-code","chatgpt","browser-url",diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts b/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.tsindex c487bb913..d7bc6b23e 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts+++ b/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts@@ -77,11 +77,35 @@ export async function isCodexMcpInstalled(): Promise<boolean> {} catch { return false; }}+// Grok CLI (superagent-ai/grok-cli) keeps user settings in+// ~/.grok/user-settings.json. MCP servers live in an *array* under+// `mcp.servers[]` (each entry: { id, label, enabled, transport, command,+// args, env? }) — unlike Claude/Cursor's `mcpServers` object map.+export async function getGrokConfigPath(): Promise<string> {+ const home = await homeDir();+ return join(home, ".grok", "user-settings.json");+}++export function hasEnabledGrokMcp(content: string): boolean {+ try {+ const servers = JSON.parse(content)?.mcp?.servers;+ if (!Array.isArray(servers)) return false;+ return servers.some((s) => s?.id === "screenpipe" && s?.enabled !== false);+ } catch { return false; }+}++export async function isGrokMcpInstalled(): Promise<boolean> {+ try {+ return hasEnabledGrokMcp(await readTextFile(await getGrokConfigPath()));+ } catch { return false; }+}+export function useHardcodedTiles(): HardcodedTile[] {const os = typeof window !== "undefined" ? platform() : "";const [claudeInstalled, setClaudeInstalled] = useState(false);const [cursorInstalled, setCursorInstalled] = useState(false);const [codexInstalled, setCodexInstalled] = useState(false);+ const [grokInstalled, setGrokInstalled] = useState(false);const [chatgptConnected, setChatgptConnected] = useState(false);const [customMcpConnected, setCustomMcpConnected] = useState(false);const [customMcpDetected, setCustomMcpDetected] = useState(false);@@ -95,6 +119,7 @@ export function useHardcodedTiles(): HardcodedTile[] {isCursorMcpInstalled().then(setCursorInstalled).catch(() => {});isCodexMcpInstalled().then(setCodexInstalled).catch(() => {});+ isGrokMcpInstalled().then(setGrokInstalled).catch(() => {});commands.chatgptOauthStatus().then(res => setChatgptConnected(res.status === "ok" && res.data.logged_in))@@ -133,6 +158,7 @@ export function useHardcodedTiles(): HardcodedTile[] {{ id: "claude", name: "Claude Desktop", icon: "claude", connected: claudeInstalled },{ id: "cursor", name: "Cursor", icon: "cursor", connected: cursorInstalled },{ id: "codex", name: "Codex", icon: "codex", connected: codexInstalled },+ { id: "grok", name: "Grok CLI", icon: "grok", connected: grokInstalled },{ id: "claude-code", name: "Claude Code", icon: "claude-code", connected: false },{ id: "warp", name: "Warp", icon: "warp", connected: false },{ id: "chatgpt", name: "ChatGPT", icon: "chatgpt", connected: chatgptConnected },