Skip to content

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

feat(app): add Codex MCP connection

Louis Beaumont8e9f07b40a66
diff --git a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx
index 188b1fcb3..0db262c7b 100644
--- a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx
@@ -91,8 +91,10 @@ async function findClaudeExeOnWindows(): Promise<string | null> {
import {
getClaudeConfigPath,
+ getCodexConfigPath,
getCursorMcpConfigPath,
getInstalledMcpVersion,
+ isCodexMcpInstalled,
isCursorMcpInstalled,
} from "@/lib/hooks/use-hardcoded-tiles";
@@ -142,6 +144,64 @@ async function installCursorMcp(): Promise<void> {
await writeFile(configPath, new TextEncoder().encode(JSON.stringify(config, null, 2)));
}
+const CODEX_SCREENPIPE_TABLE = /(?:^|\n)\[mcp_servers\.screenpipe\][\s\S]*?(?=\n\[(?!mcp_servers\.screenpipe(?:\.|\]))[^\]]+\]|\s*$)/;
+
+function tomlString(value: string): string {
+ return JSON.stringify(value);
+}
+
+function tomlKey(value: string): string {
+ return /^[A-Za-z0-9_-]+$/.test(value) ? value : tomlString(value);
+}
+
+function removeCodexMcpConfig(content: string): string {
+ return content
+ .replace(CODEX_SCREENPIPE_TABLE, "")
+ .replace(/^\n+/, "")
+ .replace(/\n{3,}/g, "\n\n")
+ .trimEnd();
+}
+
+function buildCodexMcpToml(config: McpCommand): string {
+ const lines = [
+ "[mcp_servers.screenpipe]",
+ `command = ${tomlString(config.command)}`,
+ `args = [${config.args.map(tomlString).join(", ")}]`,
+ "enabled = true",
+ ];
+
+ const envEntries = Object.entries(config.env ?? {});
+ if (envEntries.length > 0) {
+ lines.push("", "[mcp_servers.screenpipe.env]");
+ for (const [key, value] of envEntries) {
+ lines.push(`${tomlKey(key)} = ${tomlString(value)}`);
+ }
+ }
+
+ return lines.join("\n");
+}
+
+async function installCodexMcp(): Promise<void> {
+ const configPath = await getCodexConfigPath();
+ let existing = "";
+ try { existing = await readTextFile(configPath); } catch { /* fresh */ }
+
+ const config = await buildMcpConfig();
+ const withoutScreenpipe = removeCodexMcpConfig(existing);
+ const next = `${withoutScreenpipe}${withoutScreenpipe ? "\n\n" : ""}${buildCodexMcpToml(config)}\n`;
+
+ await mkdir(await dirname(configPath), { recursive: true });
+ await writeFile(configPath, new TextEncoder().encode(next));
+}
+
+async function uninstallCodexMcp(): Promise<void> {
+ const configPath = await getCodexConfigPath();
+ let existing = "";
+ try { existing = await readTextFile(configPath); } catch { return; }
+ const next = removeCodexMcpConfig(existing);
+ await writeFile(configPath, new TextEncoder().encode(next ? `${next}\n` : ""));
+}
+
// ---------------------------------------------------------------------------
// Grid tile icons
// ---------------------------------------------------------------------------
@@ -195,6 +255,7 @@ export function IntegrationIcon({ icon }: { icon: string }) {
const 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" />,
"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" />,
@@ -613,6 +674,76 @@ function CursorPanel({ onConnected, onDisconnected }: { onConnected?: () => void
);
}
+function CodexPanel({ onConnected, onDisconnected }: { onConnected?: () => void; onDisconnected?: () => void }) {
+ const [state, setState] = useState<"idle" | "installing" | "installed">("idle");
+ useEffect(() => { isCodexMcpInstalled().then(ok => { if (ok) setState("installed"); }); }, []);
+
+ const manualConfig = useMemo(() => buildCodexMcpToml({
+ command: "npx",
+ args: ["-y", "screenpipe-mcp@latest"],
+ }), []);
+
+ const handleConnect = async () => {
+ try {
+ setState("installing");
+ await installCodexMcp();
+ setState("installed");
+ onConnected?.();
+ } catch (error) {
+ console.error("failed to install codex mcp:", error);
+ await message(
+ "Failed to write Codex MCP config.\n\nManually add a [mcp_servers.screenpipe] block to ~/.codex/config.toml with command npx and args [\"-y\", \"screenpipe-mcp@latest\"].",
+ { title: "Codex MCP Setup", kind: "error" }
+ );
+ setState("idle");
+ }
+ };
+
+ const handleDisconnect = async () => {
+ try { await uninstallCodexMcp(); } catch (e) { console.warn("codex config remove failed:", e); }
+ setState("idle");
+ onDisconnected?.();
+ };
+
+ const openCodex = async () => {
+ try {
+ const os = platform();
+ if (os === "macos") await Command.create("open", ["-a", "Codex"]).execute();
+ else if (os === "windows") await Command.create("cmd", ["/c", "start", "", "Codex"]).execute();
+ else await openUrl("https://chatgpt.com/codex");
+ } catch { await openUrl("https://chatgpt.com/codex"); }
+ };
+
+ return (
+ <div className="space-y-3">
+ <p className="text-xs text-muted-foreground">Give Codex access to your screen &amp; 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={openCodex} size="sm" className="gap-1.5 h-7 text-xs normal-case font-sans tracking-normal">
+ <ExternalLink className="h-3 w-3" />open codex
+ </Button>
+ </div>
+ {state === "installed" && (
+ <p className="text-xs text-muted-foreground">
+ <strong>connected!</strong> open a new Codex session and ask: &quot;what did I do in the last 5 minutes?&quot;
+ </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";
@@ -1704,6 +1835,7 @@ export function ConnectionsSection() {
// Hardcoded connection status
const [claudeInstalled, setClaudeInstalled] = useState(false);
const [cursorInstalled, setCursorInstalled] = useState(false);
+ const [codexInstalled, setCodexInstalled] = useState(false);
const [chatgptConnected, setChatgptConnected] = useState(false);
const [calendarUserDisconnected, setCalendarUserDisconnected] = useState(false);
const [googleCalendarConnected, setGoogleCalendarConnected] = useState(false);
@@ -1726,6 +1858,7 @@ export function ConnectionsSection() {
setClaudeInstalled(localStorage.getItem("screenpipe_claude_connected") === "true");
});
isCursorMcpInstalled().then(setCursorInstalled).catch(() => {});
+ isCodexMcpInstalled().then(setCodexInstalled).catch(() => {});
commands.chatgptOauthStatus().then(res => {
setChatgptConnected(res.status === "ok" && res.data.logged_in);
}).catch(() => {});
@@ -1778,6 +1911,7 @@ export function ConnectionsSection() {
const hardcoded: ConnectionTile[] = [
{ 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: "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 },
@@ -1823,7 +1957,7 @@ export function ConnectionsSection() {
const googleCalTile = hardcoded.find(h => h.id === "google-calendar");
if (googleCalTile) googleCalTile.connected = googleCalendarConnected;
return [...hardcoded, ...apiTiles];
- }, [os, claudeInstalled, cursorInstalled, chatgptConnected, integrations, calendarUserDisconnected, googleCalendarConnected]);
+ }, [os, claudeInstalled, cursorInstalled, codexInstalled, chatgptConnected, integrations, calendarUserDisconnected, googleCalendarConnected]);
const filtered = useMemo(() => {
if (!search.trim()) return allTiles;
@@ -1844,6 +1978,10 @@ export function ConnectionsSection() {
onConnected={() => setCursorInstalled(true)}
onDisconnected={() => setCursorInstalled(false)}
/>;
+ case "codex": return <CodexPanel
+ onConnected={() => setCodexInstalled(true)}
+ onDisconnected={() => setCodexInstalled(false)}
+ />;
case "claude-code": return <ClaudeCodePanel />;
case "chatgpt": return <ChatGptPanel />;
case "user-browser": return <UserBrowserCard />;
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts b/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts
index 062bfe669..65f54f375 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-hardcoded-tiles.ts
@@ -59,10 +59,29 @@ export async function isCursorMcpInstalled(): Promise<boolean> {
} catch { return false; }
}
+export async function getCodexConfigPath(): Promise<string> {
+ const home = await homeDir();
+ return join(home, ".codex", "config.toml");
+}
+
+const CODEX_SCREENPIPE_TABLE = /(?:^|\n)\[mcp_servers\.screenpipe\][\s\S]*?(?=\n\[(?!mcp_servers\.screenpipe(?:\.|\]))[^\]]+\]|\s*$)/;
+
+export function hasEnabledCodexMcp(content: string): boolean {
+ const table = content.match(CODEX_SCREENPIPE_TABLE)?.[0] ?? "";
+ return !!table && !/^\s*enabled\s*=\s*false\s*$/m.test(table);
+}
+
+export async function isCodexMcpInstalled(): Promise<boolean> {
+ try {
+ return hasEnabledCodexMcp(await readTextFile(await getCodexConfigPath()));
+ } 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 [chatgptConnected, setChatgptConnected] = useState(false);
const [calendarConnected, setCalendarConnected] = useState(false);
@@ -72,6 +91,7 @@ export function useHardcodedTiles(): HardcodedTile[] {
.catch(() => setClaudeInstalled(localStorage.getItem("screenpipe_claude_connected") === "true"));
isCursorMcpInstalled().then(setCursorInstalled).catch(() => {});
+ isCodexMcpInstalled().then(setCodexInstalled).catch(() => {});
commands.chatgptOauthStatus()
.then(res => setChatgptConnected(res.status === "ok" && res.data.logged_in))
@@ -86,6 +106,7 @@ export function useHardcodedTiles(): HardcodedTile[] {
return [
{ 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: "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 },
diff --git a/apps/screenpipe-app-tauri/public/images/codex.svg b/apps/screenpipe-app-tauri/public/images/codex.svg
new file mode 100644
index 000000000..289547bee
--- /dev/null
+++ b/apps/screenpipe-app-tauri/public/images/codex.svg
@@ -0,0 +1,2 @@
+<!-- Codex icon from LobeHub Icons, MIT License. Source: https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/codex-color.svg -->
+<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Codex</title><path d="M19.503 0H4.496A4.496 4.496 0 000 4.496v15.007A4.496 4.496 0 004.496 24h15.007A4.496 4.496 0 0024 19.503V4.496A4.496 4.496 0 0019.503 0z" fill="#fff"></path><path d="M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z" fill="url(#lobe-icons-codex-gradient)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-codex-gradient" x1="12" x2="12" y1="3" y2="21"><stop stop-color="#B1A7FF"></stop><stop offset=".5" stop-color="#7A9DFF"></stop><stop offset="1" stop-color="#3941FF"></stop></linearGradient></defs></svg>
diff --git a/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json b/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json
index e11ec2a0c..8b1bbd0de 100644
--- a/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json
+++ b/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json
@@ -160,6 +160,14 @@
"path": "$HOME/.cursor/**",
"requireLiteralLeadingDot": false
},
+ {
+ "path": "$HOME/.codex",
+ "requireLiteralLeadingDot": false
+ },
+ {
+ "path": "$HOME/.codex/**",
+ "requireLiteralLeadingDot": false
+ },
{
"path": "$HOME/Library/Application Support/Claude",
"requireLiteralLeadingDot": false
@@ -466,4 +474,4 @@
]
}
]
-}
\ No newline at end of file
+}